Logs API
Get Logs

Get Logs

Overview

The Get Logs endpoint obtains data on interactions with smart contracts by analyzing their log events. At least one of the following parameters must be specified: topic_0, topic_1, topic_2, topic_3, contract, or origin. The range should be defined by either block_number, timestamp, or block_hash. Logs can be decoded and converted into a human-readable format when a smart contract's ABI is provided.

📘️

Multiple values can be set for these parameters: topic_0, topic_1, topic_2, topic_3, and contract, with a maximum of five items each.

Use Cases

Several possible combinations of parameters should be considered, where origin refers to the address of an EOA wallet, contract is a smart contract's address, topic 0 represents the event signature hash, and topics 1-3 correspond to three indexed arguments as defined in the Solidity code of a particular smart contract. To retrieve specific details about logs and their events, follow the guidelines below.

  1. For logs generated by a particular contract triggered by an EOA wallet, specify both contract and origin.

  2. For logs generated by a particular contract and filtered by event signature hash, specify both the contract and topic 0.

  3. For logs generated by multiple contracts triggered by an EOA wallet and filtered by event signature hash, specify both origin and topic 0.

  4. For logs generated by a particular contract triggered by an EOA wallet and filtered by event signature hash, specify contract, origin, and topic 0.

📘️

When using decoding, the output will include a decoded object with the event name, its parameters and values.

Usage

In this example, we receive all log events on the contract 0x362bc847A3a9637d3af6624EeC853618a43ed7D2 for the last 10,000 blocks.

import * as Parsiq from '@parsiq/parsiq.js';
 
const client = Parsiq.createClient(process.env.API_KEY, Parsiq.ChainId.ETH_MAINNET);
 
const logs = client.logs.getByBlockRange(-10000, 'latest', {
    contract: ['0x362bc847A3a9637d3af6624EeC853618a43ed7D2']
});
 
for await (const event of logs) {
    console.log(event);
}

Output:

{
  id: '000000000118788f-006f-00000001',
  topic_0: '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925',
  topic_1: '0x000000000000000000000000a65a864ca19535e4c06000768c6cfa9f6ebaeb12',
  topic_2: '0x0000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae',
  topic_3: null,
  log_data: '0x000000000000000000000000000000000000000000000018493fba64ef000000',
  tx_hash: '0x914538c36e76d9717427bf2913784e8a8f17e9cb2f887d767312b4a358ac8541',
  block_hash: '0x48007cc4f88cf821abc49c596c309c7464e5036ab12d9708576579372da5bf19',
  block_number: 18380943,
  timestamp: 1697676911,
  op_code: 'LOG3',
  origin: '0xa65a864ca19535e4c06000768c6cfa9f6ebaeb12',
  contract: '0x362bc847a3a9637d3af6624eec853618a43ed7d2'
}

Parameters

Path params
chainId
string
REQUIRED
version
string
REQUIRED
Query params
block_number_start
string
number
REQUIRED
block_number_end
string
number
REQUIRED
origin
string
OR
contract
string
array of strings
OR
topic_0
string
array of strings
OR
topic_1
string
array of strings
OR
topic_2
string
array of strings
OR
topic_3
string
array of strings
op_code
string
limit
number
estimate_cu
boolean