debug_traceBlockByNumber - Base
Example code for the debug_traceBlockByNumber JSON-RPC method. Complete guide on how to use debug_traceBlockByNumber JSON-RPC in GetBlock Web3 documentation.
Parameters
Parameter
Type
Required
Description
Trace Options
Field
Type
Description
Request
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "debug_traceBlockByNumber",
"params": ["0x12d687f", {"tracer": "callTracer"}],
"id": "getblock.io"
}'const axios = require('axios');
const blockNumber = '0x12d687f';
const response = await axios.post('https://go.getblock.io/<ACCESS-TOKEN>/', {
jsonrpc: '2.0',
method: 'debug_traceBlockByNumber',
params: [blockNumber, { tracer: 'callTracer' }],
id: 'getblock.io'
}, {
headers: { 'Content-Type': 'application/json' }
});
const traces = response.data.result;
console.log('Total Transactions Traced:', traces.length);
traces.forEach((trace, index) => {
console.log(`Tx ${index}: ${trace.result.type}`);
});Response
Response Parameters
Parameter
Type
Description
Trace Object
Field
Type
Description
Use Cases
Error Handling
Error Code
Message
Description
Web3 Integration
Last updated
Was this helpful?