eth_getLogs - zkSync
Example code for the eth_getLogs JSON-RPC method. Сomplete guide on how to use eth_getLogs JSON-RPC in GetBlock.io Web3 documentation.
Returns logs matching a given filter. Filters specify block range, address, and indexed topics — efficient retrieval of contract events like ERC-20 transfers.
Parameters
filterObject
object
Yes
Filter with optional fromBlock, toBlock, address (single or array), topics (array of topic filters)
Request Example
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": "0x2249b3",
"toBlock": "latest",
"address": "0x36615cf349d7f6344891b1e7ca7c72883f5dc049",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
]
}
],
"id": "getblock.io"
}'import axios from 'axios';
const data = JSON.stringify({
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [
{
"fromBlock": "0x2249b3",
"toBlock": "latest",
"address": "0x36615cf349d7f6344891b1e7ca7c72883f5dc049",
"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, null, 2)))
.catch(error => console.log(error));Response Example
Response Parameters
result
array
Array of log objects matching the filter
result[].address
string
Contract address that emitted the log
result[].topics
array of string
Indexed event topics; topic 0 is typically the event signature hash
result[].data
string
Non-indexed event data (ABI-encoded)
result[].l1BatchNumber
string
L1 batch number (zkSync extension)
Use Cases
Indexing ERC-20 transfers on zkSync
Tracking DEX swap events for analytics
Building real-time event-driven dApps
Backfilling historical contract activity
Error Handling
403
Forbidden
Missing or invalid <ACCESS-TOKEN>
-32602
Invalid params
Request parameters are missing or malformed
-32601
Method not found
Method does not exist or is not enabled on this node
429
Too Many Requests
Rate limit exceeded for your plan
-32005
Limit exceeded
Block range or returned result set exceeds the provider's limit; narrow your filter
SDK Integration
Last updated
Was this helpful?