Pre-State Tracer

Snapshot accessed account state before execution, with optional before/after diff mode.

The pre-state tracer captures the account state that was accessed during execution. In diff mode, it shows what changed — before and after values for each touched account and storage slot.

Usage

mega-evme run 0x... --trace --tracer pre-state

The tracer name accepts both pre-state and prestate.

Options

Flag
Default
Aliases
Description

--trace.prestate.diff-mode

false

--trace.pre-state.diff-mode

Show state diff (before/after) instead of just the pre-state

--trace.prestate.disable-code

false

--trace.pre-state.disable-code

Omit contract bytecode from the output

--trace.prestate.disable-storage

false

--trace.pre-state.disable-storage

Omit storage slots from the output

Output Format

Schema

Each account entry in the output contains:

Field
Type
Description

balance

hex number

Account balance in wei

nonce

number

Account nonce (only in diff mode)

code

hex bytes

Contract bytecode (omitted with --trace.prestate.disable-code)

storage

object

Storage slots as hex key-value pairs (omitted with --trace.prestate.disable-storage)

In default mode, the output is a flat map of addresses to account state. In diff mode, the output has two top-level keys: pre and post, each containing a map of addresses.

Default Mode (pre-state only)

Shows the state of every account accessed during execution, as it existed before the transaction.

Running mega-evme run 0x60016000526001601ff3 --trace --tracer pre-state produces:

Only fields that were actually read appear — accounts with no code show only balance.

Diff Mode

Shows both the pre (before) and post (after) state for each touched account. Fields that didn't change are omitted from the diff.

Running WETH.deposit() with --trace.prestate.diff-mode shows how the deposit modified balances and storage:

In this example:

  • The sender's balance decreased (paid ETH + gas), and nonce incremented to 1.

  • WETH's balance increased by the deposited amount, and a new storage slot was written (the sender's balance mapping).

  • The code field appears in pre but not post — it didn't change, so diff mode omits it from post.

Examples

Capture pre-state:

Capture state diff (before/after):

Compact diff without code or storage:

Last updated