eth_getLogs - Scroll
Example code for the eth_getLogs JSON-RPC method. Complete 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 in a single call. It is the primary method for querying event logs from smart contracts, essential for tracking token transfers, DEX swaps, and other on-chain events.
Parameters
filterObject
object
Yes
Filter criteria object
Filter Object
fromBlock
string
No
Start block in hex, or "latest"
toBlock
string
No
End block in hex, or "latest"
address
string | array
No
Contract address(es) to match
topics
array
No
Ordered topic filters (null matches any position)
blockHash
string
No
Restrict to a single block by hash (mutually exclusive with from/toBlock)
Request
curl --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": "0x14b8a10", "toBlock": "0x14b8b10", "address": "0x4200000000000000000000000000000000000006", "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"] }],
"id": "getblock.io"
}'const axios = require('axios');
const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
jsonrpc: '2.0',
method: 'eth_getLogs',
params: [{ fromBlock: '0x14b8a10', toBlock: '0x14b8b10', address: '0x4200000000000000000000000000000000000006', topics: ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'] }],
id: 'getblock.io'
}, {
headers: { 'Content-Type': 'application/json' }
});
console.log(response.data.result);import requests
response = requests.post(
'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
headers={'Content-Type': 'application/json'},
json={
'jsonrpc': '2.0',
'method': 'eth_getLogs',
'params': [{ 'fromBlock': '0x14b8a10', 'toBlock': '0x14b8b10', 'address': '0x4200000000000000000000000000000000000006', 'topics': ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'] }],
'id': 'getblock.io'
}
)
print(response.json())Response
Response Parameters
jsonrpc
string
JSON-RPC protocol version ("2.0")
id
string
Request identifier matching the request
result
array
Array of log objects matching the filter
Use Cases
Token Transfers: Track ERC-20 Transfer events by topic and address
DEX Activity: Index swap and liquidity events from AMM pools
Indexing: Backfill contract events over a block range
Analytics: Aggregate on-chain events for dashboards
Error Handling
-32602
Invalid params
Malformed filter object or block range
-32005
Limit exceeded
The requested block range or result set is too large
-32603
Internal error
The node failed to assemble the logs
Web3 Integration
Last updated
Was this helpful?