The debug_traceBlock
method returns a full trace of all invoked opcodes of all transactions included in the specified block. This method provides comprehensive low-level execution information essential for debugging, security analysis, and optimizing transaction behavior across multiple contracts within a single block context.
This method traces the execution of all transactions in a block at the opcode level.
The RLP-encoded block to trace
Trace options to configure the debugging output
Setting this to true disables storage capture
Setting this to true disables memory capture
Setting this to true disables stack capture
Use a custom tracer (available: callTracer, prestateTracer, 4byteTracer, etc.)
Overrides the default timeout of 5 seconds for JavaScript-based tracing
Array of transaction traces within the block
Gas used by the transaction
Whether the transaction failed
The return value of the transaction
Array of structured EVM operation logs
Program counter position
The executed opcode
Remaining gas
Gas cost for this operation
Call depth
EVM memory contents (if not disabled)
EVM stack contents (if not disabled)
Storage changes (if not disabled)
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"gas": 21000,
"failed": false,
"returnValue": "",
"structLogs": [
{
"pc": 0,
"op": "PUSH1",
"gas": 68232,
"gasCost": 3,
"depth": 1,
"stack": [],
"memory": [],
"storage": {}
},
{
"pc": 2,
"op": "MSTORE",
"gas": 68229,
"gasCost": 12,
"depth": 1,
"stack": ["0x60", "0x40"],
"memory": [
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000"
],
"storage": {}
}
// ... more operations
]
}
// Additional transaction traces...
]
}
When using the callTracer
option, the response is formatted as a call graph for each transaction:
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"type": "CALL",
"from": "0x1923f626bb8dc025849e00f99c25fe2b2f7fb0db",
"to": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"value": "0x0",
"gas": "0x13458",
"gasUsed": "0x8fc",
"input": "0xa9059cbb0000000000000000000000001f9840a85d5af5bf1d1762f925bdaddc4201f984000000000000000000000000000000000000000000000002b5e3af16b1880000",
"output": "0x0000000000000000000000000000000000000000000000000000000000000001",
"calls": [
{
"type": "STATICCALL",
"from": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"to": "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984",
"gas": "0x8fc",
"gasUsed": "0x54b",
"input": "0x70a08231000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7",
"output": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
]
}
// Additional call traces...
]
}
Geth provides several built-in tracers that format the output in different ways:
You can also use JavaScript-based custom tracers for specialized analysis.
This method requires an RLP-encoded block as input:
While all three methods provide block-level transaction traces:
debug_traceBlock
accepts an RLP-encoded block as inputdebug_traceBlockByNumber
accepts a block number or tag (e.g., "latest")debug_traceBlockByHash
accepts a block hashdisableMemory
, disableStack
, or disableStorage
options for better performancecallTracer
is much more efficient