signatureSubscribe
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.
Request object for subscribing to signature notifications via WebSocket
JSON-RPC protocol version
2.0
Possible values: Request identifier that will be returned in the response
1
The WebSocket method name
signatureSubscribe
Possible values: WebSocket notification for signature status
Subscription successfully created
Bad Request - Invalid parameters
Unauthorized
Forbidden
Too Many Requests
Internal Server Error
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