eth_getLogs - Monad
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.
Parameters
filter
object
Yes
The filter options.
filter.fromBlock
string
No
Start block (hex or tag). Default: "latest".
filter.toBlock
string
No
End block (hex or tag). Default: "latest".
filter.address
string/array
No
Contract address or list of addresses.
filter.topics
array
No
Array of 32-byte topic filters.
filter.blockHash
string
No
Restricts logs to a single block (cannot be used with fromBlock/toBlock).
Request
curl --location --request POST 'https://go.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"
}'import 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://go.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));Response
Response Parameters
address
string
Address from which log originated.
topics
array
Array of 0-4 indexed log topics.
data
string
Non-indexed log data.
blockNumber
string
Block number where log was in (hex).
transactionHash
string
Transaction hash.
transactionIndex
string
Transaction index in the block (hex).
blockHash
string
Block hash.
logIndex
string
Log index in the block (hex).
removed
boolean
True 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
403
Forbidden
Missing or invalid ACCESS-TOKEN.
-32602
Invalid params
Invalid filter parameters.
-32005
Limit exceeded
Too many results or block range too large.
-32000
Resource not found
Block not found.
Web3 Integration
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.
Performance Tips
Last updated
Was this helpful?