Optimism
Ready to call this in production?
Free tier covers personal projects. Pay-as-you-go scales without a card.
Optimism
Free tier covers personal projects. Pay-as-you-go scales without a card.
eth_getTransactionByBlockHashAndIndex returns a single transaction from OP Mainnet by pinning it to a block hash and a zero-based position within that block. It is handy when you have already pulled a block and want the transaction at a known slot without a separate hash lookup. OP Mainnet is an OP Stack optimistic rollup (Bedrock) settling to Ethereum L1, with gas paid in ETH and a block roughly every two seconds, so positions within a block are stable once the block is referenced by hash. Send the request to https://optimism.therpc.io/YOUR_API_KEY (chain ID 10, 0xa).
0x0 upward.| # | 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. |
| Type | Description |
|---|---|
| object | null | Same transaction object as eth_getTransactionByHash. Returns null if block or index not found. |
Try it live in the Optimism playground.
| Code | Message | Cause |
|---|---|---|
-32602 | Invalid params | Block hash or transaction index is malformed. |
"0x0" for the first transaction, not the integer 0.null rather than an error, so null-check before reading fields.Parameters
0x-prefixed 32-byte block hash
0x-prefixed hex integer (e.g. "0x0" for the first transaction)