evm command is a developer utility for exercising the Ethereum Virtual Machine in isolation. It is useful for:
- Running bytecode snippets and inspecting output or gas usage
- Executing full state transitions for consensus testing (
t8n) - Validating raw transactions against a fork spec (
t9n) - Assembling sealed block RLPs (
b11r) - Running the Ethereum state test suite
Installation
evm is built alongside the rest of go-ethereum:
Subcommands
| Subcommand | Alias | Description |
|---|---|---|
run | — | Execute arbitrary EVM bytecode |
statetest | — | Run Ethereum state test JSON files |
transition | t8n | Stateless state transition utility |
transaction | t9n | Validate a set of raw transactions |
block-builder | b11r | Assemble and seal a full block RLP |
verkle | vkt | Binary trie helper commands |
Running bytecode (evm run)
The run subcommand executes raw EVM bytecode against an in-memory state.
Basic usage
Tracing execution
Use--trace to emit a structured execution trace to stderr.
Example: PUSH and ADD
The bytecode6001 6002 01 pushes 1 and 2 onto the stack, then adds them.
--trace --trace.format struct, stderr shows each opcode step, the stack state, gas consumed, and the final result.
Inspecting state after execution
Benchmarking
--bench runs the bytecode repeatedly using Go’s testing benchmarker and prints average gas used, execution time, and allocations.
run flags reference
Execution flags
Execution flags
| Flag | Default | Description |
|---|---|---|
--gas | 10000000000 | Gas limit for the execution |
--price | 0 | Gas price (wei) |
--value | 0 | ETH value sent with the call (wei) |
--sender | "sender" | Originating address of the transaction |
--receiver | "receiver" | Address of the contract being called |
--input | — | ABI-encoded calldata (hex) |
--inputfile | — | File containing calldata (hex) |
--codefile | — | File containing bytecode. Use - for stdin. |
--prestate | — | JSON genesis file used as the initial state |
--create | false | Treat the execution as a contract creation rather than a call |
--bench | false | Benchmark the execution |
--dump | false | Dump the state trie after execution |
--statdump | false | Print stack and heap memory info |
Tracing flags
Tracing flags
| Flag | Default | Description |
|---|---|---|
--trace | false | Enable opcode-level tracing |
--trace.format | json | Trace output format: json, struct, or md |
--trace.nomemory | true | Disable memory output in traces |
--trace.nostack | false | Disable stack output in traces |
--trace.nostorage | false | Disable storage output in traces |
--trace.noreturndata | true | Disable return data in traces |
Running state tests (evm statetest)
The statetest subcommand runs Ethereum state test JSON files from the official test suite.
State transition tool (evm t8n)
The transition subcommand (alias t8n) applies a set of transactions to a pre-state and produces a post-state. It is the core primitive used in consensus testing across multiple client implementations.
Transaction validation tool (evm t9n)
The transaction subcommand (alias t9n) validates raw transactions without applying them to state.
Block builder tool (evm b11r)
The block-builder subcommand (alias b11r) assembles a complete block RLP from a header, transactions, and optional ommer/withdrawal data.
