debug_traceBlock - BSC

The debug_traceBlock method returns traces for all transactions in a block given the block's RLP-encoded bytes on the BNB Smart Chain.

Parameters

ParameterTypeRequiredDescription
blockRlpstringYesRLP-encoded block data
optionsobjectNoTracer options

Request Example

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

const url = 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/';

const payload = {
    jsonrpc: '2.0',
    method: 'debug_traceBlock',
    params: ['0xf90...', { tracer: 'callTracer' }],
    id: 'getblock.io'
};

axios.post(url, payload, {
    headers: { 'Content-Type': 'application/json' }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));
pythonimport requests

url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/"

payload = {
    "jsonrpc": "2.0",
    "method": "debug_traceBlock",
    "params": ["0xf90...", {"tracer": "callTracer"}],
    "id": "getblock.io"
}

response = requests.post(url, headers={"Content-Type": "application/json"}, json=payload)
print(response.json())
rustuse reqwest::Client;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    
    let payload = json!({
        "jsonrpc": "2.0",
        "method": "debug_traceBlock",
        "params": ["0xf90...", {"tracer": "callTracer"}],
        "id": "getblock.io"
    });

    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&payload)
        .send()
        .await?;

    let result: serde_json::Value = response.json().await?;
    println!("{:#?}", result);
    
    Ok(())
}

Response Example

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": [{
        "result": {
            "type": "CALL",
            "from": "0x...",
            "to": "0x...",
            "gasUsed": "0x5208"
        }
    }]
}

Response Parameters

ParameterTypeDescription
resultarrayArray of trace results

Use Cases

  • Analyze entire block execution
  • Debug block-level issues
  • Audit block transactions

Error Handling

Error CodeDescription
-32602Invalid params
-32603Internal error

SDK Integration

javascriptconst { ethers } = require('ethers');

const provider = new ethers.JsonRpcProvider('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/');

const traces = await provider.send('debug_traceBlock', ['0xf90...', { tracer: 'callTracer' }]);
console.log(traces);
javascriptimport { createPublicClient, http } from 'viem';
import { bsc } from 'viem/chains';

const client = createPublicClient({
    chain: bsc,
    transport: http('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/')
});

const traces = await client.request({
    method: 'debug_traceBlock',
    params: ['0xf90...', { tracer: 'callTracer' }]
});