eth_getLogs - Tron

This method returns event logs matching a filter over a range of blocks, in the Ethereum-compatible shape. It is used to read TRC-20 events such as transfers.

Parameters

ParameterTypeRequiredDescription
filterobjectYesFilter object selecting the logs to return

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/jsonrpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [{"fromBlock": "0x40d2900", "toBlock": "0x40d2a00", "address": "0x41a614f803b6fd780986a42c78ec9c7f77e6ded13c", "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', {
    jsonrpc: '2.0',
    method: 'eth_getLogs',
    params: [{"fromBlock": "0x40d2900", "toBlock": "0x40d2a00", "address": "0x41a614f803b6fd780986a42c78ec9c7f77e6ded13c", "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>/jsonrpc',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'eth_getLogs',
        'params': [{"fromBlock": "0x40d2900", "toBlock": "0x40d2a00", "address": "0x41a614f803b6fd780986a42c78ec9c7f77e6ded13c", "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>/jsonrpc")
        .header("Content-Type", "application/json")
        .json(&json!({
            "jsonrpc": "2.0",
            "method": "eth_getLogs",
            "params": [{"fromBlock": "0x40d2900", "toBlock": "0x40d2a00", "address": "0x41a614f803b6fd780986a42c78ec9c7f77e6ded13c", "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}],
            "id": "getblock.io"
        }))
        .send()
        .await?
        .json::<Value>()
        .await?;

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

Response

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": [
        {
            "address": "0x41a614f803b6fd780986a42c78ec9c7f77e6ded13c",
            "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x000000000000000000000000f0cc5a2a84cd0f68ed1667070934542d673acbd8"
            ],
            "data": "0x00000000000000000000000000000000000000000000000000000000000f4240",
            "blockNumber": "0x40d2980",
            "transactionHash": "0xd5ec749ecc2a615399d8a6c864ea4c74ff9f523c2be0e341ac9be5d47d7c2d62",
            "logIndex": "0x0"
        }
    ]
}

Response Parameters

ParameterTypeDescription
jsonrpcstringJSON-RPC protocol version ("2.0")
idstringRequest identifier matching the request
resultarrayArray of log objects matching the filter

Log Object

FieldTypeDescription
addressstringContract that emitted the log, in hex form
topicsarrayIndexed event topics, starting with the event signature
datastringNon-indexed event data, hex-encoded
transactionHashstringTransaction that emitted the log

Use Cases

  • TRC-20 Transfers: Read token Transfer events for an address or token
  • Event Indexing: Ingest contract events into a database
  • Monitoring: Trigger alerts on specific contract events
  • Analytics: Aggregate historical events over block ranges

Error Handling

Error CodeMessageDescription
-32602Invalid paramsA parameter is missing or has the wrong type or format
-32603Internal errorThe node failed to process the request