getLogs

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

REQUEST

POST https://mainnet-slice-rpc.com

HEADERS

Content-Type: application/json

REQUEST PARAMS

  • FILTER OBJECT

    • address [optional] - a string representing the address (20 bytes) to check for balance

    • fromBlock [optional, default is "latest"] - an integer block number, or the string "latest", "earliest" or "pending"

    • toBlock [optional, default is "latest"] - an integer block number, or the string "latest", "earliest" or "pending"

    • topics[optional] - Array of 32 Bytes DATA topics. Topics are order-dependent.

    • blockhash:[optional] With the addition of EIP-234, blockHash restricts the logs returned to the single block with the 32-byte hash blockHash. Using blockHash is equivalent to fromBlock = toBlock = the block number with hash blockHash. If blockHash is present in in the filter criteria, then neither fromBlock nor toBlock are allowed.

EXAMPLE

## JSON-RPC over HTTPS POST
curl https://mainnet-slice-rpc.com \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"blockHash": "0x7c5a35e9cb3e8ae0e221ab470abae9d446c3a5626ce6689fc777dcffcab52c70", "topics":["0x241ea03ca20251805084d27d4440371c34a0b85ff108f6bb5611248f73818b80"]}],"id":1}'

## JSON-RPC over WSS
wscat -c ws://mainnet-slice-rpc.com
>{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"blockHash": "0x7c5a35e9cb3e8ae0e221ab470abae9d446c3a5626ce6689fc777dcffcab52c70", "topics":["0x241ea03ca20251805084d27d4440371c34a0b85ff108f6bb5611248f73818b80"]}],"id":1}

RESPONSE

RESULT FIELDS

  • LOG OBJECTS - An array of log objects, or an empty array if nothing has changed since last poll.

    • logs are objects with following params:

      • removed: true when the log was removed, due to a chain reorganization. false if it's a valid log.

      • logIndex: integer of the log index position in the block. null when its pending log.

      • transactionIndex: integer of the transactions index position log was created from. null when its pending log.

      • transactionHash: 32 Bytes - hash of the transactions this log was created from. null when its pending log.

      • blockHash: 32 Bytes - hash of the block where this log was in. null when its pending. null when its pending log.

      • blockNumber: the block number where this log was in. null when its pending. null when its pending log.

      • address: 20 Bytes - address from which this log originated.

      • data: contains one or more 32 Bytes non-indexed arguments of the log.

      • topics: Array of 0 to 4 32 Bytes of indexed log arguments. (In solidity: The first topic is the hash of the signature of the event (e.g. Deposit(address,bytes32,uint256)), except you declared the event with the anonymous specifier.)

BODY

LIMITATIONS

To prevent queries from consuming too many resources, eth_getLogs requests are currently limited by two constraints:

  • A max of 10,000 results can be returned by a single query

  • Query duration must not exceed 10 seconds

If a query returns too many results or exceeds the max query duration, one of the following errors is returned:

If this happens:

  • Limit your query to a smaller number of blocks using fromBlock and toBlock.

  • If querying for commonly used topics, consider limiting to a single Smart Contract address as well.

Last updated