# Confirmation and retries

> Check execution and commitment through your Solana RPC before deciding whether to resubmit

<span id="acceptance" />

## What acceptance means

A successful submission acknowledges only acceptance for delivery:

| Submission | Acknowledgment means |
| --- | --- |
| Hosted single transaction | SWQoS accepted the transaction for delivery |
| Hosted bundle | SWQoS accepted the bundle for delivery |
| QUIC unidirectional stream | No acknowledgment exists |

None of these proves the signature is valid, the transaction can execute, an engine accepted it, or it landed. A submitted transaction can land successfully, land with an execution error, expire, or belong to a fork your chosen commitment does not retain.

## Routing

See [Routing](https://supanode.xyz/docs/solana/sender/routing) for leader delivery and block engine delivery. Bundles use block engines only. A response does not identify which path was used or which copy will land.

<span id="no-resend" />

## No periodic resubmission

SWQoS does not periodically resend accepted transactions or bundles. `maxRetries` is ignored. Your application owns confirmation and later resubmission.

<span id="duplicates" />

### Duplicate suppression

A recently repeated single transaction signature may be accepted without being sent again.
A repeat that arrives while the first is still being processed returns `rate_limited` without `per_second` or `retry_after_ms`.

Do not rely on this as global idempotency. Explicit bundle resubmissions are not suppressed, even though they return the same bundle id.

<span id="confirmation" />

## Confirm through your Solana RPC

Keep the first signature of each signed transaction before you send. Poll `getSignatureStatuses`, or subscribe to signature notifications, on your read RPC provider. Check both the execution error and the commitment. `getSlot` on SWQoS is not a confirmation check.

For a transaction using a recent blockhash, retain the `lastValidBlockHeight` returned with the blockhash used to sign it. If the chain passes that height and no landing is recorded, the transaction cannot newly execute with that blockhash. Rebuild and sign with a fresh blockhash only after checking the original outcome. A durable nonce has a different lifetime: check the nonce account and original signature before advancing or replacing it.

For a bundle, check every customer signature. SWQoS has no bundle status API, and its bundle id is not an engine's status id. Do not assume that seeing one member on chain proves which submission path delivered it if you sent members separately.

<Tabs>

<Tab title="Rust">

```rust title="src/confirm.rs" tab="Rust" tab-group="language"
use std::time::Duration;

use serde::Deserialize;
use serde_json::{Value, json};
use solana_signature::Signature;

use crate::swqos::{Result, request};

#[derive(Deserialize)]
struct Statuses {
    value: Vec<Option<Status>>,
}

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct Status {
    err: Option<Value>,
    confirmation_status: Option<String>,
}

pub async fn wait_for_confirmation(
    rpc_url: &str,
    signature: &Signature,
    last_valid_block_height: u64,
) -> Result<()> {
    loop {
        let statuses: Statuses = request(
            rpc_url,
            None,
            "getSignatureStatuses",
            Some(
                json!([[signature.to_string()], { "searchTransactionHistory": true }]),
            ),
        )
        .await?;
        let status = statuses.value.first().and_then(Option::as_ref);
        if let Some(error) = status.and_then(|status| status.err.as_ref()) {
            return Err(format!("transaction failed: {error}").into());
        }
        if matches!(
            status.and_then(|status| status.confirmation_status.as_deref()),
            Some("confirmed" | "finalized")
        ) {
            return Ok(());
        }
        let height: u64 = request(
            rpc_url,
            None,
            "getBlockHeight",
            Some(json!([{ "commitment": "confirmed" }])),
        )
        .await?;
        if status.is_none() && height > last_valid_block_height {
            return Err("blockhash expired with no recorded landing".into());
        }
        tokio::time::sleep(Duration::from_millis(500)).await;
    }
}
```

</Tab>

<Tab title="Go">

```go title="confirm.go" tab="Go" tab-group="language"
package swqos

import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"time"

	"github.com/gagliardetto/solana-go"
)

type confirmationStatus struct {
	Err                json.RawMessage `json:"err"`
	ConfirmationStatus string          `json:"confirmationStatus"`
}

func WaitForConfirmation(ctx context.Context, rpcURL string, signature solana.Signature, lastValidBlockHeight uint64) error {
	for {
		reply, err := callAt[struct {
			Value []*confirmationStatus `json:"value"`
		}](ctx, rpcURL, "", "getSignatureStatuses", []solana.Signature{signature},
			map[string]any{"searchTransactionHistory": true})
		if err != nil {
			return err
		}
		var status *confirmationStatus
		if len(reply.Value) > 0 {
			status = reply.Value[0]
		}
		if status != nil {
			if len(status.Err) > 0 && string(status.Err) != "null" {
				return fmt.Errorf("transaction failed: %s", status.Err)
			}
			if status.ConfirmationStatus == "confirmed" || status.ConfirmationStatus == "finalized" {
				return nil
			}
		}
		height, err := callAt[uint64](ctx, rpcURL, "", "getBlockHeight",
			map[string]any{"commitment": "confirmed"})
		if err != nil {
			return err
		}
		if status == nil && height > lastValidBlockHeight {
			return errors.New("blockhash expired with no recorded landing")
		}
		timer := time.NewTimer(500 * time.Millisecond)
		select {
		case <-ctx.Done():
			timer.Stop()
			return ctx.Err()
		case <-timer.C:
		}
	}
}
```

</Tab>

<Tab title="TypeScript">

```ts title="confirm.ts" tab="TypeScript" tab-group="language"
import { setTimeout as sleep } from 'node:timers/promises'
import { createSolanaRpc, type Signature } from '@solana/kit'

export async function waitForConfirmation(
  rpcUrl: string,
  signature: Signature,
  lastValidBlockHeight: bigint,
): Promise<void> {
  const rpc = createSolanaRpc(rpcUrl)
  for (;;) {
    const { value: [status] } = await rpc
      .getSignatureStatuses([signature], { searchTransactionHistory: true })
      .send()
    if (status?.err) throw new Error(`transaction failed: ${JSON.stringify(status.err)}`)
    if (status?.confirmationStatus === 'confirmed' || status?.confirmationStatus === 'finalized') {
      return
    }
    const height = await rpc.getBlockHeight({ commitment: 'confirmed' }).send()
    if (!status && height > lastValidBlockHeight) {
      throw new Error('blockhash expired with no recorded landing')
    }
    await sleep(500)
  }
}
```

</Tab>

</Tabs>

Pass the signature and last valid height from the transaction you actually signed. This example waits for `confirmed` or `finalized` and does not resend.

<span id="retry" />

## Decide whether to retry

| Situation | Action |
| --- | --- |
| Structured refusal with `retryable: true` | Resubmit unchanged after `retry_after_ms` when supplied, while the signed lifetime remains valid. |
| Structured refusal with `retryable: false` | Fix the cause or settle the invoice. A blind retry does not fix the request. |
| Accepted, but not yet confirmed | Check the signature and lifetime. You may resubmit the same signed bytes while valid; a duplicate at the same edge may be suppressed. |
| Timeout or lost connection before a reply | The request may already have been sent. Check the signature before deciding to resubmit. |
| Expired recent blockhash | Check the original outcome, then rebuild and sign again if your application still needs the action. |

Resubmissions can consume rate allowance. Solana prevents the same signed transaction from executing twice, but a new blockhash produces a new signature and can repeat the action. For [declared tips](https://supanode.xyz/docs/solana/sender/tips#what-is-billed), increasing the tip on a repeated signature can increase the charge.
