eth_newFilter
Creates a filter object, based on filter options, to notify when the state changes (logs) on Avalanche C-Chain.
Parameters
Object
- The filter options:fromBlock
:QUANTITY|TAG
- (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.toBlock
:QUANTITY|TAG
- (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.address
:DATA|Array
, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate.topics
:Array of DATA
- (optional) Array of 32 Bytes DATA topics.
{
"jsonrpc": "2.0",
"method": "eth_newFilter",
"params": [
{
"fromBlock": "0x1",
"toBlock": "0x2",
"address": "0x8888f1f195afa192cfee860698584c030f4c9db1",
"topics": [
"0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
null,
[
"0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc"
]
]
}
],
"id": 73
}
Returns
QUANTITY
- A filter id.
Implementation Example
- cURL
- JavaScript
curl -X POST https://api-avalanche-mainnet-archive.n.dwellir.com/YOUR_API_KEY/ext/bc/C/rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_newFilter",
"params": [
{
"fromBlock": "0x1",
"toBlock": "0x2",
"address": "0x8888f1f195afa192cfee860698584c030f4c9db1",
"topics": ["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"]
}
],
"id": 73
}'
const response = await fetch('https://api-avalanche-mainnet-archive.n.dwellir.com/YOUR_API_KEY/ext/bc/C/rpc', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_newFilter',
params: [
{
fromBlock: '0x1',
toBlock: '0x2',
address: '0x8888f1f195afa192cfee860698584c030f4c9db1',
topics: ['0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b']
}
],
id: 73
})
});
const data = await response.json();
console.log(data.result);
Response Example
{
"id": 73,
"jsonrpc": "2.0",
"result": "0x1"
}
Note: Use the returned filter ID with eth_getFilterChanges to poll for events on Avalanche C-Chain.
Need help? Contact our support team or check the Avalanche documentation.