Avalanche
eth_getTransactionByBlockHashAndIndex
The eth_getTransactionByBlockHashAndIndex method retrieves transaction information for a specific transaction position within a block, identified by the block's hash.
Use Cases
- Building block explorers to display transaction details
- Analyzing specific transaction positions within blocks
- Verifying transaction inclusion in specific blocks
- Auditing transaction sequences in historical blocks
- Blockchain forensics and transaction tracing
- Smart contract event and state analysis
- Cross-referencing transactions across indexes
- Validating transaction execution order
Method Details
Returns transaction data at the specified index position from a block with the given hash.
Transaction Types
Ethereum transactions have evolved through several formats:
| Type | Description | EIP | Key Fields |
|---|---|---|---|
0x0 | Legacy transactions | Pre-EIP-2718 | gasPrice |
0x1 | Access list transactions | EIP-2930 | gasPrice, accessList |
0x2 | Fee market transactions | EIP-1559 | maxFeePerGas, maxPriorityFeePerGas |
0x7E | Blob transactions | EIP-4844 | Adds blobVersionedHashes, maxFeePerBlobGas |
Response Example
Understanding Transaction Fields
Basic Transaction Information
The transaction object returned by this method contains important fields:
- blockHash/blockNumber: Identifies where this transaction is stored in the blockchain
- transactionIndex: Position of the transaction within the block (0 is first transaction)
- hash: Unique identifier for the transaction
- from: Sender's address (who initiated and signed the transaction)
- to: Recipient address (null indicates contract creation)
- value: Amount of ETH transferred in wei (hexadecimal)
- input: For contract creation/interaction, contains bytecode or encoded function call
- nonce: Sender's transaction count (used to prevent replays)
Gas and Fee Information
Gas and fee fields vary by transaction type:
- gas: Maximum gas the transaction can use
- gasPrice: Price per unit of gas (in legacy and Type-1 transactions)
- maxFeePerGas: Maximum total fee per gas unit (in Type-2 transactions)
- maxPriorityFeePerGas: Maximum priority fee per gas unit (in Type-2 transactions)
Signature Components
The transaction signature consists of three parts:
- v: Recovery ID (helps derive the public key from the signature)
- r and s: The ECDSA signature components
Distinguishing Contract Creation Transactions
You can identify contract creation transactions by checking if the to field is null. For example:
For contract creation transactions, the contract address can be derived from:
- Sender address (
from) - Sender's nonce at that time
- Transaction data
Differences From Related Methods
This method differs from other transaction lookup methods:
| Method | Lookup Key | Use Case |
|---|---|---|
eth_getTransactionByHash | Transaction hash | Direct transaction lookup when hash is known |
eth_getTransactionByBlockHashAndIndex | Block hash + index | When block hash and tx position are known |
eth_getTransactionByBlockNumberAndIndex | Block number + index | When block number and tx position are known |
The block hash-based method provides absolute certainty that you're querying the right block, even in reorg situations, while the block number method is more convenient for sequential access patterns.
See also
- eth_getTransactionByHash - Get transaction information by transaction hash
- eth_getTransactionByBlockNumberAndIndex - Get transaction by block number and index position
- eth_getBlockByHash - Get complete block information including all transactions
- eth_getTransactionReceipt - Retrieve transaction receipt with execution results
Parameters
Hash of the block containing the transaction
Integer of the transaction index position in the block (hex)