eth_unsubscribe

Unsubscribe from different Ethereum event types with a regular RPC call with eth_unsubscribe as the method and the subscriptionId as the first parameter.

Don’t have an API key?

Start using this API in your app today.

Parameters

  1. Subscription ID, as previously returned from an eth_subscribe call.

Returns

true if a subscription was successfully canceled, or false if no subscription existed with the given ID.

Example

Request

wscat -c wss://eth-mainnet.g.alchemy.com/v2/<key>

{"jsonrpc":"2.0", "id": 1, "method": "eth_unsubscribe", "params": ["0x9cef478923ff08bf67fde6c64013158d"]}
// npm install alchemy-sdk
import { Alchemy, Network } from "alchemy-sdk";

const settings = {
  apiKey: "demo", // Replace with your Alchemy API Key.
  network: Network.ETH_MAINNET, // Replace with your network.
};
const alchemy = new Alchemy(settings);

alchemy.ws.removeAllListeners();

Result

{
    "jsonrpc":"2.0",
    "id":1,
    "result":true
}
ReadMe