BNB Smart Chain

BNB Smart Chain

eth_getBlockTransactionCountByNumber

eth_getBlockTransactionCountByNumber answers a narrow question cheaply: how many transactions sit in the block at a given height or named tag? BNB Smart Chain finalizes new blocks about every three seconds under PoSA and pays its fees in BNB. You pass either a hex block number or a label like latest, safe, or finalized, and receive the count as a hex integer without downloading the full block body. Send the request to https://bsc.therpc.io/YOUR_API_KEY on chain ID 56 whenever you want block fullness but not the transactions themselves.

Use cases

  • Gauge live BSC congestion by polling the latest block and watching how its transaction count rises and falls.
  • Accumulate a per-block fullness time series that feeds gas-price and fee-estimation heuristics for your wallet.
  • Scan a range of heights to flag near-empty blocks or unusually packed ones during validator-performance analysis.

Parameters

#NameTypeRequiredDescription
1blockTagstringYesThe block to count transactions in.

Response

TypeDescription
string (hex)Hex-encoded transaction count.

Example request

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

Try it live in the BNB Smart Chain playground.

Errors & troubleshooting

CodeMessageCause
-32602Invalid paramsBlock tag is malformed or unrecognised.

Common pitfalls

  • Asking with the pending tag counts transactions the node is currently queuing for the next BSC block, so the figure can shift from one call to the next.
  • The value comes back as a hex string such as 0x9c; run it through parseInt(value, 16) before doing any numeric comparison or arithmetic.

Supported networks

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

See also

Parameters

hex block number or "latest"/"earliest"/"pending"/"safe"/"finalized"

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

Ready to call this in production?

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