Introducing a new way to review your PRs.

Read the announcement

solana-foundation / solana-go

Go SDK library and RPC client for the Solana Blockchain

View on GitHub

26 documents · Updated Nov 16, 2026

docs / transaction-confirmation

Transaction confirmation strategies

The confirmation package waits for a submitted Solana transaction to reach a requested commitment or to reach the end of its valid lifetime. It gives callers a clear result for success, on-chain failure, expiry, nonce change, timeout, and canceled work. See transaction lifecycle for the place of confirmation in the wider send flow.

Confirmation model

Confirmation joins two facts: whether the signature reached the requested commitment and whether the transaction can still land. A recent-blockhash transaction ends when its last valid block height passes. A durable-nonce transaction ends when its nonce account changes. The waiters race these facts so that a lifetime event does not leave the caller waiting forever.

The package accepts processed, confirmed, and finalized commitments. An empty commitment means finalized. A transaction error is reported as soon as the chain reports that the transaction landed and failed, even when the caller requested a higher commitment.

The main outcomes are:

OutcomeMeaning
nilThe signature reached the requested commitment.
*TransactionErrorThe transaction landed but failed. The value keeps the signature and the RPC error.
*BlockHeightExceededErrorA recent blockhash passed its last valid block height before confirmation won.
*InvalidNonceErrorThe nonce account holds a different nonce than the transaction.
*NonceAccountNotFoundErrorThe nonce account cannot be found.
ErrTimeoutThe caller used a time limit and it elapsed before confirmation. The transaction may still land.
context.Canceled or context.DeadlineExceededThe caller stopped the wait.

Confirmation waiters

The waiters select a lifetime strategy that matches how the transaction stays valid. They validate the transaction identity and strategy inputs before they start, then return the first meaningful result from the signature path or the lifetime path.

WaiterSignature pathLifetime pathBest fit
WaitForRecentTransactionConfirmationFee-payer signatureLast valid block heightTransactions that use a recent blockhash
WaitForDurableNonceTransactionConfirmationFee-payer signatureNonce account stateTransactions that use a durable nonce
WaitForRecentTransactionConfirmationUntilTimeoutSupplied signatureCaller-selected timeoutTransactions whose lifetime is not known, such as an airdrop

The recent-blockhash waiter can report expiry at the next block height even though the transaction may still land in that block. The durable-nonce waiter can report a changed nonce even though a failed transaction may have advanced the nonce. In both cases, the caller should check signature status before signing again with a new lifetime; the send-and-confirm helpers provide that follow-up behavior. See transaction submission for how submission connects to these waiters.

Recent blockhash lifetime

The recent blockhash strategy watches slot progress and uses epoch information to estimate block height. When the estimate passes the transaction's last valid block height, it checks the current block height again before it reports expiry. This avoids treating skipped slots as proof that the transaction lifetime ended.

The resulting BlockHeightExceededError includes the observed block height, the last valid block height, and the slot used for the decision. A later signature-status check is conclusive only when it reads a bank at least as recent as that slot.

References: confirmation/strategy_blockheight.go• L25-43 confirmation/strategy_blockheight.go• L117-144 confirmation/errors.go• L61-82

Durable nonce lifetime

The durable nonce strategy watches the nonce account and reads its current value after the watch is ready. It ends when the account holds a value different from the transaction's nonce or when the account is missing. Until then, the transaction remains valid from this strategy's point of view.

An invalid nonce does not prove that the submitted transaction failed. A failed durable-nonce transaction still advances the nonce. The caller must use the signature result, with the error's slot details when needed, to tell that case from another transaction using the nonce.

References: confirmation/strategy_nonce.go• L27-55 confirmation/strategy_nonce.go• L69-141 confirmation/errors.go• L84-125

Unknown transaction lifetime

The timeout strategy provides a bounded wait when the system does not expose a usable transaction lifetime. It waits 30 seconds for processed and 60 seconds for the other supported commitments. A timeout is only a report about the wait. It does not prove that the transaction cannot land.

References: confirmation/strategy_timeout.go• L25-40 confirmation/strategy_timeout.go• L41-60

Signature confirmation

The signature strategy is the common success and failure path for all three waiters. It watches the signature over WebSocket and checks its current status over RPC after the watch is ready. Either path can provide the answer, while an unseen or not-yet-sufficient status keeps the strategy waiting.

The strategy returns success when the observed confirmation status is at least the requested commitment. It returns TransactionError when the status or notification contains an execution error. A status lookup only sees the server's recent signature cache, so the live subscription is needed to cover a transaction that is not in that cache.

References: confirmation/strategy_signature.go• L26-46 confirmation/strategy_signature.go• L59-109

Strategy races

The race coordinator starts signature confirmation and the matching lifetime strategy together. The first result ends the public wait, then cancellation stops the other strategy and the coordinator waits for it to finish. If the lifetime result arrives first while a signature result is already ready, the signature result wins.

This ordering limits false expiry and nonce outcomes without hiding real lifetime errors. A canceled context is returned as the context error rather than as a WebSocket subscription-close error or a wrapped RPC cancellation error.

The flow is:

flowchart LR
    A[Submitted transaction] --> B[Signature confirmation]
    A --> C[Lifetime strategy]
    B --> D{First meaningful result}
    C --> D
    D --> E[Cancel other strategy]
    E --> F[Return success or typed error]

References: confirmation/racer.go• L22-77 confirmation/commitment.go• L38-56 confirmation/waiters.go• L78-182

Commitment outcomes

Commitment controls how recent a bank state must be before the package treats the transaction or lifetime event as known. The package normalizes an empty value to finalized and rejects any unsupported value before it opens a subscription or makes an RPC call.

The commitment applies to both sides of a lifetime race. For example, block-height observation and signature confirmation use the same requested level. This keeps a success result and an expiry result tied to one view of chain state.

References: confirmation/commitment.go• L24-35 confirmation/strategy_signature.go• L39-46 confirmation/strategy_blockheight.go• L36-43 confirmation/strategy_nonce.go• L48-55

Error handling

Confirmation errors support errors.Is for broad outcome checks and errors.As for details. The typed errors preserve the data needed for a follow-up status check or for a caller's retry decision.

CheckUse
errors.Is(err, ErrBlockHeightExceeded)The recent blockhash lifetime ended.
errors.Is(err, ErrInvalidNonce)The nonce changed.
errors.Is(err, ErrNonceAccountNotFound)The nonce account is gone.
errors.Is(err, ErrTransactionFailed)The transaction landed and failed.
errors.Is(err, ErrTimeout)A time-only wait ended.
errors.As(err, &typedError)Read signature, slot, nonce, block-height, or RPC failure details.

Missing fee-payer signatures prevent the signature wait from starting. A durable-nonce waiter also rejects a transaction that does not use an AdvanceNonceAccount instruction. A caller-supplied context takes precedence when cancellation races with another strategy result.

References: confirmation/errors.go• L25-59 confirmation/errors.go• L61-145 confirmation/waiters.go• L93-104 confirmation/waiters.go• L130-145 confirmation/waiters.go• L164-182

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep each waiter paired with the lifetime rule of the transaction type it accepts.
  • Keep commitment normalization aligned across signature, block-height, nonce, and timeout strategies.
  • Preserve the race rule that gives a ready signature result precedence over a simultaneous lifetime result.
  • Preserve typed error unwrapping and the slot or block-height data used by follow-up status checks.
  • Keep cancellation distinct from WebSocket closure and RPC errors at the public waiter boundary.

Important failure modes

TriggerConsequenceGuard
A recent blockhash expires before the signature result winsThe waiter returns BlockHeightExceededError; the transaction can still land in the expiry blockCheck signature status before retrying with a new blockhash
A durable nonce advances because a submitted transaction failedThe waiter can return InvalidNonceError even though the transaction landedCheck the signature status after nonce invalidation
The signature is no longer in the RPC status cacheThe one-time status read cannot decide the resultKeep the WebSocket signature watch active
A timeout ends before confirmationThe waiter returns ErrTimeout, but the transaction may later landUse a lifetime-based waiter when blockhash or nonce data is available
The caller cancels while a subscription is stoppingThe public result is delayed until the subscription cleanup endsTreat the returned context error as cancellation and account for WebSocket cleanup delay

Key files

FileWhy to read it
confirmation/waiters.goDefines the public waiter choices and their success and error contracts.
confirmation/strategy_signature.goShows how signature success and on-chain failure become confirmation outcomes.
confirmation/strategy_blockheight.goShows the recent-blockhash lifetime boundary and expiry evidence.
confirmation/strategy_nonce.goShows the durable-nonce lifetime boundary and its ambiguity after failure.
confirmation/strategy_timeout.goDefines the fallback for transactions with unknown lifetime.
confirmation/racer.goDefines how confirmation and lifetime results compete and stop each other.
confirmation/commitment.goDefines supported commitment values and cancellation reporting.
confirmation/errors.goDefines the typed outcomes and the details available to callers.