eth_newFilter - Mantle
Example code for the eth_newFilter JSON-RPC method. Complete guide on how to use eth_newFilter JSON-RPC in GetBlock Web3 documentation.
This method creates a filter object to notify when state changes (logs). To check if the state has changed, call eth_getFilterChanges.
Parameters
filterObject
object
Filter options object
Filter Object:
fromBlock
string
Starting block (hex or tag)
toBlock
string
Ending block (hex or tag)
address
string/array
Contract address(es) to filter
topics
array
Array of topic filters
Request
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_newFilter",
"params": [{
"fromBlock": "0x3F6700",
"toBlock": "0x3F6800",
"address": "0x201EBa5CC46D216Ce6DC03F6a759e8E766e956aE",
"topics": []
}],
"id": "getblock.io"
}'import axios from 'axios';
const data = JSON.stringify({
"jsonrpc": "2.0",
"method": "eth_newFilter",
"params": [{
"fromBlock": "0x3F6700",
"toBlock": "0x3F6800",
"address": "0x201EBa5CC46D216Ce6DC03F6a759e8E766e956aE",
"topics": []
}],
"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
result
string
Filter ID to use with eth_getFilterChanges
Use Case
The eth_newFilter method is essential for:
Event monitoring without WebSocket
Log polling applications
Contract event tracking
Backend services monitoring events
DApp event listeners
Error Handling
403
Forbidden
Missing or invalid ACCESS-TOKEN
-32602
Invalid params
Invalid filter parameters
Web3 Integration
Last updated
Was this helpful?