eth_uninstallFilter | Fantom

Fantom API method used to remove a filter previously created using one of the following methods:

Upon successful execution, the filter is removed and will no longer emit events.

This method can be useful for optimizing resource usage when a developer no longer needs to monitor certain events or blocks. It can also be used to clean up unused filters in order to reduce clutter in the client-side filter list.

๐Ÿšง

Disclaimer

Note that the default interactive example in this page will not work as the filter will be expired.

To test 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.

๐Ÿ‘

Get you own node endpoint today

Start for free and get your app to production levels immediately. No credit card required.

You can sign up with your GitHub, X, Google, or Microsoft account.

Parameters

  • string โ€” the filter ID that you want to uninstall

Response

  • boolean โ€” a boolean value indicating whether the filter was successfully uninstalled. true if successfully removed, and false if not.

eth_uninstallFilter code examples

๐Ÿ“˜

Note that the web3.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)
from web3 import Web3  
node_url = "CHAINSTACK_NODE_URL" 
web3 = Web3(Web3.HTTPProvider(node_url))

def remove_filter(filter_id):
    try:
        removed = web3.eth.uninstall_filter(filter_id)
        return removed
    except Exception as e:
        print(e)

filter_id = '0x0'
print(remove_filter(filter_id))

Use case

One use case for 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.

Try the eth_uninstallFilter RPC method yourself

Language
Click Try It! to start a request and see the response here!