Visualizing the Ethereum Virtual Machine

December 18, 2025

I find the Ethereum Virtual Machine interesting. So, I wanted to go through the exercise of building and visualizing an Ethereum Virtual Machine, to understand how smart contracts actually run on Ethereum.

The program below stores 42 (0x2a) in memory, reads it back, saves it to storage slot 0, and returns it. Step through it one instruction at a time, or paste your own bytecode.

Program
0 PUSH1 0x2a
2 PUSH1 0x00
4 MSTORE
5 PUSH1 0x00
7 MLOAD
8 PUSH1 0x00
10 SSTORE
11 PUSH1 0x00
13 SLOAD
14 PUSH1 0x00
16 MSTORE
17 PUSH1 0x20
19 PUSH1 0x00
21 RETURN
14 instructions · 22 bytes
PC 0 Gas 21,000
Stack
Empty
Memory
Empty
Storage
Empty
Transient
Empty

Implemented Opcodes

OpcodeNameMin. gasDescription
0x00STOP0Halt execution
0x01ADD3Pop two values, push their sum
0x02MUL5Pop two values, push their product
0x03SUB3Pop two values, push their difference
0x10LT3Less than comparison (a < b → 1, else 0)
0x11GT3Greater than comparison (a > b → 1, else 0)
0x14EQ3Equality check (a == b → 1, else 0)
0x15ISZERO3Check if value is zero (0 → 1, else 0)
0x16AND3Bitwise AND of two values
0x17OR3Bitwise OR of two values
0x18XOR3Bitwise XOR of two values
0x19NOT3Bitwise NOT (256-bit inversion)
0x50POP2Remove top stack item
0x51MLOAD3Load 32 bytes from memory (+ expansion cost)
0x52MSTORE3Store 32 bytes to memory (+ expansion cost)
0x54SLOAD100Load value from storage
0x55SSTORE100Store to storage (100-22100 depending on state)
0x5CTLOAD100Load from transient storage (EIP-1153)
0x5DTSTORE100Store to transient storage (EIP-1153)
0x60PUSH13Push 1-byte value onto stack
0x80DUP13Duplicate top stack item
0x81DUP23Duplicate 2nd stack item
0x90SWAP13Swap top two stack items
0xF3RETURN0Pop offset and size, halt and return that memory