signatureSubscribe | Solana

The signatureSubscribe method in Solana allows developers to receive real-time notifications about the status of a transaction signature. This subscription-based method provides updates when a transaction's status changes.

Parameters

  • string - Transaction signature to monitor, as base-58 encoded string
  • <config> - (optional) Configuration object:
    • commitment - The level of commitment desired when querying state:
      • "processed" - Most recent block that has reached the node
      • "confirmed" - Block that has reached 1 confirmation by supermajority of the cluster
      • "finalized" - Block that has been finalized by supermajority of the cluster
    • enableReceivedNotification - (optional) Boolean to enable notifications when transaction is received by the node. Default: false

Response

  • result - An integer subscription id (needed to unsubscribe)
  • subscription - An object containing signature status:
    • err - Error if transaction failed, null if transaction succeeded
    • status - Transaction status:
      • "received" - Transaction received by node (if enableReceivedNotification is enabled)
      • "processed" - Transaction has been processed
      • "confirmed" - Transaction has been confirmed
      • "finalized" - Transaction has been finalized
    • confirmations - Number of blocks since transaction was processed (null if finalized)
    • confirmationStatus - The transaction's cluster confirmation status:
      • "processed" - Transaction landed in a block
      • "confirmed" - Transaction confirmed by supermajority
      • "finalized" - Transaction finalized by supermajority

signatureSubscribe code examples

This example subscribes to updates for a specific transaction signature.

📘

Note that subscriptions require a WebSocket connection and WebSocket cat for you to use this method in the console.

Install WebSocket cat with:

npm install -g wscat

$ wscat -c YOUR_CHAINSTACK_WEBSOCKET_ENDPOINT
# Wait for the connection to be established

Connected (press CTRL+C to quit)

> {"jsonrpc":"2.0","id":1,"method":"signatureSubscribe","params":["51y7FDe6Up5o2PfwkPiDVJz35NREmPjQsJXy9tqvdZyYqiFNG2JzMUjUJ6oZpVZFGBHBZtXQzVqyKPwzWktF6s24",{"commitment":"finalized","enableReceivedNotification":true}]}

Use case

The signatureSubscribe method is essential for applications that need to track transaction status. Common use cases include:

  • Transaction monitoring: Track the status of sent transactions in real-time
  • Payment processing: Monitor payment transactions for confirmation and finality
  • User experience: Provide immediate feedback to users about their transaction status
  • Error handling: Detect and respond to failed transactions quickly
  • Confirmation tracking: Track the number of confirmations for critical transactions

By subscribing to signature updates, applications can provide real-time transaction status updates and implement robust error handling for failed transactions.