eth_getFilterLogs
Returns an array of all logs matching filter with given id on the Polygon network. This method retrieves all accumulated logs that match the criteria of a previously created filter.
Parameters​
id
(string, required): The filter ID to retrieve logs for (obtained from eth_newFilter, eth_newBlockFilter, or eth_newPendingTransactionFilter)
Returns​
An array of log objects, or an empty array if no logs match the filter. Each log object contains:
address
(string): Address from which this log originatedtopics
(array of strings): Array of 0 to 4 32-byte DATA topics. The first topic is the hash of the signature of the eventdata
(string): Contains non-indexed arguments of the logblockNumber
(string): Block number where this log was included (null when pending)blockHash
(string): Hash of the block where this log was included (null when pending)transactionHash
(string): Hash of the transaction that created this log (null when pending)transactionIndex
(string): Transaction index position in the block (null when pending)logIndex
(string): Integer of the log index position in the block (null when pending)removed
(boolean): true when the log was removed due to a chain reorganization, false if it's a valid log
Implementation Example​
- cURL
- JavaScript
- Python
curl -X POST https://api-polygon-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getFilterLogs",
"params": ["0x16"],
"id": 1
}'
const response = await fetch('https://api-polygon-mainnet.n.dwellir.com/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_getFilterLogs',
params: ['0x16'],
id: 1
})
});
const data = await response.json();
console.log(data.result);
import requests
import json
url = 'https://api-polygon-mainnet.n.dwellir.com/YOUR_API_KEY'
headers = {'Content-Type': 'application/json'}
payload = {
"jsonrpc": "2.0",
"method": "eth_getFilterLogs",
"params": ["0x16"],
"id": 1
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
data = response.json()
print(data['result'])
Response Example​
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"address": "0x1234567890abcdef1234567890abcdef12345678",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000009876543210fedcba9876543210fedcba98765432"
],
"data": "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
"blockNumber": "0x1b4",
"blockHash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
"transactionHash": "0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321",
"transactionIndex": "0x1",
"logIndex": "0x0",
"removed": false
}
]
}
Notes​
- The filter must be created first using
eth_newFilter
,eth_newBlockFilter
, oreth_newPendingTransactionFilter
- This method returns all logs accumulated since the filter was created
- Filters timeout if not accessed within a certain time period (typically 5 minutes)
- Use
eth_getFilterChanges
to get only new logs since the last poll - The
removed
field helps handle chain reorganizations
Need help? Contact our support team or check the Polygon documentation.