eth_newFilter - BSC

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

This method creates a filter object for logs on the BNB Smart Chain, which can be polled with eth_getFilterChanges. This is useful for tracking BEP-20 transfers and DeFi events.

Parameters

Parameter
Type
Required
Description

filterObject

object

Yes

Filter options

Filter Object

Field
Type
Required
Description

fromBlock

string

No

Starting block

toBlock

string

No

Ending block

address

string/array

No

Contract address(es)

topics

array

No

Event topics

Returns

Field
Type
Description

result

string

Filter ID

Request Example

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": "latest",
        "address": "0x55d398326f99059fF775485246999027B3197955",
        "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
    }],
    "id": "getblock.io"
}'

Response Example

Response Parameters

Parameter
Type
Description

result

string

Filter ID for polling

Use Cases

  • Track BEP-20 token transfers

  • Monitor PancakeSwap events

  • Build notification systems

  • Index contract events

Error Handling

Error Code
Description

-32602

Invalid params

-32603

Internal error

SDK Integration

Last updated

Was this helpful?