BNB Smart Chain

BNB Smart Chain

debug_traceBlockByNumber

Reach for debug_traceBlockByNumber when you think in heights rather than hashes. You name a block by its hex number or by a tag like latest, earliest, or pending, and the node returns an opcode-level trace of every transaction it contains. That addressing fits the common jobs: walking a contiguous range of heights, or grabbing whatever block sits at the tip right now. BNB Smart Chain (BSC) mints those blocks roughly every three seconds and charges gas in BNB, so the tip moves fast. Point the call at chain ID 56 via https://bsc.therpc.io/YOUR_API_KEY. A full-block replay is heavy work, and it needs a debug-enabled archive node to reach back past the recent window.

Use cases

  • Trace every transaction at a known height in one pass to audit all of that block's state transitions together.
  • Pull a whole block's call graph for MEV research with callTracer, mapping how value moves transaction to transaction.
  • Line up per-transaction gas profiles across a block and flag the outliers worth a closer look.

Parameters

#NameTypeRequiredDescription
1blockNumberstringYesBlock to trace.
2optionsobjectNoSame tracer configuration object as debug_traceTransaction.

Response

TypeDescription
arrayArray of per-transaction trace results in block order. Each element has the same shape as debug_traceTransaction output for the active tracer.

Example request

curl https://bsc.therpc.io/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "debug_traceBlockByNumber",
"params": [
"latest",
{}
],
"id": 1
}'

Try it live in the BNB Smart Chain playground.

Errors & troubleshooting

CodeMessageCause
-32601Method not founddebug namespace not enabled on the node.
-32602Invalid paramsBlock number is malformed or not a recognized tag.
-32000block not foundBlock does not exist or archive state is unavailable for that number.

Common pitfalls

  • A full-block replay re-runs every transaction inside, so a busy BSC block can take minutes and spill gigabytes of structLog data.
  • Historical heights need an archive node. A non-archive node keeps only the recent window and rejects older blocks outright.
  • The latest tag works but races the three-second cadence, so the height you trace can advance between request and response, and lower tiers may rate-limit the call.

Supported networks

  • Mainnet — Chain ID: 56
  • Testnet — Chain ID: 97

See also

Parameters

hex block number or "latest" | "earliest" | "pending"

Same tracer configuration object as debug_traceTransaction.

curl https://bsc.therpc.io/YOUR_API_KEY \
-X POST \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"debug_traceBlockByNumber","params":["latest",{}]}'

Ready to call this in production?

Free tier covers personal projects. Pay-as-you-go scales without a card.