Larzscript Flagship Projects

LarzVM — A Gas-Metered Bytecode VM, Built in Larzscript

Every sibling project's require runs once, or a handful of times, per call. Here it runs once per INSTRUCTION executed — however many that turns out to be. Gas is bought upfront, a real pay before a single instruction runs, so a caller who can't afford the worst case never gets to start.

What LarzVM actually does

wallet, pay, and require meter real computation here, not a transaction between two named parties. A program that finishes normally gets its unused gas refunded in full; a program that reverts — out of gas, or a runtime error — still gets its unused gas back, but whatever gas was already consumed before the revert is gone for good.

Every line below is the real output of a fresh run against the actual interpreter — re-run fresh for this page, not copied from documentation. A simple arithmetic program and a real iterative Fibonacci both complete with gas to spare.

larzvm fund alice 100
larzvm run alice simple.asm     --gas-limit=50  --gas-price=0.10  # (3+4)*2
larzvm run alice fibonacci.asm  --gas-limit=300 --gas-price=0.01  # iterative fib(10)
Output
simple:     > 14   gas used 10   ($4.00 refunded)   alice: $99
fibonacci:  > 55   gas used 216  ($0.84 refunded)   alice: $96.84

Both programs finished, so both got their unused gas refunded — the simple one got back $4.00 of its $5.00 budget, and Fibonacci's tighter 300-gas budget still had $0.84 left over once fib(10) actually finished.

larzvm run alice infinite.asm --gas-limit=30 --gas-price=0.10  # JMP back to top, forever
larzvm run alice divzero.asm  --gas-limit=50 --gas-price=0.10
Output
infinite:  REVERTED: out of gas          (30 gas consumed, $0.00 refunded)   alice: $93.84
divzero:   REVERTED: division by zero    (4 gas consumed, $4.60 refunded)    alice: $93.44

The infinite loop (a real JMP straight back to its own start) consumed its entire 30-gas budget before gas metering cut it off — nothing left to refund. The division-by-zero error reverted after only 4 gas, so the other 46 units' worth of its budget still came back.

Why it matters

Every project before this one in the series runs its require once, or a handful of times, per call. LarzVM's gas check runs once per instruction — potentially hundreds of times in a single call — which is the only thing that makes it safe to execute an arbitrary, possibly-infinite program at all, the same refusal logic the course's error-handling lesson covers. wallet, pay, and require are the same money-native core the course's Money-Native Basics lesson teaches — composed here into metering computation instead of a financial transaction.

View source on GitHubFlagship ProjectsLarzscript Course