For the complete documentation index, see llms.txt. This page is also available as Markdown.

debug_traceBlockByNumber -Ethereum

Example code for the debug_traceBlockByNumber JSON RPC method. Сomplete guide on how to use debug_traceBlockByNumber JSON RPC in GetBlock Web3 documentation.

This method traces the execution of every transaction in a block identified by number or tag. Same output as debug_traceBlockByHash but with the convenient block-number-based lookup. The most common entry point when iterating through historical blocks for batch trace analysis.

Parameters

Parameter
Type
Required
Description

blockParameter

string

Yes

Block number in hex, or latest, earliest, pending, finalized, safe

tracerOptions

object

No

Trace configuration — same shape as in debug_traceBlock

Request

curl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "debug_traceBlockByNumber",
    "params": [
        "0x1720340",
        {
            "tracer": "callTracer"
        }
    ],
    "id": "getblock.io"
}'
const axios = require('axios');

const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    method: 'debug_traceBlockByNumber',
    params: [
        "0x1720340",
        {
            "tracer": "callTracer"
        }
    ],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

console.log(response.data.result);

Response

Response Parameters

Parameter
Type
Description

jsonrpc

string

JSON-RPC protocol version ("2.0")

id

string

Request identifier matching the request

result

array of object

Array of {txHash, result} records — one per transaction in the block

Use Cases

  • Historical Backfill: Iterate through historical block numbers to build a complete internal-call graph database

  • Analytics Pipelines: Feed trace data into indexers tracking token flows, protocol usage, or MEV events

  • Recent Block Analysis: Trace the latest block for real-time protocol monitoring

Error Handling

Error Code
Message
Description

-32601

Method not found

debug module not enabled — Dedicated Node tier required

-32602

Invalid params

Block parameter is malformed

-32603

Internal error

Node failed to execute the trace

Web3 Integration

Last updated

Was this helpful?