eth_newFilter-polygon

Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call eth_getFilterChanges.

๐Ÿšง

Filters expire after 5 minutes of inactivity (no queries).

Parameters

  • Object - The filter options:
    • fromBlock: QUANTITY|TAG - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.
    • toBlock: QUANTITY|TAG - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.
    • address: DATA|Array, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate.
    • topics: Array of DATA, - (optional) Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.

A note on specifying topic filters

Topics are order-dependent. A transaction with a log with topics [A, B] will be matched by the following topic filters:

  • [] "anything"
  • [A] "A in first position (and anything after)"
  • [null, B] "anything in first position AND B in second position (and anything after)"
  • [A, B] "A in first position AND B in second position (and anything after)"
  • [[A, B], [A, B]] "(A OR B) in first position AND (A OR B) in second position (and anything after)"
curl https://polygon-mainnet-archive.allthatnode.com:8545/8U3JLUhzIDg3GShvy9hkCCSYkLGc11kj \
--request POST \
--header "Content-Type: application/json" \
--data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_newFilter",
  "params": [
    {
      "fromBlock": "0x2B9BB83",
      "toBlock": "0x2B9BB84",
      "address": "0xe2f651480ddd91109d8feb087abd82722fe58ff8"
    }
  ]
}'

Returns

  • QUANTITY - A filter id.
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": "0x0700000000000000ca5cb4ca3744c4b9"
}

Try Yourself

Language
Click Try It! to start a request and see the response here!