Infura icon

Infura

Interact with blockchain APIs via Infura

Get Transaction By Block Hash And Index

AI-generated

Overview

This node operation retrieves a specific transaction from the Ethereum blockchain by using the block's hash and the transaction's index within that block. It is useful for scenarios where you need detailed information about a particular transaction included in a known block, such as auditing, transaction tracking, or blockchain analysis.

Use Case Examples

  1. Retrieve a transaction from a block when you have the block hash and want to inspect the transaction details at a specific index.
  2. Use case in blockchain analytics to fetch transaction data for verification or reporting.

Properties

Name Meaning
Block Hash The hash of the block from which to retrieve the transaction.
Transaction Index The index of the transaction within the block, specified in hexadecimal format.

Output

JSON

  • result - The raw transaction data retrieved from the blockchain.
  • valueEth - The transaction value converted from Wei to Ether.
  • gasPriceGwei - The gas price of the transaction converted from Wei to Gwei.
  • blockNumberDecimal - The block number containing the transaction, converted from hexadecimal to decimal.
  • transactionIndexDecimal - The transaction index within the block, converted from hexadecimal to decimal.
  • nonceDecimal - The nonce of the transaction, converted from hexadecimal to decimal.
  • metadata
    • network - The blockchain network used (e.g., mainnet, rinkeby).
    • operation - The operation performed, here 'getTransactionByBlockHashAndIndex'.
    • timestamp - The timestamp when the data was retrieved.
    • infura_endpoint - The Infura API endpoint used for the request.
    • raw_response - The full raw response from the Infura API.

Dependencies

  • Infura API key credential with project ID and optional project secret for authentication.

Troubleshooting

  • Ensure the block hash and transaction index are correctly formatted in hexadecimal and correspond to an existing block and transaction.
  • Common errors include invalid parameters or network issues connecting to the Infura endpoint.
  • If the transaction is not found, verify the block hash and index are correct and that the transaction exists in that block.

Links

Discussion