API Reference

eth_newFilter-zkSync Era

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

Unlike eth_newBlockFilter which notifies you of all new blocks, you can pass in filter options to track new logs matching the topics specified.

To check if the state has changed, call eth_getFilterChanges.

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

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.
params: [
	{
		fromBlock: "0x1",
		toBlock: "0x2",
		address: "0x4200000000000000000000000000000000000006",
		topics: [
			"0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c",
			null,
			[
				"0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
				"0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc",
			],
		],
	},
];

Returns

QUANTITY - A filter id.

Example

Request

curl --request POST \
     --url https://zksync-era-mainnet.unifra.io/v1/{your-api-key} \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "jsonrpc": "2.0",
  "method": "eth_newFilter",
  "params": [
    {
      "fromBlock": "0x0",
      "toBlock": "latest",
      "address": "0x4200000000000000000000000000000000000006",
      "topics": [
        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
      ]
    }
  ],
  "id": 0
}
'

Result

{
  "jsonrpc": "2.0",
  "id": 0,
  "result": "0xd3fa9bc5f388ecd80ca5dda522faef9c"
}

🚧

The below parameter inputs do not work, please reference the section above instead.

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