Ethereum
eth_getTransactionByBlockHashAndIndex
eth_getTransactionByBlockHashAndIndex fetches a single transaction by where it sits, not by what it is. You name a block by its hash and a zero-based position within that block, and Ethereum mainnet (chain ID 1, fees denominated in ETH) returns the full transaction object at that slot. The order matters here: a validator fixes the transaction ordering when it seals the block, and that order is exactly what this index walks. It's the same transaction object you'd get from eth_getTransactionByHash, just addressed positionally. Querying by block hash rather than number means you're pinned to one specific block even across a reorg. Send the call to https://ethereum.therpc.io/YOUR_API_KEY.
Use cases
- Walk a block's transactions in order by incrementing the index from
0x0until you hitnull, when you already have the block hash but not the individual tx hashes. - Pull the first transaction in a block to study ordering — the top slot is where MEV searchers and builders fight to land arbitrage and liquidation bundles.
- Resolve a transaction by its position reference (block hash plus index) when that's how it was cited, instead of needing its hash up front.
Parameters
| # | Name | Type | Required | Description |
|---|---|---|---|---|
| 1 | blockHash | string (hex) | Yes | The hash of 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 hash or transaction index is malformed. |
Common pitfalls
- The index is hex, not decimal. The first transaction is
"0x0", the eleventh is"0xa"— passing a bare0or a decimal10will misfire. - Run the index past the block's last transaction and you get
null, not an error. Pair this witheth_getBlockTransactionCountByNumber, or just treatnullas your stop condition when enumerating.
Supported networks
- Mainnet — Chain ID: 1
- Sepolia — Chain ID: 11155111
See also
- eth_getTransactionByHash
- eth_getTransactionByBlockNumberAndIndex
- eth_getBlockByHash
- eth_getTransactionReceipt
Parameters
0x-prefixed 32-byte block hash
0x-prefixed hex integer (e.g. "0x0" for the first transaction)