Ethereum
eth_getTransactionByBlockNumberAndIndex
eth_getTransactionByBlockNumberAndIndex returns the transaction at a given position inside a block, with the block addressed by its height or by a tag like latest, finalized, or pending. It's the sibling of the by-hash lookup, but keyed on number instead of hash, which is what you usually want for scanning forward through Ethereum mainnet (chain ID 1, gas paid in ETH) where heights are simple to iterate. Give it a block number and a zero-based hex index, and the node returns the full transaction object sitting at that slot, the same shape eth_getTransactionByHash produces. Querying by number lets you reach symbolic tags like pending that no fixed hash exists for. The endpoint is https://ethereum.therpc.io/YOUR_API_KEY.
Use cases
- March block by block pulling index
0x0from each height to study top-of-block placement, the slot MEV researchers care about most. - Peek at the
pendingblock's contents by index to see what a client expects to include next from the mempool before the slot is sealed. - Scan sequentially over a known height range when you have block numbers in hand and don't need to resolve a hash first — incrementing a counter is cheaper than tracking hashes.
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 Ethereum playground.
Errors & troubleshooting
| Code | Message | Cause |
|---|---|---|
-32602 | Invalid params | Block tag is malformed or transaction index is not a valid hex integer. |
Common pitfalls
- The index is hex-encoded:
"0x0"for the first transaction, never a decimal0. Same goes for higher positions —"0xf", not15. - The
pendingblock is a client's local guess, not a finalized fact. Its ordering and even which transactions appear differ between geth, erigon, nethermind and besu, so don't treat apending-tag result as canonical.
Supported networks
- Mainnet — Chain ID: 1
- Sepolia — Chain ID: 11155111
See also
Parameters
hex block number or "latest"/"earliest"/"pending"/"safe"/"finalized"
0x-prefixed hex integer (e.g. "0x0" for the first transaction)