A stack machine that turns bytecode into checked state changes.
LET’S PICTURE IT
Think of a calculator with a stack of sticky notes. Each instruction adds, removes or transforms the top notes.
SEE IT FOR YOURSELF
Watch a stack machine execute a tiny programStep 1 / 4
The program bytes are PUSH1 02, PUSH1 03, ADD, STOP. The program counter begins at byte zero.
The program bytes are PUSH1 02, PUSH1 03, ADD, STOP. The program counter begins at byte zero.PUSH1 reads its next byte as an immediate value and places two on the stack. The next instruction begins at byte two.The next PUSH1 places three above two. Stack order matters for operations that are not commutative.ADD consumes the top two values and pushes five. The next instruction is STOP at byte five; no storage write is implied by ADD.
Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.
A shared execution model
The Ethereum Virtual Machine runs contract bytecode. Nodes reproduce execution to check the result. It operates with 256-bit stack values and has instructions, called opcodes, for arithmetic, memory, storage and contract calls.
Push, then add
PUSH1 0x02 places 2 on the stack. PUSH1 0x03 places 3 above it. ADD takes the two top values and pushes their sum, 5. Step through the experiment to see the stack change. The example is a tiny fixed program, not a complete virtual machine.
Memory and storage differ
Memory is temporary working space for a call. Storage is persistent state associated with the executing contract’s context. Calldata holds the input for a call. These spaces have different access rules and gas costs.
Execution can fail
An instruction can revert, run out of gas, or fail another check. A REVERT rolls back the call’s state changes and can return error data. An outer call may handle an inner failure. Use revert decoding to identify common error forms before investigating the complete call trace.
QUICK CHECK · NO PRESSURE
What happens after pushing 2, pushing 3, then ADD?
ADD consumes the top two stack values and pushes their sum. It does not itself write storage.