Infura icon

Infura

Interact with blockchain APIs via Infura

Get Logs

AI-generated

Overview

This node operation retrieves blockchain logs that match specified filter criteria using the Infura API. It is useful for monitoring events emitted by smart contracts or transactions within a specified block range. For example, a user can fetch logs from a particular contract address between two blocks or filter logs by specific topics to track certain events.

Use Case Examples

  1. Fetch logs emitted by a specific smart contract between block 1000000 and 1000100.
  2. Retrieve logs filtered by topics to monitor specific event types across the blockchain.

Properties

Name Meaning
Address Contract address to filter logs (optional). If provided, only logs from this address are returned.
From Block Starting block number or tag (hex, "latest", "earliest", "pending") from which to begin fetching logs.
To Block Ending block number or tag (hex, "latest", "earliest", "pending") up to which to fetch logs.
Topics JSON array string representing topics to filter logs by specific event signatures or indexed parameters.

Output

JSON

  • logs - Array of log objects matching the filter criteria.
  • logsCount - Number of logs returned.
  • filter
    • address - Contract address filter used in the query.
    • fromBlock - Starting block filter used in the query.
    • toBlock - Ending block filter used in the query.
    • topics - Topics filter used in the query.
  • metadata
    • network - Blockchain network used for the query.
    • operation - Operation performed, here 'getLogs'.
    • timestamp - Timestamp when the query was executed.
    • infura_endpoint - The Infura API endpoint used for the request.

Dependencies

  • Infura API key credential

Troubleshooting

  • If the 'Topics' input is not a valid JSON array, the node throws an error 'Topics must be a valid JSON array'. Ensure the topics input is correctly formatted JSON.
  • Network or credential misconfiguration can cause request failures. Verify the Infura API credentials and network settings.
  • If no logs are returned, check that the address, block range, and topics filters are correctly set and that relevant events exist in that range.

Links

Discussion