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
pendingtag 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
| # | Name | Type | Required | Description |
|---|---|---|---|---|
| 1 | blockTag | string | Yes | The block containing the transaction. |
| 2 | transactionIndex | string (hex) | Yes | Zero-based position of the transaction within the block. |
Response
| Type | Description |
|---|---|
| object | null | Same transaction object as eth_getTransactionByHash. Returns null if block or index not found. |
Example request
Try it live in the BNB Smart Chain playground.
Errors & troubleshooting
| Code | Message | Cause |
|---|---|---|
-32602 | Invalid params | Block 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 numeric0. - How the
pendingtag 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)