Infura icon

Infura

Interact with blockchain APIs via Infura

Get Block By Hash

AI-generated

Overview

This node operation retrieves detailed information about a specific blockchain block using its hash via the Infura API. It is useful for blockchain developers, analysts, or anyone needing to fetch block data by its unique hash identifier. For example, it can be used to get the full details of a block including transactions for auditing or monitoring purposes.

Use Case Examples

  1. Retrieve a block by its hash to analyze all transactions within that block.
  2. Fetch block details to verify block metadata such as timestamp, gas used, and block size.

Properties

Name Meaning
Block Hash The unique hash identifier of the block to retrieve.
Include Full Transactions Whether to include full transaction details within the block or just transaction hashes.

Output

JSON

  • blockNumberDecimal - Block number in decimal format.
  • timestampDate - Block timestamp as an ISO date string.
  • gasLimitDecimal - Gas limit of the block in decimal.
  • gasUsedDecimal - Gas used in the block in decimal.
  • sizeDecimal - Size of the block in decimal.
  • transactions - List of transactions in the block, either full details or hashes depending on input.

Dependencies

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

Troubleshooting

  • Ensure the provided block hash is valid and correctly formatted (e.g., starting with '0x').
  • Check that the Infura API credentials are correctly configured and have access to the specified network.
  • If 'Include Full Transactions' is set to true, the response may be large and could impact performance or timeout; consider setting it to false if only transaction hashes are needed.
  • Common error messages include invalid block hash or network errors; verify network connectivity and API limits.

Links

Discussion