Base
debug_traceBlockByHash
The debug_traceBlockByHash method returns a full trace of all invoked opcodes of all transactions included in the specified block, identified by its hash. This method provides comprehensive opcode-level execution information for analyzing and debugging every transaction within a specified block, making it ideal for deep investigation of blockchain state transitions.
Use Cases
- Debug complex transaction failures and interactions within a specific known block
- Analyze execution patterns across multiple transactions in a precisely identified block
- Investigate gas usage optimization across transactions in historical blocks
- Perform security auditing of deployed contracts in production environments
- Verify correct transaction behavior and execution flow in specific important blocks
- Understand complex multi-contract interactions across a series of transactions
- Analyze historical blocks by their hash to investigate network behavior
- Trace exact execution of transactions for block validation or bug hunting
- Identify patterns in transaction execution within the same block context
- Investigate MEV (Miner Extractable Value) transaction ordering effects
- Debug failed transactions in the context of their block environment
Method Details
This method traces the execution of all transactions in a block, identified by its hash, at the opcode level.
Response Example (Simplified)
Response with callTracer
When using the callTracer option, the response is formatted as a call graph for each transaction:
Available Tracers
Geth provides several built-in tracers:
- Default tracer: Detailed opcode-level execution logs
- callTracer: Focuses on call hierarchy between contracts
- prestateTracer: Shows contract state before execution
- 4byteTracer: Tracks function selector usage statistics
- noopTracer: Minimal tracer for performance testing
- opCountTracer: Counts occurrences of each opcode
You can also use JavaScript-based custom tracers for specialized analysis.
Differences from Other Block Tracing Methods
While all three block tracing methods provide similar information:
debug_traceBlockByHashaccepts a block hash for precise block identificationdebug_traceBlockByNumberuses a block number or tag (e.g., "latest")debug_traceBlockrequires an RLP-encoded block as input- All methods return identical trace formats
- This method is ideal when you know the exact block hash you want to investigate
Performance Considerations
- Tracing entire blocks is extremely resource-intensive, especially for blocks with many transactions
- Response size can be very large for blocks with complex transactions
- Consider using the
disableMemory,disableStack, ordisableStorageoptions - For call graph analysis only, the
callTraceris much more efficient - JavaScript tracers may require longer timeouts for complex blocks
- Queries against historical blocks require an archive node
- Tracing blocks with many transactions may time out on public nodes
- For high-volume blocks, consider tracing individual transactions instead
- Response time increases with block size and transaction complexity
- For blocks with complex transactions, specialized tracers are recommended
Important Notes
- This method requires debug APIs to be enabled on the node (--http.api=eth,debug,net,web3)
- Not all Ethereum clients support this method (primarily Geth with debug APIs enabled)
- For older blocks, an archive node is required to access historical state
- The method provides detailed traces for all transactions in the block, which can result in very large responses
- Different Ethereum clients may produce slightly different trace formats
- The output format depends on the tracer used and may change between client versions
- For regular block information without tracing, use eth_getBlockByHash
See also
- debug_traceBlock - Trace a block using RLP-encoded block data
- debug_traceBlockByNumber - Trace block transactions by number
- debug_traceTransaction - Trace a single transaction
- debug_traceCall - Trace a call without creating a transaction
- eth_getBlockByHash - Get block by hash without tracing
Parameters
The hash of the block to trace
Trace options to configure the debugging output (JSON)