Ethereum

Ethereum

trace_replayTransaction

Give trace_replayTransaction the hash of a transaction that already landed on Ethereum, and the node re-runs it against the state that existed just before it executed, then returns whatever depth of detail you select. You choose any combination of three views: trace (the call tree), vmTrace (an opcode-by-opcode record), and stateDiff (every balance, nonce, code, and storage slot the transaction altered, marked with +, -, *, or =). It's the single-transaction member of the replay family on Ethereum mainnet (chain ID 1), where its block-wide sibling handles entire blocks. Replay requests go to https://ethereum.therpc.io/YOUR_API_KEY and require an archive node, since reconstructing the pre-transaction state means reaching back into history.

Use cases

  • Reconstruct the exact storage writes a past transaction made. The stateDiff lists each touched slot with its before and after value, which is what forensic work on a hack or a mispriced trade depends on.
  • Debug a revert by reading the state diff up to the failure point to pin down which storage slot or balance check tripped the transaction.
  • Build a compliance audit trail: a per-transaction record of every ETH balance shift and storage mutation, sourced straight from the replayed execution rather than inferred from events.

Parameters

#NameTypeRequiredDescription
1transactionHashstringYesHash of the transaction to replay.
2traceTypesarrayYesOne or more of `"trace"`, `"vmTrace"`, `"stateDiff"`. At least one value is required.

Response

TypeDescription
object`{output, trace?, stateDiff?, vmTrace?}` — `trace` is the call tree, `stateDiff` maps each affected address to balance/nonce/code/storage diffs using `=` (unchanged), `+` (created), `-` (deleted), `*{from,to}` (modified), `vmTrace` is the Parity-format opcode trace.

Example request

curl https://ethereum.therpc.io/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "trace_replayTransaction",
"params": [
"0x0000000000000000000000000000000000000000000000000000000000000000",
[
"trace"
]
],
"id": 1
}'

Try it live in the Ethereum playground.

Errors & troubleshooting

CodeMessageCause
-32601Method not foundtrace namespace not enabled or not supported by this client (primarily OpenEthereum/Nethermind/Erigon).
-32602Invalid paramsTransaction hash is missing/malformed or traceTypes is empty or contains unknown values.
-32000transaction not foundTransaction does not exist or archive trace data is unavailable for that block.

Common pitfalls

  • vmTrace on a complex transaction (a multi-hop DEX route, a flash-loan unwind) generates an enormous opcode log. When you only need call structure or storage changes, stick to ["trace"] or ["stateDiff"].
  • The method requires a trace-enabled archive node; the historical state needed for the replay isn't kept by a pruned full node.
  • The vmTrace is Parity-format, not Geth's structLog. If you're migrating from debug_traceTransaction, expect a different schema and adjust your decoder accordingly.

Supported networks

  • Mainnet — Chain ID: 1
  • Sepolia — Chain ID: 11155111

See also

Parameters

0x-prefixed 32-byte hash

["trace"] | ["trace","vmTrace","stateDiff"]

curl https://ethereum.therpc.io/YOUR_API_KEY \
-X POST \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"trace_replayTransaction","params":["0x0000000000000000000000000000000000000000000000000000000000000000",[]]}'

Ready to call this in production?

Free tier covers personal projects. Pay-as-you-go scales without a card.