Skip to content

eth_getLogs


Returns logs matching the filter in the parameters.

Parameters

Filter

Parameter Type Required Description
fromBlock string optional Starting block number, inclusive; if not present, latest is assumed
toBlock string optional Ending block number, inclusive; if not present, latest is assumed
address string optional Contract address or list of addresses from which logs should originate
topics string optional Topic elements - see later
blockHash string optional If present, we search the specific block matching this hash

If blockHash is specified, it is an error to also specify fromBlock or toBlock. If fromBlock or toBlock is specified, it is an error to also specify blockHash. fromBlock must be less than or equal to toBlock.

Block Number

The block number can be:

  • A hex number in a string: eg. "0x800"
  • A block hash as a string eg. "0xf77e76c25038b0be1fbd12a4f3e404173802bf0c9a9e62deef7949201d59ebfb
  • "earliest" for the earliest block
  • "latest" for the latest block
  • "safe" for the block that the node's high quorum certificate points to
  • "finalized" for the latest finalized block.
  • "pending" is the block that is about to be created.

Topic specifications

Topic elements represent an alternative that matches any of the contained topics.

Examples (from Erigon):

* `[]`                          matches any topic list
* `[[A]]`                       matches topic A in first position
* `[[], [B]]` or `[None, [B]]`  matches any topic in first position AND B in second position
* `[[A], [B]]`                  matches topic A in first position AND B in second position
* `[[A, B], [C, D]]`            matches topic (A OR B) in first position AND (C OR D) in second position

Return values

We return a list of log objects

Log object

Parameter Type Required Description
removed bool required Always false
logIndex string required Hex string; the (0-based) index of this log within the current transaction receipt
transactionIndex string required Hex string; the (0-based) index of this transaction within the current block
transactionHash string required Hash of the transaction that generated this log
blockHash string required Hash of the block in which the transaction that generated this log appears
blockNumber string required Hex string; the number of the block in which this transaction appears
address string required The address from which this log was emitted
data string required Hex string; the data associated with this log entry
topics string required An array containing the topics associated with this log entry, as an array of hex strings

Example Request

curl -d '{
    "id": "1",
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [ { "fromBlock": "0x779", "toBlock": "0x779" } ]}' -H "Content-Type: application/json" -X POST "https://api.zq2-prototestnet.zilliqa.com/"

Example response

{"jsonrpc":"2.0","result":[{"removed":false,"logIndex":"0x0","transactionIndex":"0x0","transactionHash":"0xcfd9d4473c9467f7fc1fe6f602599c8559ea78953acaae205551bb6c2f55472f","blockHash":"0x224a67320685771e1e0c428b1a271af8339cbd542d1726642c3a14519f25ae9e","blockNumber":"0x779","address":"0xbca0f6f4cbfe8ac37096b674de8f96c701c43f7c","data":"0x00000000000000000000000000000000000000000000000000000000000f4240","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000000000000000000000000000000000000000000000","0x000000000000000000000000cb57ec3f064a16cadb36c7c712f4c9fa62b77415"]}],"id":"1"}

Arguments

Parameter Type Required Description
id string Required "1"
jsonrpc string Required "2.0"
method string Required "DSBlockListing"
params array Requred [ filter ]