Updated on 2023-12-15 GMT+08:00

eth_newFilter

Introduction

This API creates a filter object based on the given filter options to notify when the state changes (logs). It consumes 120 CUs.

Parameter Description

Parameter

Type

Description

address

String

(Optional) A 20-byte contract address or a list of addresses from which logs should originate.

fromBlock

String

(Optional) A hexadecimal block number, or the string (earliest, latest, or pending). Latest is set by default.

toBlock

String

(Optional) A hexadecimal block number, or the string (earliest, latest, or pending). Latest is set by default.

topics

String

(Optional) An array of 32-byte data topics. Topics are order-dependent.

Return Value

It returns the ID of the new filter in hexadecimal.

Request

curl https://your-http-endpoint/v1/<API-KEY> \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_newFilter","params":[{"topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}],"id":73}'