eth_getTransactionByBlockHashAndIndex
JSON-RPC method returns transaction information by block hash and transaction index. This method is useful for retrieving specific transactions when you know the block hash and the transaction’s position within that block.
Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.
Parameters
The method takes two parameters:- Block hash - The hash of the block containing the transaction
- Transaction index - The index position of the transaction within the block
Parameter details
blockHash
(string, required) — The 32-byte hash of the block containing the transactiontransactionIndex
(string, required) — The index position of the transaction in the block as a hexadecimal string (0-based)
Response
The method returns detailed transaction information, ornull
if the transaction is not found.
Response structure
Transaction object:hash
— The 32-byte transaction hashnonce
— Transaction nonce (number of transactions sent by sender)blockHash
— Hash of the block containing the transactionblockNumber
— Number of the block containing the transactiontransactionIndex
— Index of the transaction in the blockfrom
— Address of the transaction senderto
— Address of the transaction receiver (null for contract creation)value
— Value transferred in wei as a hexadecimal stringgas
— Gas limit provided by the sendergasPrice
— Gas price provided by the sender in weiinput
— Data sent along with the transactionv
,r
,s
— ECDSA signature componentstype
— Transaction type (0x0 for legacy, 0x1 for EIP-2930, 0x2 for EIP-1559)
Transaction types
Legacy transactions (type 0x0):- Traditional Ethereum transactions
- Use
gasPrice
for fee calculation - Simple fee structure
- Include access lists for gas optimization
- Still use
gasPrice
for fees - Reduce gas costs for certain operations
- Use
maxFeePerGas
andmaxPriorityFeePerGas
- Dynamic fee structure with base fee
- More predictable fee estimation
Hash-based transaction retrieval
Precise block identification
Immutable block references:- Block hashes provide unique, immutable block identification
- Useful during chain reorganizations when block numbers may change
- Ensures retrieval from specific block versions
- Maintains data consistency across different chain states
Index-based access
Sequential processing:- Process transactions in block order using indices (0-based)
- Iterate through all transactions in a block systematically
- Maintain transaction execution order for analysis
- Access specific transactions when index is known
Example request
Shell
Use cases
Theeth_getTransactionByBlockHashAndIndex
method is essential for applications that need to:
- Block transaction processing: Process all transactions in a specific block sequentially
- Transaction ordering analysis: Analyze transaction execution order within blocks
- Block explorers: Display transactions in block context with proper indexing
- Analytics platforms: Collect transaction data for comprehensive analysis
- Audit systems: Verify transaction ordering and block composition
- Development tools: Debug and analyze transaction execution within blocks
- Historical analysis: Study transaction patterns in historical blocks using immutable block hashes
- Integration services: Provide transaction data to external systems with precise block identification
Transaction indices are 0-based and sequential within each block. If the specified index exceeds the number of transactions in the block, the method returns
null
. Block hashes provide immutable identification, useful during chain reorganizations.Body
application/json
JSON-RPC version
Available options:
2.0
The RPC method name
Available options:
eth_getTransactionByBlockHashAndIndex
Parameters: [blockHash, transactionIndex]
Request identifier