The trace_call
method allows you to execute a new message call and get a detailed trace of its execution without adding the transaction to the blockchain. This is like eth_call
but with detailed step-by-step execution traces.
This method simulates a transaction and returns detailed traces of its execution.
The transaction call object
The address the transaction is sent from
The address the transaction is directed to
The gas provided for the transaction (hex)
The gas price in wei (hex)
The value transferred in wei (hex)
The contract method call data
Array of trace types to include in the response
Integer block number, or 'latest', 'earliest', 'pending' (optional)
The trace result object with execution details
The return data from the call
State changes caused by the call (if requested)
Array of trace objects
Details about the call action
Type of call (call, delegatecall, etc.)
Sender address
Gas provided for the call
Input data for the call
Recipient address
Value transferred in wei
Result of the call
Amount of gas used
Output data from the call
Number of subtraces
Address path of trace location in the call tree
Type of trace
Error message if the call failed
Virtual machine execution trace (if requested)
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"output": "0x",
"stateDiff": null,
"trace": [
{
"action": {
"callType": "call",
"from": "0x6f1fb6efdf50f34bfa3f2bc0e5576edd71631638",
"gas": "0x1dcd11f8",
"input": "0xa67a6a45000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000",
"to": "0x1e0447b19bb6ecfdae1e4ae1694b0c3659614e4e",
"value": "0x0"
},
"error": "Reverted",
"subtraces": 0,
"traceAddress": [],
"type": "call"
}
],
"vmTrace": null
}
}
The callType
field in the trace action indicates the type of call:
The type
field in the trace indicates the type of operation:
The traceAddress
field indicates the position in the call tree:
[]
) for top-level callsHere's an example response from trace_call
:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"output": "0x0000000000000000000000000000000000000000000000000000000000000001",
"stateDiff": { /* state changes */ },
"trace": [
{
"action": {
"callType": "call",
"from": "0x407d73d8a49eeb85d32cf465507dd71d507100c1",
"gas": "0x1dcd12f8",
"input": "0xa9059cbb0000000000000000000000002710000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a",
"to": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"value": "0x0"
},
"result": {
"gasUsed": "0x765",
"output": "0x0000000000000000000000000000000000000000000000000000000000000001"
},
"subtraces": 1,
"traceAddress": [],
"type": "call"
},
{
"action": {
"callType": "call",
"from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"gas": "0x1dcd0393",
"input": "0x",
"to": "0x2710000000000000000000000000000000000000",
"value": "0xa"
},
"result": {
"gasUsed": "0x0",
"output": "0x"
},
"subtraces": 0,
"traceAddress": [0],
"type": "call"
}
],
"vmTrace": { /* detailed VM execution information */ }
}
}
While both trace_call
and eth_call
perform simulated calls:
trace_call
provides detailed execution traces not available in eth_call
trace_call
can return several types of traces (operations, VM steps, state changes)trace_call
gives more information for debugging and analysiseth_call
is more lightweight and standard across all Ethereum clientstrace_call
supports historical block state simulation--gcmode=archive
and OpenEthereum/Nethermind)stateDiff
response can be very large for transactions that modify many storage slots