eth_getLogs - Mantle

This method returns an array of all logs matching a given filter object on the Mantle network.

Parameters

ParameterTypeDescription
filterObjectobjectThe filter options

Filter Object:

FieldTypeDescription
fromBlockstring(optional) Start block number or "earliest", "latest"
toBlockstring(optional) End block number or "earliest", "latest"
addressstring/array(optional) Contract address or list of addresses
topicsarray(optional) Array of topic filters
blockHashstring(optional) Specific block hash to filter

Request examples

curl

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_getLogs",
    "params": [{
        "fromBlock": "0x3F6700",
        "toBlock": "0x3F6800",
        "address": "0x201EBa5CC46D216Ce6DC03F6a759e8E766e956aE",
        "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
    }],
    "id": "getblock.io"
}'

example.js

javascriptimport axios from 'axios';

const data = JSON.stringify({
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [{
        "fromBlock": "0x3F6700",
        "toBlock": "0x3F6800",
        "address": "0x201EBa5CC46D216Ce6DC03F6a759e8E766e956aE",
        "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
    }],
    "id": "getblock.io"
});

const config = {
    method: 'post',
    url: 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers: {
        'Content-Type': 'application/json'
    },
    data: data
};

axios(config)
    .then(response => console.log(JSON.stringify(response.data)))
    .catch(error => console.log(error));

example.py

pythonimport requests
import json

url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/"

payload = json.dumps({
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [{
        "fromBlock": "0x3F6700",
        "toBlock": "0x3F6800",
        "address": "0x201EBa5CC46D216Ce6DC03F6a759e8E766e956aE",
        "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
    }],
    "id": "getblock.io"
})

headers = {
    'Content-Type': 'application/json'
}

response = requests.post(url, headers=headers, data=payload)
print(response.text)

main.rs

rustuse reqwest::header;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::new();
    
    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header(header::CONTENT_TYPE, "application/json")
        .body(r#"{
            "jsonrpc": "2.0",
            "method": "eth_getLogs",
            "params": [{
                "fromBlock": "0x3F6700",
                "toBlock": "0x3F6800",
                "address": "0x201EBa5CC46D216Ce6DC03F6a759e8E766e956aE",
                "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
            }],
            "id": "getblock.io"
        }"#)
        .send()
        .await?;
    
    println!("{}", response.text().await?);
    Ok(())
}

Response

response.json

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": [
        {
            "address": "0x201EBa5CC46D216Ce6DC03F6a759e8E766e956aE",
            "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x000000000000000000000000...",
                "0x000000000000000000000000..."
            ],
            "data": "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
            "blockNumber": "0x3F6750",
            "transactionHash": "0x...",
            "transactionIndex": "0x0",
            "blockHash": "0x...",
            "logIndex": "0x0",
            "removed": false
        }
    ]
}

Response Parameters

FieldTypeDescription
addressstringContract address that emitted the log
topicsarrayArray of indexed log topics
datastringNon-indexed log data
blockNumberstringBlock number (hex)
transactionHashstringTransaction hash
logIndexstringLog index in the block
removedbooleanTrue if log was removed due to reorg

Use Case

The eth_getLogs method is essential for:

  • Event monitoring and indexing
  • ERC-20 Transfer event tracking
  • DeFi protocol event analysis
  • NFT activity monitoring
  • Smart contract event listening
  • Historical data extraction

Error Handling

Status CodeError MessageCause
403ForbiddenMissing or invalid ACCESS-TOKEN
-32602Invalid paramsInvalid filter parameters
-32005Query limit exceededBlock range too large

Web3 Integration

ethers.js

javascriptimport { ethers } from 'ethers';

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

const logs = await provider.getLogs({
    address: '0x201EBa5CC46D216Ce6DC03F6a759e8E766e956aE',
    fromBlock: 0x3F6700,
    toBlock: 0x3F6800,
    topics: ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef']
});
console.log('Logs:', logs);

viem.js

javascriptimport { createPublicClient, http } from 'viem';
import { mantle } from 'viem/chains';

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

const logs = await client.getLogs({
    address: '0x201EBa5CC46D216Ce6DC03F6a759e8E766e956aE',
    fromBlock: 0x3F6700n,
    toBlock: 0x3F6800n,
    events: ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef']
});
console.log('Logs:', logs);