curl --request POST \
--url https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "eth_uninstallFilter",
"params": [
"0xbdc5b4b99ca699e1d734fc4202afee79"
],
"id": 1
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": true
}
curl --request POST \
--url https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "eth_uninstallFilter",
"params": [
"0xbdc5b4b99ca699e1d734fc4202afee79"
],
"id": 1
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": true
}
eth_uninstallFilter
in this page, first create a new filter using one of the following:Then use the fresh filter ID as the parameter for eth_uninstallFilter
.string
— the filter ID that you want to uninstallboolean
— a boolean value indicating whether the filter was successfully uninstalled. true
if successfully removed, and false
if not.eth_uninstallFilter
code examplesweb3.eth.filter
methods have been deprecated and replaced with the web3.eth.subscribe
in web3.js. See web3.js subscriptions.const ethers = require('ethers');
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);
async function removeFilter(filter) {
try {
const removed = await provider.send('eth_uninstallFilter', [filter]);
console.log(removed); // Log whether the filter is removed
} catch (err) {
console.error(err); // Handle errors that may occur
}
}
const filterId = '0x4e7ef166cd43f188b0f8f9e218966a8f' //'YOUR_FILTER_iD'
removeFilter(filterId)
eth_uninstallFilter
is to optimize resource usage in a DApp. When a DApp needs to monitor events on the blockchain, it can create a filter using eth_newFilter,eth_newPendingTransactionFilter, or eth_newBlockFilter to listen for specific events or blocks.
However, once the DApp no longer needs to monitor these events or blocks, it can use eth_uninstallFilter
to stop watching for them. By doing so, the DApp can reduce the number of active filters and free up resources, such as network bandwidth and computational power, that would otherwise be used to maintain the filter.
For example, let’s say that a DApp is monitoring incoming blocks, logs batches of 50 blocks, and then uses uninstallFilter
to remove the filter.Boolean value indicating if the filter was removed or not.
The response is of type object
.
Was this page helpful?