eth_getLogs - BSC

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

This method returns an array of all logs matching a given filter object on the BNB Smart Chain. This is essential for tracking events emitted by smart contracts, monitoring BEP-20 transfers, and building event-driven applications.

Parameters

Parameter
Type
Required
Description

filterObject

object

Yes

The filter options

Filter Object

Field
Type
Required
Description

fromBlock

string

No

Starting block (hex or "latest")

toBlock

string

No

Ending block (hex or "latest")

address

string/array

No

Contract address(es)

topics

array

No

Event topic filters

blockHash

string

No

Specific block hash

Request Example

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

Response Example

Response Parameters

Parameter
Type
Description

address

string

Contract address

topics

array

Event topics

data

string

Event data

blockNumber

string

Block number

transactionHash

string

Transaction hash

Use Cases

  • Track BEP-20 token transfers

  • Monitor PancakeSwap swaps

  • Index DeFi protocol events

  • Build analytics dashboards

Error Handling

Error Code
Description

-32602

Invalid params - malformed filter

-32005

Query returned too many results

-32603

Internal error

SDK Integration

Last updated

Was this helpful?