Transaction submission and confirmation
Transaction submission turns a constructed and signed transaction into a cluster result. The RPC client can first simulate the transaction, encode it for the JSON-RPC request, submit it, and then track the returned signature until the cluster reports success or failure. This page complements the RPC client, JSON-RPC transport, and WebSocket subscriptions pages.
Transaction lifecycle
The transaction lifecycle joins local transaction work with two kinds of remote feedback. A transaction carries its message and signatures; the first signature identifies it after submission. The client uses that identifier to distinguish acceptance by an RPC node from later processing by the cluster.
The normal lifecycle is:
- Obtain a recent blockhash and use it to construct the transaction.
- Sign every required signer position.
- Optionally simulate the signed transaction to inspect execution before submission.
- Submit the serialized transaction through
sendTransaction. - Track the returned signature until the required commitment level is reached.
- Treat a non-null execution error as a failed transaction even when the cluster confirms it.
The transaction's recent blockhash limits how long the cluster can accept it. A submission response only means that the RPC service accepted the request. It does not mean that the transaction reached the cluster or completed.
References: transaction.go• L185-227 transaction.go• L524-548 rpc/sendTransaction.go• L27-68 rpc/getLatestBlockhash.go• L25-80
Transaction simulation
Simulation evaluates a transaction against a bank state without submitting it for execution on the cluster. It is useful for checking instruction behavior, logs, fees, compute use, account changes, and return data before a real send.
SimulateTransaction accepts a transaction object and sends its binary form as base64. Its options control signature checks, commitment, recent-blockhash replacement, inner-instruction output, minimum context slot, and selected account output. The default path uses finalized commitment and does not verify signatures, while a caller can enable checks when it needs a closer preflight result.
Simulation reports execution details in SimulateTransactionResult:
| Result | Meaning |
|---|---|
Err | The simulation failed or an instruction returned an error. |
Logs | Messages emitted while the instructions ran. |
UnitsConsumed | Compute budget used by the simulated transaction. |
Fee | Fee charged by the simulated execution. |
PreBalances and PostBalances | Balance changes caused by the simulation. |
ReturnData | The latest return data produced by an instruction. |
Simulation does not replace signing and confirmation. A simulation can use a replacement blockhash or skip signature checks, while a live submission must use a valid transaction accepted by the cluster.
References: rpc/simulateTransaction.go• L27-75 rpc/simulateTransaction.go• L83-143 rpc/simulateTransaction.go• L146-193 rpc/…/simulateTransaction.go• L27-80
Transaction encoding and submission
Submission accepts the same signed transaction in three input forms. All forms converge on the JSON-RPC sendTransaction request, which returns the transaction signature used for later tracking.
| Input form | Entry point | Conversion before the RPC call |
|---|---|---|
| Transaction object | SendTransactionWithOpts | Binary transaction data is encoded as base64. |
| Raw bytes | SendRawTransactionWithOpts | Bytes are encoded as base64. |
| Base64 text | SendEncodedTransactionWithOpts | Text is sent as supplied. |
The submission options carry the wire encoding, preflight behavior, preflight commitment, retry limit, and minimum context slot. By default, preflight is enabled and the request uses base64 encoding. Preflight checks signatures and simulates the transaction unless the caller sets SkipPreflight.
The client returns the first transaction signature as soon as the RPC service accepts the request. Use the returned signature for status checks; do not interpret the return from SendTransaction as confirmation.
References: rpc/sendTransaction.go• L69-84 rpc/sendRawTransaction.go• L26-54 rpc/sendEncodedTransaction.go• L25-56 rpc/types.go• L610-642 transaction.go• L642-655
Signature status polling
Signature status polling asks the RPC node whether a submitted transaction has reached a chosen cluster state. GetSignatureStatuses accepts one or more signatures and returns a matching status for each signature, so callers can poll after submission when they do not use a WebSocket subscription.
Each status has three important parts:
| Field | Use |
|---|---|
ConfirmationStatus | Shows processed, confirmed, or finalized. |
Err | Shows whether transaction execution failed. A null value means success. |
Slot and Confirmations | Locate processing and show progress when the status is not rooted. |
The default lookup searches the recent status cache. Set searchTransactionHistory when a signature is not in that cache and a ledger search is needed. A missing result is exposed as ErrNotFound, so a caller must distinguish “not known yet” from a status that reports execution failure.
Commitment is the required confidence level for the caller. processed is the node's latest view, confirmed has supermajority voting support, and finalized has reached the cluster's final state. The required level should match the business effect that depends on the transaction.
References: rpc/getSignatureStatuses.go• L23-51 rpc/getSignatureStatuses.go• L54-83 rpc/types.go• L509-525
Send-and-confirm flow
The send-and-confirm helper combines RPC submission with WebSocket signature confirmation. It sends the transaction with preflight enabled and finalized preflight commitment, then subscribes to the returned signature at finalized commitment and waits for the terminal notification.
The flow is:
sequenceDiagram
participant App as Application
participant RPC as RPC client
participant Cluster as Cluster
participant WS as WebSocket client
App->>RPC: SendTransactionWithOpts(transaction)
RPC->>Cluster: sendTransaction
Cluster-->>RPC: transaction signature
RPC-->>App: signature
App->>WS: SignatureSubscribe(signature, finalized)
WS-->>App: terminal signature notification
App->>App: inspect notification error
App-->>App: success, execution failure, or timeout
SendAndConfirmTransaction uses a default two-minute wait. The timeout variant lets the caller choose a duration, while the options variant lets the caller control transaction submission options and the timeout. The helper unsubscribes after it receives the terminal notification or after the wait ends.
The helper returns a successful outcome only when the finalized notification has no execution error. A finalized transaction with an instruction error returns confirmed == true together with an error. A context cancellation, subscription error, or timeout returns confirmed == false; timeout is exposed as ErrTimeout.
The WebSocket path is an event-driven alternative to repeated GetSignatureStatuses calls. Use the status method when polling fits the surrounding control flow or when a WebSocket connection is not available.
References: rpc/…/sendAndConfirmTransaction.go• L27-136 rpc/…/signatureSubscribe.go• L33-53 rpc/…/signatureSubscribe.go• L108-196
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the accepted transaction input forms aligned with the base64 wire format used by
sendTransaction. - Keep the meaning of a submission response separate from the confirmation contract. A returned signature is not a completed transaction.
- Keep commitment values consistent between preflight, status polling, and WebSocket confirmation when callers expect one level of assurance.
- Preserve the distinction between an unknown signature, a transport or subscription error, a timeout, and a confirmed transaction with an execution error.
- If the signature notification shape changes, update both the WebSocket result contract and the send-and-confirm interpretation of
Value.Err.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The transaction uses an expired recent blockhash before it lands. | The RPC node can accept the request but the cluster can reject the transaction. | Build and submit with a current blockhash, then track the returned signature. |
| Preflight simulation or signature checks fail. | sendTransaction returns an error and no usable submission result exists. | Inspect the simulation result and sign every required signer before sending. |
| The status cache no longer contains the signature. | A normal status lookup reports no known transaction. | Use searchTransactionHistory when the application must search the ledger. |
A confirmed or finalized notification contains a non-null Err. | The transaction reached the requested cluster state but its instructions failed. | Check Err after confirmation instead of checking only the commitment level. |
| The WebSocket does not deliver a terminal notification before the deadline. | The helper returns ErrTimeout without claiming confirmation. | Set a suitable timeout and use status polling when the subscription path is not reliable. |
Key files
| File | Why to read it |
|---|---|
| transaction.go | Shows how a constructed transaction becomes signed binary data and how its first signature identifies it. |
| rpc/simulateTransaction.go | Defines the pre-send simulation boundary and the execution data returned to callers. |
| rpc/sendTransaction.go | Defines object-based submission and explains why submission is not confirmation. |
| rpc/sendEncodedTransaction.go | Shows the common JSON-RPC submission request for already encoded transactions. |
| rpc/getSignatureStatuses.go | Defines the polling result and the three cluster confirmation levels. |
| rpc/…/sendAndConfirmTransaction.go | Connects submission to finalized WebSocket confirmation and outcome handling. |
| rpc/…/signatureSubscribe.go | Defines the signature notification used by the send-and-confirm flow. |
| rpc/…/sendTransaction.go | Demonstrates the broad build, sign, blockhash, and submit path with a live RPC client. |