Opcode Tracer

Log every instruction with gas, stack, memory, and storage at each step.

The opcode tracer records every EVM instruction executed, along with gas costs, stack state, memory, and storage changes. This is the default tracer when you pass --trace without specifying --tracer.

Usage

mega-evme run 0x60016000526001601ff3 --trace --tracer opcode

Options

These flags control what the opcode tracer captures. Disabling memory and stack capture significantly reduces trace size for large executions.

Flag
Default
Description

--trace.opcode.disable-memory

false

Omit memory snapshots from each step

--trace.opcode.disable-stack

false

Omit stack snapshots from each step

--trace.opcode.disable-storage

false

Omit storage change records

--trace.opcode.enable-return-data

false

Include return data in each step (off by default for size)

Output Format

The opcode tracer emits Geth-compatible JSON. The top-level object wraps the trace:

Schema

Field
Type
Description

failed

bool

Whether the transaction reverted

gas

number

Total gas used

returnValue

hex string

Return data from the transaction

structLogs

array

Array of per-opcode step objects

Each entry in structLogs:

Field
Type
Description

pc

number

Program counter

op

string

Opcode name (e.g., PUSH1, SSTORE)

gas

number

Gas remaining before this step

gasCost

number

Gas consumed by this step

depth

number

Call depth

stack

array

Stack contents as hex strings (unless disabled)

memory

array

Memory contents as 32-byte hex chunks (unless disabled)

storage

object

Storage changes as key-value hex pairs (unless disabled)

returnData

hex string

Return data at this step (only if enabled)

Example Output

Running mega-evme run 0x60016000526001601ff3 --trace --tracer opcode produces:

Examples

Minimal trace (no memory or stack, for compact output):

Full trace to file with return data:

Last updated