Skip to content

eth_getLogs

Returns an array of all logs matching the given filter object.

Parameters

  1. object - The filter object:
    • fromBlock (optional) - string: Integer block number, or "latest", "earliest" or "pending"
    • toBlock (optional) - string: Integer block number, or "latest", "earliest" or "pending"
    • address (optional) - string or array: Contract address or array of addresses from which logs should originate
    • topics (optional) - array: Array of 32-byte DATA topics. Topics are order-dependent
    • blockHash (optional) - string: Hash of the block to get logs from (overrides fromBlock/toBlock)

Example

[{
  "fromBlock": "0x1",
  "toBlock": "0x2",
  "address": "0x8888f1f195afa192cfee860698584c030f4c9db1",
  "topics": [
    "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
    null,
    [
      "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
      "0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc"
    ]
  ]
}]

Returns

array

An array of log objects, each containing:

interface Log {
  removed: boolean; // Whether the log was removed due to a chain reorganization
  logIndex: string; // Integer of the log index position in the block
  transactionIndex: string; // Integer of the transaction's index position the log was created from
  transactionHash: string; // Hash of the transaction this log was created from
  blockHash: string; // Hash of the block where this log was in
  blockNumber: string; // The block number where this log was in
  address: string; // Address from which this log originated
  data: string; // Contains non-indexed parameters of the log
  topics: Array<string>; // Array of up to 4 32-byte topics, topic[0] is the event signature
}

Errors

CodeMessage
-32602Invalid parameters
-32005Filter not found
-32000Log response too large