eth_newFilter - Chiliz

This method creates a log filter matching address and topic criteria and returns a filter ID. New matching logs are then retrieved with eth_getFilterChanges.

Parameters

ParameterTypeRequiredDescription
filterObjectobjectYesFilter criteria object

Filter Object

FieldTypeRequiredDescription
fromBlockstringNoStart block in hex, or "latest"
toBlockstringNoEnd block in hex, or "latest"
addressstring | arrayNoContract address(es) to match
topicsarrayNoOrdered topic filters (null matches any)

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_newFilter",
    "params": [{ "fromBlock": "0x14b8a10", "toBlock": "latest", "address": "0x9f2b4c1d7e3a6084b5c9d0e1f2a3b4c5d6e7f809", "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"] }],
    "id": "getblock.io"
}'

example.js

javascriptconst axios = require('axios');

const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    method: 'eth_newFilter',
    params: [{ fromBlock: '0x14b8a10', toBlock: 'latest', address: '0x9f2b4c1d7e3a6084b5c9d0e1f2a3b4c5d6e7f809', topics: ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'] }],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

console.log(response.data.result);

example.py

pythonimport requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'eth_newFilter',
        'params': [{ 'fromBlock': '0x14b8a10', 'toBlock': 'latest', 'address': '0x9f2b4c1d7e3a6084b5c9d0e1f2a3b4c5d6e7f809', 'topics': ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'] }],
        'id': 'getblock.io'
    }
)

print(response.json())

example.rs

rustuse reqwest::Client;
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();

    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&json!({
            "jsonrpc": "2.0",
            "method": "eth_newFilter",
            "params": [{ "fromBlock": "0x14b8a10", "toBlock": "latest", "address": "0x9f2b4c1d7e3a6084b5c9d0e1f2a3b4c5d6e7f809", "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"] }],
            "id": "getblock.io"
        }))
        .send()
        .await?
        .json::<Value>()
        .await?;

    println!("Result: {}", response["result"]);
    Ok(())
}

Response

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": "0x1a4b0d21f8e0c3b6d2a9f7e4c1b8a5d2"
}

Response Parameters

ParameterTypeDescription
jsonrpcstringJSON-RPC protocol version ("2.0")
idstringRequest identifier matching the request
resultstringHex-encoded filter ID

Use Cases

  • Event Watching: Track ERC-20 Transfer events for a token contract
  • Polling Pipelines: Create a filter, then poll changes on an interval
  • Topic Filtering: Match specific event signatures by topic0
  • Multi-Contract Watch: Watch several addresses with one filter

Error Handling

Error CodeMessageDescription
-32602Invalid paramsMalformed filter object or topic list
-32603Internal errorThe node failed to register the filter

Web3 Integration

ethers-example.js

javascriptimport { ethers } from 'ethers';

const provider = new ethers.JsonRpcProvider('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/');

// ethers v6 uses provider.on(filter, cb) rather than raw filter IDs
provider.on({ address: '0x9f2b4c1d7e3a6084b5c9d0e1f2a3b4c5d6e7f809', topics: ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'] }, (log) => console.log(log));

viem-example.js

javascriptimport { createPublicClient, http } from 'viem';

const client = createPublicClient({
  transport: http('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/')
});

const filter = await client.createEventFilter({ address: '0x9f2b4c1d7e3a6084b5c9d0e1f2a3b4c5d6e7f809' });