eth_getFilterChanges
Polling method for a filter, which returns an array of events that have occurred since the last poll on the Unichain network.
Parameters​
id
(string, required): The filter ID returned from eth_newFilter, eth_newBlockFilter, or eth_newPendingTransactionFilter
Returns​
An array containing different data types depending on the filter type:
For log filters (eth_newFilter):​
Array of log objects with:
address
(string): Address from which this log originatedtopics
(array of strings): Array of 0 to 4 32-byte DATA topicsdata
(string): Contains non-indexed arguments of the logblockNumber
(string): Block number where this log was includedblockHash
(string): Hash of the block where this log was includedtransactionHash
(string): Hash of the transaction that created this logtransactionIndex
(string): Transaction index position in the blocklogIndex
(string): Integer of the log index position in the blockremoved
(boolean): true when the log was removed due to a chain reorganization
For block filters (eth_newBlockFilter):​
Array of 32-byte block hashes for blocks that were newly created
For pending transaction filters (eth_newPendingTransactionFilter):​
Array of 32-byte transaction hashes for transactions that entered the pending state
Implementation Example​
- cURL
- JavaScript
- Python
curl -X POST https://api-unichain-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getFilterChanges",
"params": ["0x16"],
"id": 1
}'
const response = await fetch('https://api-unichain-mainnet.n.dwellir.com/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_getFilterChanges',
params: ['0x16'],
id: 1
})
});
const data = await response.json();
console.log(data.result);
import requests
import json
url = 'https://api-unichain-mainnet.n.dwellir.com/YOUR_API_KEY'
headers = {'Content-Type': 'application/json'}
payload = {
"jsonrpc": "2.0",
"method": "eth_getFilterChanges",
"params": ["0x16"],
"id": 1
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
data = response.json()
print(data['result'])
Response Example​
For log filters:​
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"address": "0x1234567890abcdef1234567890abcdef12345678",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
],
"data": "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
"blockNumber": "0x1b4",
"blockHash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
"transactionHash": "0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321",
"transactionIndex": "0x1",
"logIndex": "0x0",
"removed": false
}
]
}
For block filters:​
{
"jsonrpc": "2.0",
"id": 1,
"result": [
"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321"
]
}
Notes​
- This method only returns changes that occurred since the last poll
- Filters timeout if not accessed within a certain time period (typically 5 minutes)
- The first call to eth_getFilterChanges returns all events since filter creation
- Subsequent calls return only new events since the previous call
- Use eth_getFilterLogs to retrieve all accumulated logs regardless of polling
Need help? Contact our support team or check the Unichain documentation.