BNB Smart Chain

BNB Smart Chain

eth_getTransactionByBlockNumberAndIndex

When you are stepping through BNB Smart Chain by height rather than by hash, eth_getTransactionByBlockNumberAndIndex is the tool to reach a single transaction. Pass a hex block number or a tag such as latest or pending, add a zero-based hex index, and the node returns that one transaction object. You get null if the height or position has no entry. BNB Smart Chain charges gas in BNB and seals blocks about every three seconds, so iterating height-by-height keeps pace with a quick chain. Send each request to https://bsc.therpc.io/YOUR_API_KEY on chain ID 56.

Use cases

  • Sweep across consecutive heights pulling the leading transaction of each block to study ordering and MEV behaviour on BSC.
  • Inspect a queued transaction at a known mempool position by combining the pending tag with its index.
  • Scan blocks in sequence when you already hold the height numbers and have no need to resolve a block hash first.

Parameters

#NameTypeRequiredDescription
1blockTagstringYesThe block containing the transaction.
2transactionIndexstring (hex)YesZero-based position of the transaction within the block.

Response

TypeDescription
object | nullSame transaction object as eth_getTransactionByHash. Returns null if block or index not found.

Example request

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

Try it live in the BNB Smart Chain playground.

Errors & troubleshooting

CodeMessageCause
-32602Invalid paramsBlock tag is malformed or transaction index is not a valid hex integer.

Common pitfalls

  • Encode the index as hex — write "0x0" for the leading transaction, never a plain numeric 0.
  • How the pending tag orders and exposes queued transactions is not uniform across node clients, so do not depend on stable positions there.

Supported networks

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

See also

Parameters

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

0x-prefixed hex integer (e.g. "0x0" for the first transaction)

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

Ready to call this in production?

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