eth_getLogs - Monad

This method returns an array of all logs matching a given filter object.

Parameters

ParameterTypeRequiredDescription
filterobjectYesThe filter options.
filter.fromBlockstringNoStart block (hex or tag). Default: "latest".
filter.toBlockstringNoEnd block (hex or tag). Default: "latest".
filter.addressstring/arrayNoContract address or list of addresses.
filter.topicsarrayNoArray of 32-byte topic filters.
filter.blockHashstringNoRestricts logs to a single block (cannot be used with fromBlock/toBlock).

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_getLogs",
    "params": [{
        "fromBlock": "0x1",
        "toBlock": "0xa",
        "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
        "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
    }],
    "id": "getblock.io"
}'
javascriptimport axios from 'axios';

const data = JSON.stringify({
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [{
        "fromBlock": "0x1",
        "toBlock": "0xa",
        "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
        "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));
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": "0x1",
        "toBlock": "0xa",
        "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
        "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
    }],
    "id": "getblock.io"
})

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

response = requests.post(url, headers=headers, data=payload)
print(response.text)
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": "0x1",
                "toBlock": "0xa",
                "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
                "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
            }],
            "id": "getblock.io"
        }"#)
        .send()
        .await?;
    
    println!("{}", response.text().await?);
    Ok(())
}

Response

Response (example)

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": [
        {
            "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
            "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x000000000000000000000000742d35cc6634c0532925a3b844bc9e7595f0beb",
                "0x0000000000000000000000004bbeeb066ed09b7aed07bf39eee0460dfa261520"
            ],
            "data": "0x0000000000000000000000000000000000000000000000000000000005f5e100",
            "blockNumber": "0x5",
            "transactionHash": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
            "transactionIndex": "0x0",
            "blockHash": "0xdc0818cf78f21a8e70579cb46a43643f78291264dda342ae31049421c82d21ae",
            "logIndex": "0x0",
            "removed": false
        }
    ]
}

Response Parameters

FieldTypeDescription
addressstringAddress from which log originated.
topicsarrayArray of 0-4 indexed log topics.
datastringNon-indexed log data.
blockNumberstringBlock number where log was in (hex).
transactionHashstringTransaction hash.
transactionIndexstringTransaction index in the block (hex).
blockHashstringBlock hash.
logIndexstringLog index in the block (hex).
removedbooleanTrue if log was removed due to chain reorganization.

Use Case

The eth_getLogs method is essential for:

  • Tracking token transfers (ERC-20, ERC-721)
  • Monitoring DeFi protocol events
  • Building event-driven applications
  • Indexing blockchain data
  • Transaction history analysis
  • Real-time event notifications

Error Handling

Status CodeError MessageCause
403ForbiddenMissing or invalid ACCESS-TOKEN.
-32602Invalid paramsInvalid filter parameters.
-32005Limit exceededToo many results or block range too large.
-32000Resource not foundBlock not found.

Web3 Integration

javascriptimport { ethers } from 'ethers';

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

// ERC-20 Transfer event signature
const transferTopic = ethers.id('Transfer(address,address,uint256)');

const logs = await provider.getLogs({
    fromBlock: 1,
    toBlock: 10,
    address: tokenAddress,
    topics: [transferTopic]
});

logs.forEach(log => {
    console.log('Transfer in block:', log.blockNumber);
});
jsimport { createPublicClient, http } from 'viem';
import { monad } from 'viem/chains';

// Create Viem client with GetBlock
const client = createPublicClient({
  chain: monad,
  transport: http("https://shared.us-east-1.getblock.io/<ACCESS_TOKEN>"),
});

// Using the method through Viem
async function fetchAccountViem() {
    try {
        // Method-specific Viem implementation
        const result = await client.request({
           method: "eth_getLogs",
           params: [{
            "fromBlock": "0x1",
            "toBlock": "0xa",
            "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
            "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
        }],
        });
        console.log('Result:', result);
        return result;
    } catch (error) {
        console.error('Viem Error:', error);
        throw error;
    }
}

Block Range Limit

Important: Monad has a maximum block range of 1000 blocks for eth_getLogs.

Due to Monad's high throughput (much larger blocks than Ethereum), we recommend using small block ranges (1-10 blocks) for optimal performance.

Example: recommended vs not recommended

javascript// Recommended: Small block ranges
const logs = await provider.getLogs({
    fromBlock: latestBlock - 10,
    toBlock: latestBlock,
    address: contractAddress
});

// Not recommended: Large ranges may timeout
// fromBlock: 0, toBlock: 'latest' // May fail

Performance Tips

  1. Use specific addresses

    Always filter by contract address when possible.

  2. Use topics

    Filter by event signatures to reduce results.

  3. Paginate

    For large queries, break into smaller block ranges.

  4. Use blockHash

    When querying a single block, use the blockHash parameter.