BNB Smart Chain

BNB Smart Chain

eth_getBlockByNumber

eth_getBlockByNumber retrieves a BNB Smart Chain block by its height or by a named tag like latest or finalized, returning the same structure as a hash lookup. BSC is a geth-equivalent EVM fueled by BNB that adds a PoSA block roughly every three seconds, which makes height-by-height retrieval the natural way to walk the chain in order. Direct the request to https://bsc.therpc.io/YOUR_API_KEY (chain ID 56). Back comes that block (header, gas figures, transaction list), or null when the height has not yet been produced.

Use cases

  • Step a BSC indexer forward one height at a time, ingesting every block in sequence.
  • Grab the latest block to feed a real-time monitoring or analytics dashboard.
  • Query the finalized tag to anchor work that must survive any reorg under PoSA finality.
  • Read a block hash-only first to list its transaction hashes, then batch their receipts in a follow-up.

Parameters

#NameTypeRequiredDescription
1blockTagstringYesThe block to retrieve.
2includeTransactionsbooleanYesWhen true, transactions[] contains full transaction objects. When false, only hashes.

Response

TypeDescription
object | nullSame block object as eth_getBlockByHash. Returns null if the block does not exist.

Example request

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

Try it live in the BNB Smart Chain playground.

Errors & troubleshooting

CodeMessageCause
-32602Invalid paramsBlock number is malformed or block tag is unrecognised.

Common pitfalls

  • Send includeTransactions as a genuine boolean; the quoted string "true" is invalid and the node will reject it.
  • When you actually need every receipt in the block, one eth_getBlockReceipts call beats firing N separate eth_getTransactionReceipt requests.
  • With full transactions enabled, a heavily loaded BSC block can balloon to 1-2 MB, so size your buffers and timeouts to match.

Supported networks

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

See also

Parameters

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

true = full tx objects, false = tx hashes only

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

Ready to call this in production?

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