Skip to main content

signatureUnsubscribe

The Solana signatureUnsubscribe method cancels a signature subscription created by signatureSubscribe so that transaction signature notifications are no longer received.

Usage Notes
  • Must be called via a WebSocket endpoint; HTTP is not supported.
  • After unsubscribing, the subscription cannot be re-established using the same subscription ID. If a new subscription is needed, call signatureSubscribe again.
  • If the WebSocket connection is closed, subscriptions are automatically cancelled, so subscriptions must be re-established upon reconnection.
  • signatureSubscribe is a single-notification subscription, so the subscription is automatically cancelled after a notification is received.

1. Request

Parameters

The signature unsubscribe request has the following parameters.

ParameterTypeRequiredDescription
idinteger or stringrequiredUnique identifier for the request. Used by the client to match requests with responses.
jsonrpcstringrequiredJSON-RPC protocol version. Always set to "2.0".
methodstringrequiredName of the method to execute. Enter "signatureUnsubscribe" here.
paramsarrayrequiredAn array containing the subscription ID of the subscription to cancel.

Example

{
"jsonrpc": "2.0",
"id": 1,
"method": "signatureUnsubscribe",
"params": [24006]
}

2. Response

Success Response

When the subscription is successfully cancelled, true is returned.

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

Error Response

If the unsubscribe fails, an error is returned.

{
"jsonrpc": "2.0",
"error": {
"code": -32000,
"message": "Invalid subscription ID"
},
"id": 1
}

3. How to Use

Connect to WebSocket Channel

wscat -c wss://api.mainnet-beta.solana.com

Subscribe to Signature (First)

{
"jsonrpc": "2.0",
"id": 1,
"method": "signatureSubscribe",
"params": [
"2EBVM6cB8vAAD93Ktr6Vd8p67XPbQzCJX47MpReuiCXJAtcjaxpvWpcg9Ege1Nr5Tk3a2GFrByT7WPBjdsTycY9b",
{
"commitment": "finalized",
"enableReceivedNotification": false
}
]
}

Receive Subscription ID

{
"jsonrpc": "2.0",
"result": 24006,
"id": 1
}

Unsubscribe

There are two ways to unsubscribe:

  1. Close the connection: Press Ctrl+C in the terminal window to terminate the WebSocket connection, which automatically cancels all subscriptions.

  2. Cancel a specific subscription: Use signatureUnsubscribe to cancel only a specific subscription while keeping the connection open.

{
"jsonrpc": "2.0",
"id": 2,
"method": "signatureUnsubscribe",
"params": [24006]
}

Confirm Unsubscribe

{
"jsonrpc": "2.0",
"result": true,
"id": 2
}