Skip to main content
Version: Next

debug_traceBlockByNumber

Replays the block identified by the given number 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.

Replays a block and returns traces for all transactions.

Parameters (by position)​

Block string or string required


Show Option 1 Block number string

Block number fields​

Block string required

Block number

Match pattern: ^0x(0|[1-9a-f][0-9a-f]*)$


Show Option 2 Block tag string

Block tag fields​

earliest: The lowest numbered block the client has available; finalized: The most recent crypto-economically secure block, cannot be re-orged outside of manual intervention driven by community coordination; safe: The most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions; latest: The most recent block in the canonical chain observed by the client, this block may be re-orged out of the canonical chain even under healthy/normal conditions; pending: A sample next block built by the client on top of latest and containing the set of transactions usually taken from local mempool. If the safe or finalized tag cannot be resolved to a block, the method responds as it does for an unknown block.

Block string required

earliest: The lowest numbered block the client has available; finalized: The most recent crypto-economically secure block, cannot be re-orged outside of manual intervention driven by community coordination; safe: The most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions; latest: The most recent block in the canonical chain observed by the client, this block may be re-orged out of the canonical chain even under healthy/normal conditions; pending: A sample next block built by the client on top of latest and containing the set of transactions usually taken from local mempool. If the safe or finalized tag cannot be resolved to a block, the method responds as it does for an unknown block.

Allowed values: earliest finalized safe latest pending


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 fields​

  • debug boolean

    Opcode 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 boolean

    Opcode 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 boolean

    Opcode 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 boolean

    Opcode 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 boolean

    Opcode 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 integer

    Opcode 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 string

    Optional 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 string

    The 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 object

    An 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 tracerConfig object

    tracerConfig fields​

    An 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 1 Opcode tracer entry object

Opcode tracer entry fields​

Returned when no named tracer is specified.

Block trace unknown or unknown


Show Option 1 Opcode tracer entry

Opcode tracer entry fields​

Show Option 2 Opcode tracer entry

Opcode tracer entry fields​

Show Option 2 Call tracer entry object

Call tracer entry fields​

Returned when the tracer field is "callTracer".

Block trace unknown or unknown


Show Option 1 Call tracer entry

Call tracer entry fields​

Show Option 2 Call tracer entry

Call tracer entry fields​

Show Option 3 Named tracer entry object

Named 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 fields​

Show Option 2 Named tracer entry

Named tracer entry fields​

Errors​

Error code: 4444

  • code

    4444

  • message

    Pruned history unavailable

Examples​

debug_traceBlockByNumber example (opcode tracer)

Request​

{
"params": [
"0x3",
{
"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"
}
]