Skip to content
Alchemy Logo

signatureSubscribe

Subscribe to status notifications for one Solana transaction signature.

The signatureSubscribe method opens a stream that emits a single notification when a given transaction signature reaches the requested commitment level (or when transaction status changes if enableReceivedNotification is set). After the notification fires, the subscription is automatically cancelled. Pair it with signatureUnsubscribe to cancel a subscription before it fires.

  • signature: string - Transaction signature, as a base-58 encoded string.

  • config (optional): object - Configuration object containing:

    • commitment: string - The commitment level. One of processed, confirmed, finalized. Defaults to finalized.
    • enableReceivedNotification: boolean (optional) - When true, the subscription also fires a notification when the transaction has been received by the node, before reaching the requested commitment.

// initiate websocket stream first
wscat -c wss://solana-mainnet.g.alchemy.com/v2/<-- ALCHEMY APP API KEY -->
 
// then call subscription
{"jsonrpc":"2.0","id":1,"method":"signatureSubscribe","params":["2EBVM6cB8vAAD93Ktr6Vd8p67XPbQzCJX47MpReuiCXJAtcjaxpvWpcg9Ege1Nr5Tk3a2GFrByT7WPBjdsTycY9b",{"commitment":"finalized","enableReceivedNotification":false}]}

// subscribe response
{"jsonrpc":"2.0","result":24006,"id":1}
 
// notification (commitment reached)
{
  "jsonrpc": "2.0",
  "method": "signatureNotification",
  "params": {
    "result": {
      "context": { "slot": 5207624 },
      "value": { "err": null }
    },
    "subscription": 24006
  }
}

Use signatureUnsubscribe with the subscription id returned by signatureSubscribe to cancel a pending subscription. (After the notification has already fired, the subscription is removed automatically.)

  • subscription_id: number - The subscription id to cancel.
{"jsonrpc":"2.0","id":1,"method":"signatureUnsubscribe","params":[subscription_id]}
{"jsonrpc":"2.0","result":true,"id":1}

When using @solana/web3.js, call connection.removeSignatureListener(subscriptionId) instead of sending the raw JSON-RPC request.

Was this page helpful?