🟪 Polygon
eth_getLogs


eth_getLogs JSON-RPC Method

The eth_getLogs method is used to retrieve logs that match a specific set of criteria. Logs are generated by transactions that are processed on the Polygon blockchain.

Parameters

  • Filter object


    • fromBlock [optional, default is "latest"] - The block number or block tag representing the end of the search range, hexadecimal encoded (or “latest”, “earliest” or “pending”)

    • toBlock [optional, default is "latest"] - The block number or block tag representing the end of the search range, hexadecimal encoded (or "latest", "earliest" or "pending")

    • address [optional] - The address of the contract to filter for (or an array of addresses).

    • topics [optional] - An array of up to 4 32-byte data fields that represent the topic of the event. Each topic can also be an array of up to 4 32-byte data fields. If a topic is not specified, it matches any value.The first topic in the array is used as the event signature. All events with a matching signature are returned. The other topics act as filters on the event data. 👉 Learn more (opens in a new tab)

    • blockHash [optional] - A specific block hash to search for logs. If this parameter is present, then the fromBlock and toBlock parameters are ignored.

Returns

  • An array with log objects


    • blockNumber - 20 Bytes - The block where the transaction was included where the log originated from. Null for pending transactions.

    • blockHash - 32 Bytes - The hash of the block where the transaction was included where the log originated from. Null for pending transactions.

    • transactionHash - 32 Bytes - The hash of the transaction that generated the log. Null for pending transactions.

    • transactionIndex - The index of the transaction in the block, where the log originated from.

    • address - The address of the contract that generated the log.

    • topics - An array of 0 to 4 32-byte topics. The first topicis the event signature and the others are indexed filters on the event return data.

    • data - Array of 32-bytes non-indexed return data of the log.

    • logIndex - Index position of the log in the transaction. Null for pending transactions.

    • removed - True when the log was removed, due to a chain reorganization. False if it's a valid log.

Request

POST https://<network>.chainnodes.org/YOUR-API-KEY

Example

💡 Confusing?

Ask our experienced blockchain developers in Telegram

  • HTTPS POST Request with a JSON RPC call in the body
  • Replace YOUR-API-KEY with the API key from your CHAINNODES.ORG Dashboard
  • You can use a different supported network by replacing polygon-mainnet
curl https://polygon-mainnet.chainnodes.org/YOUR-API-KEY \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_getLogs","params": [{"fromBlock": "0xef9b4f", "toBlock": "0xef9b4f", "topics": ["0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67"]}],"id":1}'

Body

{
   "jsonrpc": "2.0",
   "id": 1,
   "result": [
      {
         "address": "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640",
         "topics": [
            "0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67",
            "0x000000000000000000000000f2f400c138f9fb900576263af0bc7fcde2b1b8a8",
            "0x000000000000000000000000f2f400c138f9fb900576263af0bc7fcde2b1b8a8"
         ],
         "data": "0x0000000000000000000000000000000000000000000000000000000059682f00fffffffffffffffffffffffffffffffffffffffffffffffff054554f5c6f00a70000000000000000000000000000000000006b33d80674a4cb1807222e3073180000000000000000000000000000000000000000000000015fc7b7a35506b28f0000000000000000000000000000000000000000000000000000000000031e78",
         "blockNumber": "0xef9b4f",
         "transactionHash": "0x0ab702817d36270e680e0b21d39b40467c0c89e974f41644fcf6d063fff3bcf4",
         "transactionIndex": "0x1d",
         "blockHash": "0x3b0bbb845961c1c403dd680129b7e2cb4261ab77b7c03d4b49855d9712bf75be",
         "logIndex": "0x5f",
         "removed": false
      } ................
 
 
      }
   ]
}

Need RPC API keys?

Get 12.5M archival requests for free today.

JSON-RPC API Documentation by CHAINNODES is based on Erigon node client. Contact us if you are interested in specific methods that are only available on geth, besu, Nethermind or reth