eth_getTransactionByBlockHashAndIndex
The eth_getTransactionByBlockHashAndIndex method returns information about a transaction by block hash and transaction index position. This method allows you to retrieve a specific transaction from a block when you know the exact block hash and the transaction's position within that block.
This method is particularly useful for sequential transaction processing, iterating through all transactions in a specific block, building block explorers that display transactions in order, and analyzing transaction patterns within blocks. Unlike eth_getTransactionByHash which requires knowing the transaction hash, this method lets you discover transactions by their position. The block hash parameter ensures you're querying a specific block even in the case of chain reorganizations, making it more reliable than using block numbers for critical applications.
Parameters
parameter | type | description |
|---|---|---|
blockHash | string (required) | Hash of the block (32 bytes) |
transactionIndex | string (required) | Transaction index position in hex |
Return Object
The method returns a transaction object, or null if no transaction exists at the specified index:
field | type | description |
|---|---|---|
blockHash | string | Hash of the block containing this transaction (32 bytes) |
blockNumber | string | Block number containing this transaction (hex) |
from | string | Address of the sender (20 bytes) |
to | string | Address of the receiver (20 bytes), null for contract creation transactions |
gas | string | Gas limit provided by the sender (hex) |
gasPrice | string | Gas price provided by the sender in wei (hex), for legacy and EIP-2930 transactions |
maxFeePerGas | string | Maximum total fee per gas the sender is willing to pay (hex, in wei), for EIP-1559 transactions |
maxPriorityFeePerGas | string | Maximum priority fee per gas (tip) the sender is willing to pay (hex, in wei), for EIP-1559 transactions |
hash | string | Hash of the transaction (32 bytes) |
input | string | The data sent along with the transaction (hex-encoded). Contains the function signature and encoded parameters for contract calls |
nonce | string | Number of transactions sent by the sender prior to this one (hex) |
value | string | Value transferred in wei (hex) |
transactionIndex | string | Integer of the transaction's index position in the block (hex) |
type | string | Transaction type: 0x0 for legacy, 0x1 for EIP-2930, 0x2 for EIP-1559 |
chainId | string | Chain ID of the transaction (hex) |
v | string | ECDSA recovery id |
r | string | ECDSA signature r |
s | string | ECDSA signature s |
Request Example
Response Example