signatureSubscribe

signatureSubscribe WebSocket Method

post

Subscribe to receive a notification when the transaction with the given signature reaches the specified commitment level. This is a subscription to a single notification that is automatically cancelled by the server once the signatureNotification is sent. Optionally, you can also receive notifications when the signature is first received by the RPC before processing begins. The transaction signature must be the first signature from the transaction.

Authorizations
Body

Request object for subscribing to signature notifications via WebSocket

jsonrpcstring Β· enumRequired

JSON-RPC protocol version

Example: 2.0Possible values:
idone ofRequired

Request identifier that will be returned in the response

Example: 1
stringOptional
or
numberOptional
methodstring Β· enumRequired

The WebSocket method name

Example: signatureSubscribePossible values:
Responses
101

WebSocket notification for signature status

application/json
post
const ws = new WebSocket('wss://public.rpc.solanavibestation.com');

ws.onopen = function() {
  // Subscribe to signature confirmation
  const signature = "2EBVM6cB8vAAD93Ktr6Vd8p67XPbQzCJX47MpReuiCXJAtcjaxpvWpcg9Ege1Nr5Tk3a2GFrByT7WPBjdsTycY9b";
  
  ws.send(JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'signatureSubscribe',
    params: [
      signature,
      {
        commitment: 'finalized',
        enableReceivedNotification: true
      }
    ]
  }));
};

ws.onmessage = function(event) {
  const data = JSON.parse(event.data);
  
  if (data.method === 'signatureNotification') {
    const { context, value } = data.params.result;
    const subscriptionId = data.params.subscription;
    
    if (value === 'receivedSignature') {
      console.log(`[Slot ${context.slot}] Transaction signature received`);
    } else if (value.err === null) {
      console.log(`[Slot ${context.slot}] Transaction confirmed successfully!`);
      console.log(`Subscription ${subscriptionId} automatically cancelled`);
    } else {
      console.log(`[Slot ${context.slot}] Transaction failed:`, value.err);
      console.log(`Subscription ${subscriptionId} automatically cancelled`);
    }
  } else if (data.result !== undefined) {
    console.log('Signature subscription ID:', data.result);
  }
};
{
  "jsonrpc": "2.0",
  "method": "signatureNotification",
  "params": {
    "result": {
      "context": {
        "slot": 5207624
      },
      "value": {
        "err": null
      }
    },
    "subscription": 24006
  }
}

Last updated