> ## 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.

# Channel Lifecycle

> How private payment channels work, who the participants are, and when to use them

<Info>
  This page documents the Sparse Merkle Tree design at solana-private-channels
  commit `c9e2240`, the source of the program deployed to devnet (see
  [Installation](/developers/docs/tools/private-channels/quickstart/installation)).
  Since commit `46a8e24` (2026-09-09), upstream `main` uses an onchain
  withdrawal bitmap instead, and clients generated from `main` don't include
  the SMT parameters or `ResetSmtRoot`.
</Info>

## What is a Private Channel?

A private channel is an offchain payment network anchored to Solana. Users
deposit SPL tokens into an onchain escrow program, then transact offchain
through a gateway at high speed and zero per-transfer cost. Settlement back to
Solana Mainnet happens via a Sparse Merkle Tree proof, ensuring funds are always
redeemable and double-spend is impossible.

Unlike Solana's native payment flow, transfers within a channel do not appear
onchain until a user withdraws. The channel network runs its own transaction
pipeline (dedup -> sig verify -> sequencer -> executor -> settler) that
processes transactions independently of Solana's block time.

## Participants

### Instance Admin

The admin deploys the `Instance` PDA via `CreateInstance` and controls which SPL
token mints are accepted (`AllowMint` / `BlockMint`). The admin provisions and
revokes operators via `AddOperator` / `RemoveOperator`, and can transfer admin
rights via `SetNewAdmin`. There is one admin per instance. Admin rights transfer
is irreversible in a single step: the current admin cannot reclaim the role
without the new admin's cooperation.

### Operators

Operators are provisioned by the admin. They hold an `Operator` PDA and are the
only accounts permitted to call `ReleaseFunds` (to settle withdrawals to
Mainnet) and `ResetSmtRoot` (to rotate the Sparse Merkle Tree). Operators bypass
all ownership checks in the gateway and have access to all JSON-RPC methods
including `getBlock`, `getTransaction`, and `simulateTransaction`. JWT role:
`"operator"`. Operators must be provisioned directly in the database; there is
no self-service escalation. See the
[Operators guide](/developers/docs/tools/private-channels/operators) for deployment and
configuration details.

### Users

Users self-register through the Auth Service. JWT role: `"user"`. Users can call
`Deposit` directly on the Escrow Program and initiate withdrawals via the
channel-side `WithdrawFunds` instruction on the Withdraw Program. Gateway access
is gated to their own verified wallets; they cannot call `getBlock`,
`getTransaction`, or `simulateTransaction`.

## Channel Lifecycle

```mermaid
sequenceDiagram
    participant Admin
    participant Alice
    participant Mainnet as Solana Mainnet
    participant Channel as Private Channel Network

    Note over Admin,Channel: SETUP (one time)
    Admin->>Mainnet: CreateInstance
    Admin->>Mainnet: AllowMint
    Admin->>Mainnet: AddOperator

    Note over Alice,Channel: DEPOSIT
    Alice->>Mainnet: Deposit (tokens to escrow ATA)
    Note over Channel: Indexer detects deposit event,<br/>credits Alice's channel balance

    Note over Alice,Channel: OFFCHAIN TRANSFERS
    Alice->>Channel: SPL token transfer (via gateway)
    Channel-->>Alice: Confirmed (~100 ms, no Mainnet fee)

    Note over Alice,Mainnet: WITHDRAWAL
    Alice->>Channel: WithdrawFunds (burns channel balance)
    Note over Channel: Indexer detects burn (~1 s),<br/>operator submits ReleaseFunds
    Channel->>Mainnet: ReleaseFunds (with SMT exclusion proof)
    Mainnet-->>Alice: Tokens released to Mainnet wallet
```

<div className="sol-mermaid" data-fallback="mermaid" data-mermaid="769e8bf99c19">
  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/769e8bf99c19-light.svg" alt="Channel Lifecycle diagram" />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/769e8bf99c19.svg" alt="Channel Lifecycle diagram" />

  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/769e8bf99c19-sm-light.svg" alt="Channel Lifecycle diagram" />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/769e8bf99c19-sm.svg" alt="Channel Lifecycle diagram" />
</div>

1. **Instance creation** - Admin calls `CreateInstance`, creating the `Instance`
   PDA and configuring allowed mints.
2. **Deposit** - Users deposit SPL tokens into the escrow via the `Deposit`
   instruction. Tokens move to the instance's associated token account.
3. **Offchain transfers** - Users send transfers through the gateway. Transfers
   are sequenced and executed on the channel network without touching Mainnet.
4. **Withdrawal initiation** - A user calls `WithdrawFunds` on the Withdraw
   Program (channel side) to burn their balance and signal a withdrawal.
5. **Mainnet settlement** - An operator provides a valid SMT exclusion proof and
   calls `ReleaseFunds` on the Escrow Program (Mainnet), releasing tokens to the
   user's wallet.
6. **Tree rotation** - When the SMT approaches capacity (65,536 leaves), the
   operator calls `ResetSmtRoot` to rotate the tree and start a new epoch.

### Transfer

```mermaid
sequenceDiagram
    participant Alice
    participant Bob
    participant GW as Gateway
    participant Pipeline as Write Node Pipeline
    participant DB as Channel State

    Alice->>GW: SPL token transfer to Bob
    GW->>Pipeline: Route to write node

    Note over Pipeline: 1. Dedup - reject duplicates and replays<br/>2. SigVerify - validate signatures<br/>3. Sequencer - order into conflict-free batch<br/>4. Executor - apply to offchain account state<br/>5. Settler - commit to database, update blockhash

    Pipeline->>DB: Commit updated balances
    GW-->>Alice: Confirmed (offchain, not recorded on Mainnet)
    Note over Bob: Balance updated in channel state
```

<div className="sol-mermaid" data-fallback="mermaid" data-mermaid="9be46cc54c85">
  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/9be46cc54c85-light.svg" alt="Transfer diagram" />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/9be46cc54c85.svg" alt="Transfer diagram" />

  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/9be46cc54c85-sm-light.svg" alt="Transfer diagram" />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/9be46cc54c85-sm.svg" alt="Transfer diagram" />
</div>

### Withdrawal

```mermaid
sequenceDiagram
    participant Bob
    participant Channel as Private Channel Network
    participant Indexer as indexer-private-channel
    participant Operator as operator-private-channel
    participant Mainnet as Solana Mainnet

    Bob->>Channel: WithdrawFunds (burns channel-side balance)
    Channel-->>Bob: Burn confirmed offchain

    Note over Indexer: Polls gateway every 1 s
    Indexer->>Channel: Detect burn event
    Indexer->>Indexer: Write pending withdrawal to database

    Operator->>Indexer: Pick up pending record
    Operator->>Mainnet: ReleaseFunds (SMT exclusion proof)
    Mainnet-->>Bob: Tokens transferred to Mainnet ATA
```

<div className="sol-mermaid" data-fallback="mermaid" data-mermaid="fbdcc12b1f66">
  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/fbdcc12b1f66-light.svg" alt="Withdrawal diagram" />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/fbdcc12b1f66.svg" alt="Withdrawal diagram" />

  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/fbdcc12b1f66-sm-light.svg" alt="Withdrawal diagram" />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/fbdcc12b1f66-sm.svg" alt="Withdrawal diagram" />
</div>

## When to Use Private Channels

Use private channels when your application needs:

- **Offchain throughput** - your transfer volume would saturate Solana TPS or
  you need sub-second confirmation
- **Privacy** - counterparty identities and transfer amounts must not appear
  onchain
- **Zero per-transfer fees** - transferring frequently where per-transaction SOL
  cost is prohibitive

Use native SPL transfers instead when:

- **Onchain composability** is required (DeFi, swaps, lending; other programs
  must be able to observe or act on the transfer)
- **Single-transfer settlement** is fine and privacy is not a concern
- **No gateway infrastructure** is available or operationally feasible
