eth_newFilter - Mantle

Example code for the eth_newFilter JSON-RPC method. Complete guide on how to use eth_newFilter JSON-RPC in GetBlock Web3 documentation.

This method creates a filter object to notify when state changes (logs). To check if the state has changed, call eth_getFilterChanges.

Parameters

Parameter
Type
Description

filterObject

object

Filter options object

Filter Object:

Field
Type
Description

fromBlock

string

Starting block (hex or tag)

toBlock

string

Ending block (hex or tag)

address

string/array

Contract address(es) to filter

topics

array

Array of topic filters

Request

curl
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_newFilter",
    "params": [{
        "fromBlock": "0x3F6700",
        "toBlock": "0x3F6800",
        "address": "0x201EBa5CC46D216Ce6DC03F6a759e8E766e956aE",
        "topics": []
    }],
    "id": "getblock.io"
}'

Response

Response Parameters

Field
Type
Description

result

string

Filter ID to use with eth_getFilterChanges

Use Case

The eth_newFilter method is essential for:

  • Event monitoring without WebSocket

  • Log polling applications

  • Contract event tracking

  • Backend services monitoring events

  • DApp event listeners

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid ACCESS-TOKEN

-32602

Invalid params

Invalid filter parameters

Web3 Integration

Last updated

Was this helpful?