debug_traceBlockByHash
Replays the block identified by the given hash and returns a trace for every transaction in the block. The parent block must be present in the client's database. The genesis block (block 0) cannot be traced because it has no parent state to replay from; clients MUST return an error for this input. When no tracer is specified (or the tracer field is absent), the opcode (struct) logger is used and each entry conforms to OpcodeBlockTransactionTrace, whose result field conforms to OpcodeTransactionTrace. When the tracer field in TraceConfig is "callTracer", each entry conforms to CallTracerBlockEntry, whose result field is the transaction's CallFrame tree. For other named tracers (e.g. "prestateTracer"), the result field contains tracer-specific output; defining the output schemas of other named tracers is outside the scope of this specification. The response is an array ordered by transaction index within the block. Each entry includes the transaction hash paired with its trace result. The array MUST contain exactly one entry for each transaction in the block. System calls (EIP-4788, EIP-2935, EIP-7002, EIP-7251) are not transactions, so clients MUST NOT trace them or add entries for them. If a timeout is configured and reached before tracing completes, the client MUST return an error; no partial results are returned. Clients that do not support execution timeouts MAY ignore the timeout field. Clients MUST return an error if no block with the given hash is found.
Replays a block and returns traces for all transactions.
Parameters (by position)
Block hash string required
TraceConfig object
Configuration object accepted by debug_traceBlockByNumber, debug_traceBlockByHash, debug_traceTransaction, and (extended as TraceCallConfig) debug_traceCall. When the tracer field is absent or empty, the opcode (struct) logger is used and the result conforms to OpcodeTransactionTrace. The fields enableMemory, disableStack, disableStorage, enableReturnData, and limit only apply to the opcode logger and are ignored when a named tracer is set. When the tracer field is "callTracer", the result conforms to CallFrame and tracerConfig accepts CallTracerConfig. For other named tracers (e.g. "prestateTracer"), the result format is tracer-specific; defining the output schemas of other named tracers is outside the scope of this specification.
Show TraceConfig object
TraceConfig objectTraceConfig fields
-
debug
booleanOpcode logger only. When true, the client may print the trace output to its internal log during execution. Has no effect on the JSON-RPC response. Ignored when tracer is set. Default: false.
-
disableStack
booleanOpcode logger only. Setting to true disables stack capture in structLogs. When true, the stack field is omitted from each StructLog entry. Ignored when tracer is set. Default: false.
-
disableStorage
booleanOpcode logger only. Setting to true disables storage capture in structLogs. When true, the storage field is omitted from each StructLog entry. Ignored when tracer is set. Default: false.
-
enableMemory
booleanOpcode logger only. Setting to true enables memory capture in structLogs. When false (default), the memory field is omitted from each StructLog entry. Ignored when tracer is set. Default: false.
-
enableReturnData
booleanOpcode logger only. Setting to true enables return data capture in structLogs. When false (default), the returnData field is omitted from each StructLog entry. Ignored when tracer is set. Default: false.
-
limit
integerOpcode logger only. Maximum number of opcode steps to capture. Zero means no limit. When the limit is reached, execution continues but no further StructLog entries are recorded. The limit counts StructLog entries. Clients MUST NOT apply it as a limit on the size of the output in bytes. Ignored when tracer is set. Default: 0 (unlimited).
Range:
>= 0
-
timeout
stringOptional duration string specifying a timeout for trace execution. Clients that do not support execution timeouts (e.g. streaming implementations) MAY ignore this field. When supported and the timeout is reached, the client MUST return an error; no partial results are returned. Accepts Go duration strings (e.g. "5s", "300ms", "2m").
-
tracer
stringThe name of a built-in or custom tracer to use. When absent or empty, the opcode (struct) logger is used. Example built-in tracer names in go-ethereum include: 4byteTracer, callTracer, prestateTracer, noopTracer, bigramTracer, evmdisTracer, opcountTracer, trigramTracer, unigramTracer. Clients may support different sets of named tracers. Custom JavaScript tracers may also be supplied as an expression string.
-
tracerConfig
objectAn optional tracer-specific configuration object passed to the named tracer. Only applicable when the tracer field is set. The fields accepted here depend on the named tracer in use; for "callTracer" this is CallTracerConfig.
Show
tracerConfigobjecttracerConfigfieldsAn optional tracer-specific configuration object passed to the named tracer. Only applicable when the tracer field is set. The fields accepted here depend on the named tracer in use; for "callTracer" this is CallTracerConfig.
-
additionalProperties
true
Result
Block trace object or object or object
Show Option 3 Named tracer entry object
Named tracer entry objectNamed tracer entry fields
Returned when another named tracer is specified. The result field contains tracer-specific output not defined by this specification; error is present instead when the transaction could not be traced.
Block trace unknown or unknown
Show Option 1 Named tracer entry
Named tracer entry Named tracer entry fields
Show Option 2 Named tracer entry
Named tracer entry Named tracer entry fields
Errors
Error code: 4444
-
code
4444
-
message
Pruned history unavailable
Examples
debug_traceBlockByHash example (opcode tracer)
Request
{
"params": [
"0x79ba0368c2c6563a7d263695b583dcc6d1c25d4988daa0105804d38bdd987f2f",
{
"disableStack": false,
"disableStorage": false,
"enableMemory": false,
"enableReturnData": false
}
]
}
Response
[
{
"result": {
"failed": false,
"gas": 26916,
"returnValue": "0x",
"structLogs": [
{
"depth": 1,
"gas": 68612,
"gasCost": 3,
"op": "PUSH1",
"pc": 0,
"stack": []
},
{
"depth": 1,
"gas": 68609,
"gasCost": 3,
"op": "PUSH1",
"pc": 2,
"stack": [
"0x60"
]
},
{
"depth": 1,
"gas": 68606,
"gasCost": 12,
"op": "MSTORE",
"pc": 4,
"stack": [
"0x60",
"0x40"
]
}
]
},
"txHash": "0xdd8cf045113754c306ba9ac8ac8786235e33bc5c087678084ef260a2a583f127"
}
]