trace
Inspecting Transaction Execution with Trace, VMTrace, and StateDiff
The trace module is for getting a deeper insight into transaction processing. It includes two sets of calls the transaction trace filtering API and the ad-hoc tracing API.
In order to use the Transaction-Trace Filtering API, Erigon must be fully synced with the argument trace in http.api flag.
./build/bin/erigon --http.api: eth,erigon,traceAs for the Ad-hoc Tracing API, as long the blocks have not yet been pruned, the RPC calls will work.
The Ad-hoc Tracing API
The ad-hoc tracing API allows you to perform diagnostics on calls or transactions—whether they are historical ones from the chain or hypothetical ones not yet mined. As long as the blocks have not yet been pruned, the RPC calls will work.
The diagnostics are requested by providing a configuration object that specifies the tracer type to be executed, allowing for deep insight into EVM execution:
trace: Provides a Transaction Trace, showing the sequence of all external calls, internal messages, and value transfers that occurred during execution.vmTrace: Provides a Virtual Machine Execution Trace, delivering a full step-by-step trace of the EVM's state throughout the transaction, including all opcodes and gas usage.stateDiff: Provides a State Difference, detailing all altered portions of the Ethereum state (e.g., storage, balances, nonces) resulting from the transaction's execution.
Providing a Transaction to Trace
There are three primary ways to specify the transaction to be traced:
Hypothetical Call: Providing the transaction information (like sender, recipient, and data) as if making a call using
eth_call(seetrace_call).Raw Transaction: Providing raw, signed transaction data, as when using
eth_sendRawTransaction(seetrace_rawTransaction).Mined Transaction: Providing a transaction hash for a previously mined transaction (see
trace_replayTransaction).
The Transaction-Trace Filtering API
These APIs allow you to get a full externality trace on any transaction executed throughout the Erigon chain. Unlike the log filtering API, you are able to search and filter based only upon address information. Information returned includes the execution of all CREATEs, SUICIDEs and all variants of CALL together with input data, output data, gas usage, amount transferred and the success status of each individual action.
traceAddress field
traceAddress fieldThe traceAddress field of all returned traces, gives the exact location in the call trace [index in root, index in first CALL, index in second CALL, ...].
i.e. if the trace is:
then it should look something like:
[ {A: []}, {B: [0]}, {G: [0, 0]}, {C: [1]}, {G: [1, 0]} ]
JSON-RPC methods
Ad-hoc Tracing
Transaction-Trace Filtering
JSON-RPC API Reference
trace_call
Executes the given call and returns a number of possible traces for it.
Parameters
Object- [Transaction object] wherefromfield is optional andnoncefield is omitted.Array- Type of trace, one or more of:"vmTrace","trace","stateDiff".QuantityorTag- (optional) Integer of a block number, or the string'earliest','latest'or'pending'.
Returns
Array- Block traces
Example
Request
Response
trace_callMany
Performs multiple call traces on top of the same block. i.e. transaction n will be executed on top of a pending block with all n-1 transactions applied (traced) first. Allows to trace dependent transactions.
Parameters
Array- List of trace calls with the type of trace, one or more of:"vmTrace","trace","stateDiff".QuantityorTag- (optional) integer block number, or the string'latest','earliest'or'pending', see the default block parameter.
Returns
Array- Array of the given transactions' traces
Example
Request
Response
trace_rawTransaction
Traces a call to eth_sendRawTransaction without making the call, returning the traces
Parameters
Data- Raw transaction data.Array- Type of trace, one or more of:"vmTrace","trace","stateDiff".
Returns
Object- Block traces.
Example
Request
Response
trace_replayBlockTransactions
Replays all transactions in a block returning the requested traces for each transaction.
Parameters
QuantityorTag- Integer of a block number, or the string'earliest','latest'or'pending'.Array- Type of trace, one or more of:"vmTrace","trace","stateDiff".
Returns
Array- Block transactions traces.
Example
Request
Response
trace_replayTransaction
Replays a transaction, returning the traces.
Parameters
Hash- Transaction hash.Array- Type of trace, one or more of:"vmTrace","trace","stateDiff".
Returns
Object- Block traces.
Example
Request
Response
trace_block
Returns traces created at given block.
Parameters
QuantityorTag- Integer of a block number, or the string'earliest','latest'or'pending'.
Returns
Array- Block traces.
Example
Request
Response
trace_filter
Returns traces matching given filter
Parameters
Object- The filter objectfromBlock:QuantityorTag- (optional) From this block.toBlock:QuantityorTag- (optional) To this block.fromAddress:Array- (optional) Sent from these addresses.toAddress:Address- (optional) Sent to these addresses.after:Quantity- (optional) The offset trace numbercount:Quantity- (optional) Integer number of traces to display in a batch.
Returns
Array- Traces matching given filter
Example
Request
Response
trace_get
Returns trace at given position.
Parameters
Hash- Transaction hash.Array- Index positions of the traces.
Returns
Object- Trace object
Example
Request
Response
trace_transaction
Returns all traces of given transaction
Parameters
Hash- Transaction hash
Returns
Array- Traces of given transaction
Example
Request
Response
Last updated
Was this helpful?