> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# Confirmation & finality

> How a Solana transaction moves from processed to confirmed to finalized, which commitment level to wait for, and what happens when a transaction expires.

## In short

A transaction goes from *processed* to *finalized* in well under a second, and once finalized it can't be reversed. *Confirmed* reports the same block as finalized.

<div className="sol-usedin not-prose" data-concept="commitment">
<span className="sol-usedin-label">You've used this in:</span> [Payments <span className="sol-usedin-step">Step 3</span>](/developers/docs/payments/checkout/backend) [Pay-per-call <span className="sol-usedin-step">Step 3</span>](/developers/docs/payments/paywall-api/server) [Trade settlement <span className="sol-usedin-step">Step 4</span>](/developers/docs/defi/settle-trade/go-live)
</div>

## Commitment levels

When you send a
<span className="sol-chip" data-concept="transaction"><Tooltip headline="Transactions" tip="A transaction is a signed request to change the shared ledger. It either fully happens or doesn't happen at all, and once confirmed anyone can look it up." cta="Learn more" href="/developers/docs/core/transactions">transaction</Tooltip><span className="nojs-only"> ([Transactions](/developers/docs/core/transactions): A transaction is a signed request to change the shared ledger. It either fully happens or doesn't happen at all, and once confirmed anyone can look it up.)</span>,</span> the
network does not answer "done" once. Validators vote on the block that
contains it, and RPC methods let you choose how much of that progress to wait
for. That choice is the **commitment level**.

| Level       | What has happened                                                                                        | Typical time after sending | Can it still be reversed?            |
| ----------- | -------------------------------------------------------------------------------------------------------- | -------------------------- | ------------------------------------ |
| `processed` | The RPC node has seen the transaction in its most recent block.                                          | A few hundred milliseconds | Yes. The block can still be skipped. |
| `confirmed` | The same as `finalized`.                                                                                 | Under a second             | No.                                  |
| `finalized` | Validators holding at least 80% of stake (in one round) or 60% (in two rounds) have certified the block. | Under a second             | No.                                  |

A block is finalized roughly 150 milliseconds after it is produced, so
`confirmed` and `finalized` arrive together. `confirmed` remains available so
existing code keeps working and is planned for removal in a later release;
point new code at `finalized`.
[Settlement and finality](/developers/docs/defi/finality) explains how
finality works.

If a method or subscription accepts `commitment` and you leave it out, the
default is usually `finalized`. See
[configuring state commitment](/developers/docs/rpc#configuring-state-commitment) in the
RPC reference.

## Which level to wait for

| You want to                                                    | Wait for    |
| -------------------------------------------------------------- | ----------- |
| Show progress in a UI, such as "payment sent"                  | `processed` |
| Ship an order, unlock content, or answer a paid API request    | `finalized` |
| Credit a large deposit or settle a trade that cannot be undone | `finalized` |

Use the same level for reads that follow a write. If you send at `processed`
and then read balances at `finalized`, the read can return the state from
before your transaction.

## Check a payment at a commitment level

The checkout tutorial confirms each payment on the server before it ships the
order. It fetches the transaction at `confirmed`, then checks that it succeeded
and moved the right amount. The output below is from a local Surfpool network.

```ts checkout/verify-payment.ts
import type { Address, Signature } from "@solana/kit";
import { rpc } from "./config";

export type PaymentCheck = { paid: true } | { paid: false; reason: string };

/**
 * Confirm on your server that `signature` paid this order: the transaction
 * succeeded, it carries the order's reference, and the store's token account
 * for `mint` received exactly `amount` base units. Never trust the browser's
 * word for it.
 */
export async function verifyPayment(order: {
  signature: Signature;
  storeOwner: Address;
  mint: Address;
  amount: bigint;
  reference?: Address;
}): Promise<PaymentCheck> {
  const tx = await rpc
    .getTransaction(order.signature, {
      commitment: "confirmed",
      encoding: "jsonParsed",
      maxSupportedTransactionVersion: 0,
    })
    .send();
  if (!tx) return { paid: false, reason: "transaction not found" };
  if (tx.meta?.err) return { paid: false, reason: "transaction failed" };

  const keys = tx.transaction.message.accountKeys.map((k) => k.pubkey);
  if (order.reference && !keys.includes(order.reference)) {
    return { paid: false, reason: "reference not found" };
  }

  // What the store's token account for this mint held before and after.
  type TokenBalances = NonNullable<typeof tx.meta>["preTokenBalances"];
  const balance = (list: TokenBalances) =>
    BigInt(
      list?.find((b) => b.owner === order.storeOwner && b.mint === order.mint)
        ?.uiTokenAmount.amount ?? "0",
    );
  const received =
    balance(tx.meta?.postTokenBalances) - balance(tx.meta?.preTokenBalances);
  if (received !== order.amount) {
    return {
      paid: false,
      reason: `amount mismatch: expected ${order.amount}, received ${received}`,
    };
  }
  return { paid: true };
}
```

<div className="sol-term not-prose" data-term="paths/payments/checkout/verify" data-tab="checkout/verify-payment.ts" data-kind="block" data-steps="1" data-l-run="Run" data-l-run-step="Run step" data-l-next="Next step" data-l-all="Run all" data-l-again="Run again" data-l-running="Running…" data-l-tx="Sending transaction…" data-l-http="Requesting…" data-l-call="Running…" data-l-confirming="Confirming…" data-l-done="Done" data-l-copied="Copied" data-l-step="Step">
<div className="sol-term-head"><span className="sol-term-title">Output of verifyPayment() with the right and a wrong amount</span><span className="sol-term-env">Local test network (Surfpool)</span><button type="button" className="sol-term-copy" data-act="copy">Copy</button></div>
<div className="sol-term-screen" role="region" tabIndex="0" aria-label="Output of verifyPayment() with the right and a wrong amount: Output">
<div className="sol-term-step" data-step="1" data-pending="call">
<div className="sol-term-row sol-term-cmd"><span className="sol-term-ps" aria-hidden="true">\></span> `await verifyPayment({ ...order, signature, mint: USDC_MINT })`</div>
<div className="sol-term-row sol-term-ln" data-tone="ok">\{ paid\: true \}</div>
<div className="sol-term-row sol-term-cmd"><span className="sol-term-ps" aria-hidden="true">\></span> `await verifyPayment({ ...order, amount: 2_000_000n, signature, mint: USDC_MINT })`</div>
<div className="sol-term-row sol-term-ln">\{</div>
<div className="sol-term-row sol-term-ln" data-tone="error" data-indent="2"><span className="sol-term-k">paid\:</span> false,</div>
<div className="sol-term-row sol-term-ln" data-tone="error" data-indent="2"><span className="sol-term-k">reason\:</span> `'amount mismatch: expected 2000000, received 1000000'`</div>
<div className="sol-term-row sol-term-ln">\}</div>
<div className="sol-term-result"><span className="sol-term-badge" data-tone="ok">Right amount\: paid</span><span className="sol-term-badge" data-tone="error">Wrong amount\: refused</span></div>
</div>
</div>
<div className="sol-term-foot"><button type="button" className="sol-term-btn" data-act="run">Run</button><span className="sol-term-status"></span><span className="sol-term-sr" role="status"></span></div>
</div>

To track a transaction you sent, poll
[`getSignatureStatuses`](/developers/docs/rpc/http/getsignaturestatuses), which returns each
signature's `confirmationStatus`, or subscribe with
[`signatureSubscribe`](/developers/docs/rpc/websocket/signaturesubscribe).

## Expiry

Every transaction includes a recent blockhash. If the transaction has not landed
in a block before that blockhash is more than 150 blocks old, about 30 seconds
at 200ms slots, the network drops it and it can never be processed. That makes
retries safe: when a send times out, wait until the blockhash has expired, then rebuild
the transaction with a fresh blockhash and send it again.

- [Transaction confirmation and expiration](/developers/cookbook/transactions/confirmation)
  explains how expiry works and lists best practices for each commitment
  level.
- [Retry transactions](/developers/cookbook/transactions/retry) covers custom
  retry logic.
- [Durable nonces](/developers/docs/core/transactions/durable-nonces) let you sign a
  transaction now and submit it later without it expiring.
