eth_newFilter

Creates a filter object, based on filter options, to notify when the state changes (logs).

Parameters

OBJECT - The filter object

Object NameRequiredTypeDetail
addressString/ArrayAddress or a list of addresses from which logs should originate.
fromBlockStringA hex code of an integer that represents the block number, or "latest" for the last mined block. "pending", "earliest" for not yet mined transactions.
toBlockStringA hex code of an integer that represents the block number, or "latest" for the last mined block. "pending", "earliest" for not yet mined transactions.
topicsArrayArray of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.
"params": [
  {
    "fromBlock": "0x1",
    "toBlock": "0x2",
    "address": "0x8888f1f195afa192cfee860698584c030f4c9db1",
    "topics": [
      "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b", 
      null, 
      [
        "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b", 
        "0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc"
      ]
    ]
  }  
]

📘

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)”

Result

A hex code of an integer that represents the newly created filter ID.

Example

Request

curl <your-endpoint> \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_newFilter","params":[{"fromBlock": "0x1","toBlock": "0x2","address": "0x8888f1f195afa192cfee860698584c030f4c9db1","topics": ["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b", null, ["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b", "0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc"]]}],"id":0}'

Return

{
    "id": 0,
    "jsonrpc": "2.0",
    "result": "0x12bf38f0a996df1bb6604e1055470420"
}
Language
Click Try It! to start a request and see the response here!