Infura icon

Infura

Interact with blockchain APIs via Infura

Get Transaction By Block Number And Index

AI-generated

Overview

This node interacts with the Infura blockchain API to retrieve details of a specific transaction by its block number and transaction index within that block. It is useful for blockchain developers or analysts who need to fetch transaction data from Ethereum blocks, for example, to verify transaction details or analyze blockchain activity.

Use Case Examples

  1. Retrieve the transaction at index 0 in the latest block to monitor recent blockchain activity.
  2. Fetch a transaction by specifying a particular block number and transaction index to audit or debug blockchain transactions.

Properties

Name Meaning
Block Number The block number (in hex) or tag (latest, earliest, pending) from which to retrieve the transaction.
Transaction Index The index (in hex) of the transaction within the specified block.

Output

JSON

  • result - The raw transaction data returned by the Infura API.
  • valueEth - Transaction value converted from Wei to Ether.
  • gasPriceGwei - Gas price of the transaction converted from Wei to Gwei.
  • blockNumberDecimal - Block number converted from hex to decimal.
  • transactionIndexDecimal - Transaction index converted from hex to decimal.
  • nonceDecimal - Nonce of the transaction converted from hex to decimal.
  • metadata
    • network - The blockchain network used (e.g., mainnet, rinkeby).
    • operation - The operation performed, here 'getTransactionByBlockNumberAndIndex'.
    • timestamp - Timestamp when the data was fetched.
    • 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

Troubleshooting

  • Common issues include invalid block number or transaction index formats, which must be in hex or valid tags like 'latest'.
  • Errors may occur if the Infura API credentials are incorrect or missing.
  • If the transaction does not exist at the specified block number and index, the response will be empty or null.
  • Ensure the network specified in credentials matches the blockchain network of the block number.

Links

Discussion