viem-goviem-go

uninstallFilter

Destroys a filter and frees server resources

Destroys a filter and frees server resources.

Filters timeout when they aren't requested with eth_getFilterChanges for a period of time, so this is mainly useful for cleanup when you're done with a filter early.

Import

Import the public actions package so you can call this action.

import "github.com/ChefBingbong/viem-go/actions/public"

Usage

An example showing how to create a filter, then uninstall it when you are finished.

import (
"context"
"log"
"github.com/ChefBingbong/viem-go/actions/public"
"github.com/ChefBingbong/viem-go/client"
"github.com/ChefBingbong/viem-go/client/transport"
"github.com/ChefBingbong/viem-go/chain/definitions"
)
ctx := context.Background()
publicClient, err := client.CreatePublicClient(client.PublicClientConfig{
Chain: definitions.Mainnet,
Transport: transport.HTTP("https://eth.llamarpc.com"),
})
if err != nil {
log.Fatal(err)
}
defer func() { _ = publicClient.Close() }()
filter, err := public.CreatePendingTransactionFilter(ctx, publicClient)
if err != nil {
log.Fatal(err)
}
success, err := public.UninstallFilter(ctx, publicClient, filter.ID)
if err != nil {
log.Fatal(err)
}
if success {
log.Println("Filter successfully uninstalled")
}

Returns

bool

A boolean indicating if the filter was successfully uninstalled.

Parameters

Configuration options accepted by this action.

FilterID

  • Type: FilterID
  • Required

The filter identifier to uninstall.

filter, err := public.CreatePendingTransactionFilter(ctx, publicClient)
if err != nil {
log.Fatal(err)
}
success, err := public.UninstallFilter(ctx, publicClient, filter.ID)

JSON-RPC Method

Underlying JSON-RPC method used by this action.

eth_uninstallFilter