Sending, confirmation, and expiry
Transaction submission turns a signed transaction into a network request and returns its signature. Confirmation then tracks that signature until the requested commitment is reached or the transaction can no longer be valid. This page covers the shared flow behind signed and raw transactions, including blockheight-based and durable-nonce expiry. See Transactions for the wider transaction model, Legacy and versioned transactions for transaction format differences, RPC connection operations for related RPC calls, and Network and protocol utilities for related network rules.
Transaction submission
The submission path has two stages: prepare the transaction for the RPC connection, then send its serialized bytes to the JSON-RPC service. The connection performs preflight checks unless the caller disables them and returns the transaction signature when the RPC service accepts the request.
Signed transaction submission
sendAndConfirmTransaction in packages/…/send-and-confirm-transaction.ts accepts a legacy Transaction and partial signers. The helper asks the connection to send the transaction, then confirms the returned signature with the validity data carried by the transaction.
For a blockhash-based transaction, the transaction carries the blockhash and its lastValidBlockHeight. For a durable-nonce transaction, it carries the nonce account instruction and nonce value instead. These two forms give confirmation enough information to tell normal processing apart from expiry.
Before sending a durable-nonce transaction, the helper checks that its nonce instruction is a valid advance-nonce instruction. An invalid instruction stops submission with an error because the helper cannot identify the nonce account needed for expiry-aware confirmation.
References: packages/…/send-and-confirm-transaction.ts• L24-61 packages/…/send-and-confirm-transaction.ts• L63-102
Raw transaction submission
sendAndConfirmRawTransaction in packages/…/send-and-confirm-raw-transaction.ts accepts bytes that are already signed. It sends those bytes through the RPC connection, which encodes them for the RPC request. Because the helper cannot inspect an unsigned transaction object, the caller supplies a confirmation strategy when using the current API.
The strategy must describe either the blockhash and its last valid block height or the durable nonce account and nonce value. The overload that omits a strategy uses the older timeout-based confirmation path and is deprecated. Send options are mapped to preflight and context settings before submission. The helper then checks the returned status and raises SendTransactionError when the status contains an error.
References: packages/…/send-and-confirm-raw-transaction.ts• L25-30 packages/…/send-and-confirm-raw-transaction.ts• L37-100
Confirmation model
Confirmation answers a stronger question than submission. A successful send means that the RPC service accepted the request; confirmation means that the cluster reported the signature at the requested commitment without a transaction error.
Confirmation strategies
confirmTransaction accepts a signature alone for the legacy timeout path or a TransactionConfirmationStrategy for expiry-aware confirmation. The strategy carries the signature plus the data needed to identify when the transaction stops being valid.
| Strategy | Validity signal | Best use |
|---|---|---|
| Blockheight based | The current block height passes lastValidBlockHeight | Recent-blockhash transactions |
| Durable nonce | The nonce account no longer holds the signed nonceValue | Transactions signed with a durable nonce |
| Legacy signature-only | A fixed confirmation timeout | Older callers that do not provide expiry data |
The signed helper chooses the durable-nonce strategy when the transaction has nonce information. Otherwise, it chooses the blockheight strategy when the transaction has a recent blockhash and last valid block height. If neither set of data is available, it uses the deprecated signature-only path. An abort signal applies to the first two strategies. With the signature-only path, the helper warns that cancellation is not supported.
References: packages/…/send-and-confirm-transaction.ts• L44-102
Commitment levels
A commitment is the minimum cluster state at which confirmation may complete. The RPC connection applies the requested commitment to both the signature subscription and status checks, so a transaction is not reported as confirmed before that level is met.
| Commitment | Meaning |
|---|---|
processed | The connected node has processed the block |
confirmed | The cluster has confirmed the block |
finalized | The cluster has finalized the block |
The older names recent, single, singleGossip, root, and max remain accepted for compatibility. New code should use the current three levels. A helper passes options.commitment to confirmation, while preflight uses preflightCommitment or the requested commitment when the caller does not set a separate preflight level. Skipping preflight sends the request with the connection's compatibility preflight setting.
References: packages/…/send-and-confirm-transaction.ts• L34-42 packages/…/send-and-confirm-raw-transaction.ts• L73-90
Confirmation lifecycle
The connection combines a signature subscription with status polling and races that work against the relevant expiry condition. This diagram shows the high-level path from submission to a result or a failure.
flowchart LR
A[Signed or raw transaction] --> B[Send through RPC connection]
B --> C[Transaction signature]
C --> D[Watch signature at requested commitment]
D --> E{Confirmed without error?}
E -->|Yes| F[Return signature]
E -->|No| G[Return transaction error]
D --> H{Validity limit reached?}
H -->|Block height| I[Blockheight expiry error]
H -->|Nonce changed| J[Durable nonce expiry check]
J --> K{Status meets commitment?}
K -->|Yes| F
K -->|No| L[Nonce invalid error]
D --> M[Abort signal]
M --> N[Reject confirmation]
The connection removes its signature subscription when confirmation finishes, expires, or is canceled. An abort signal is supported by the expiry-aware strategies and by the signed helper. It is not supported by the deprecated signature-only path.
References: packages/…/send-and-confirm-transaction.ts• L24-32 packages/…/send-and-confirm-transaction.ts• L63-102
Transaction expiry
Expiry protects callers from waiting forever for a transaction that can no longer execute with its signed validity data. The connection monitors the validity signal that belongs to the transaction instead of treating a missing status as proof of failure.
Blockheight expiry
A recent blockhash is valid only through its associated lastValidBlockHeight. During confirmation, the connection checks block height while it waits for the signature at the requested commitment. If the block height moves past that limit first, it throws TransactionExpiredBlockheightExceededError with the signature.
This error means the transaction missed its blockhash window. It does not mean that the transaction executed and failed; callers can use the signature and surrounding application state when they need to decide whether to retry.
References: packages/…/send-and-confirm-transaction.ts• L78-92 src/…/expiry-custom-errors.ts• L1-16
Durable nonce expiry
A durable-nonce transaction uses a nonce value stored in a nonce account instead of a short-lived recent blockhash. Confirmation reads that account from at least minContextSlot and compares its current value with the value used to sign the transaction.
When the nonce changes before the signature reaches the requested commitment, the connection performs a status check at or after the slot where the nonce advanced. If the transaction did not reach the required commitment, it throws TransactionExpiredNonceInvalidError. This extra status check prevents a nonce advance from being reported as failure when the transaction was already confirmed.
References: packages/…/send-and-confirm-transaction.ts• L44-77 src/…/expiry-custom-errors.ts• L37-48
Legacy timeout expiry
Signature-only confirmation has no blockhash or nonce data with which to determine validity. It therefore waits for a time limit based on the requested commitment and throws TransactionExpiredTimeoutError when the limit passes.
Timeout is an unknown-result state. The transaction may have succeeded or failed, so callers must check the signature before they retry. Prefer an expiry-aware strategy for new code.
References: packages/…/send-and-confirm-transaction.ts• L93-102 src/…/expiry-custom-errors.ts• L18-35
Transaction errors
The send-and-confirm helpers turn a confirmed status with err into SendTransactionError. The same error also represents an RPC send or preflight failure, so callers should use its action and transaction details to distinguish a request that was rejected before submission from a transaction that reached the cluster and failed.
Submission and execution errors
When preflight is enabled, the RPC service may reject the transaction during simulation. When preflight is skipped, the service may reject it during send. If the transaction is accepted but later reports an execution error, the helper still throws SendTransactionError after confirmation.
SendTransactionError exposes the transaction message and available logs through transactionError. Its asynchronous getLogs(connection) method can fetch full log messages after the error when the initial RPC response did not include them.
References: packages/…/send-and-confirm-transaction.ts• L104-117 packages/…/send-and-confirm-raw-transaction.ts• L91-107 src/errors.ts• L4-91
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the confirmation strategy types aligned with the data carried by
Transaction, the raw-transaction helper, and the confirmation API. - Preserve the distinction between preflight commitment and final confirmation commitment when changing send option handling.
- Keep nonce confirmation's minimum context slot tied to the slot at which the nonce value was read. A weaker slot can produce a stale nonce result.
- Preserve the post-nonce-advance status check. Removing it can turn an already-confirmed transaction into a false expiry failure.
- Keep expiry error names and signatures stable for callers that branch on error type or use the signature to inspect an unknown result.
- Keep durable-nonce instruction validation aligned with the instruction decoder. A change can block valid sends or allow confirmation without a usable nonce account.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
A recent-blockhash transaction reaches a block height greater than lastValidBlockHeight before confirmation | TransactionExpiredBlockheightExceededError is thrown | Supply fresh blockhash expiry data and decide whether a retry is safe for the application operation |
| A durable nonce changes before the transaction reaches the requested commitment | TransactionExpiredNonceInvalidError is thrown after the status check | Use the nonce account, signed nonce value, and minContextSlot that belong to the same signing attempt |
| Signature-only confirmation reaches its time limit | TransactionExpiredTimeoutError is thrown while the result remains unknown | Query the signature before retrying; use an expiry-aware strategy for new submissions |
| A durable-nonce transaction does not contain a valid advance-nonce instruction | Submission stops before the RPC request with a validation error | Build nonceInfo from a valid advance-nonce instruction and its matching nonce value |
| Preflight or send RPC rejects the transaction | SendTransactionError is thrown before normal confirmation | Inspect transactionError and call getLogs(connection) when logs are needed |
A transaction reaches the cluster but its status contains err | The helper throws SendTransactionError instead of returning the signature | Treat submission acceptance and successful execution as separate outcomes |
Key files
| File | Why to read it |
|---|---|
| packages/…/send-and-confirm-transaction.ts | Shows the main signed-transaction helper and how it validates nonce data and selects confirmation data. |
| packages/…/send-and-confirm-raw-transaction.ts | Shows the raw signed-byte helper and the current versus deprecated call shapes. |
| src/…/expiry-custom-errors.ts | Defines the public errors for blockheight expiry, nonce invalidation, and timeout. |
| src/errors.ts | Defines send and execution error details and log retrieval. |
| src/…/index.ts | Re-exports the expiry errors as part of the transaction API. |