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

# Operators

> Deploy and operate a Private Channels instance with Docker Compose

## What is a Private Channels Operator?

An operator is a trusted, onchain-permissioned entity that bridges Solana
Mainnet and the private channel network. Operators are provisioned by the
instance admin via `AddOperator`, which creates an onchain `Operator` PDA;
without this, no party can call `ReleaseFunds`. In practice, an operator is an
organization or team running the services that watch for deposits, mint
channel-side tokens, detect withdrawals, and settle funds back to Mainnet.
Running an instance gives your users private, high-volume transfers that don't
appear on Solana Mainnet, instant zero-fee throughput beyond native Solana TPS,
and controlled access via RBAC.

<Info>
  If you're a developer integrating against an existing Private Channels
  instance rather than deploying one, start with the
  [Quickstart](/developers/docs/tools/private-channels/quickstart/installation) instead.
</Info>

## Before You Start

<Info>
  This guide targets solana-private-channels commit `c9e2240`, the source of
  the escrow program deployed to devnet at
  `9tgHa1DcnaSSUtmMsst8ovKTe1Gfxzezn27KnH9xXYeU`. Upstream `main` has moved
  on: it renames `ESCROW_INSTANCE_ID` to `COMMON_ESCROW_INSTANCE_ID`, requires
  permanent-delegate keys and more secrets, adds arguments to `allow_mint`, and
  replaces the Sparse Merkle Tree with an onchain withdrawal bitmap. The devnet
  program still runs the `c9e2240` code, so follow this guide from a `c9e2240`
  checkout.
</Info>

### Prerequisites

Pin these versions on the host to match the Docker images:

- Docker Engine 26+ (macOS Apple Silicon: enable "Docker VMM" in Settings ->
  Virtual Machine Options)
- Node.js **24** and pnpm **10.15.1**, the versions the repository's
  Dockerfile and `versions.env` use
- Solana CLI **3.1.13** (Agave)
- Rust **1.91.0**
- A Yellowstone gRPC endpoint for Devnet (available from Helius, Triton,
  QuickNode)

For network requirements and default port assignments, see
[`docs/TECHNICAL_REQUIREMENTS.md`](https://github.com/solana-foundation/solana-private-channels/blob/c9e2240/docs/TECHNICAL_REQUIREMENTS.md)
in the repository.

Clone the repository at the commit this guide targets, then install the pinned
Solana toolchain and warm the SBF cache:

```bash
git clone https://github.com/solana-foundation/solana-private-channels.git
cd solana-private-channels
git checkout c9e2240
make install-toolchain
```

### Services

Running a Private Channels instance means owning five ongoing responsibilities,
each handled by dedicated containers in the Docker Compose stack:

1. **Index Mainnet for deposits** - `indexer-solana` watches Solana Mainnet for
   `Deposit` events via Yellowstone gRPC; `operator-solana` picks up confirmed
   deposits and mints the equivalent token balance on the channel network
2. **Index the channel for withdrawals** - `indexer-private-channel` polls the
   channel every second for `WithdrawFunds` burn events and writes pending
   withdrawal records to the database
3. **Release funds on Mainnet** - `operator-private-channel` picks up pending
   records and calls `ReleaseFunds` on the Escrow Program with a
   [Sparse Merkle Tree](/developers/docs/tools/private-channels/concepts/smt)
   exclusion proof for the withdrawal's nonce
4. **Rotate the Sparse Merkle Tree** - when a tree's 65,536 nonces are used,
   `operator-private-channel` calls `ResetSmtRoot` to start a new tree; the
   onchain proof check, which releases each nonce at most once, is the last
   line of defense against replayed withdrawals
5. **Run the gateway and auth service** - the gateway is the single public
   endpoint for all client traffic; the auth service (optional) enforces
   JWT/RBAC when `JWT_SECRET` is set

For the full service inventory and port assignments, see the
[Configuration reference](/developers/docs/tools/private-channels/operators/configuration).

> **Security note:** Write-node and read-node ports are bound to loopback
> (`127.0.0.1`) only, but several other services (gateway, auth, operator
> metrics, Grafana, Prometheus, cAdvisor) are published to all network
> interfaces by default. See the
> [Configuration reference](/developers/docs/tools/private-channels/operators/configuration#service-port-reference)
> for the full port table and firewall these before any public-facing
> deployment. RBAC only covers the gateway's own JSON-RPC methods, not these
> other services.

### Access Control: Open vs. RBAC

By default the gateway accepts all connections; no tokens required. To enable
JWT-based RBAC, set `JWT_SECRET` and start the stack with `--profile auth`. See
**[Authentication & Roles](/developers/docs/tools/private-channels/concepts/auth)** for the
full configuration reference, including how to provision the `operator` role and
register user wallets.

If enabling auth, add these to your environment before starting the stack:

```bash
JWT_SECRET=<openssl rand -hex 32>   # must match on gateway and auth service
AUTH_PORT=8903
```

## Environment Setup

`.env.devnet` is already tracked in the repository with devnet-specific defaults
filled in; edit it directly rather than regenerating it from `.env.example`,
which would overwrite those defaults.

Fill in the remaining values as you work through the deploy steps below; some
are only available mid-deployment. Secrets go in the gitignored `.env` file;
non-secret variables go in `.env.devnet`.

**Secrets - set these immediately:**

```bash
POSTGRES_PASSWORD=<openssl rand -hex 32>
POSTGRES_REPLICATION_PASSWORD=<openssl rand -hex 32>
GF_ADMIN_PASSWORD=<openssl rand -hex 16>
```

`make docker-devnet-up` refuses to start without the two PostgreSQL passwords.
`GF_ADMIN_PASSWORD` isn't checked, but `.env.devnet` sets it to `admin`, so
override it here.

**Variables obtained during deployment:**

```bash
ESCROW_INSTANCE_ID=<instance address - from Step 3>
ADMIN_PRIVATE_KEY=<operator keypair as u8 array or base58 - from Step 4>
DEVNET_RPC_URL=https://api.devnet.solana.com
DEVNET_YELLOWSTONE_ENDPOINT=<your Yellowstone gRPC endpoint>
INDEXER_YELLOWSTONE_TOKEN=<your Yellowstone auth token>
```

<Warning>
  `ADMIN_PRIVATE_KEY` is the offchain services' own required fee-payer signer,
  unrelated to the onchain instance admin from Step 3. This guide puts the
  **operator** keypair generated in Step 4 below into `ADMIN_PRIVATE_KEY` and
  leaves the optional `OPERATOR_PRIVATE_KEY` unset, so the operator signer falls
  back to the same key. Never put the protocol-level instance admin keypair from
  Step 3 into either variable.
</Warning>

For the full environment variable reference, see
**[Configuration](/developers/docs/tools/private-channels/operators/configuration)**.

## Deploy

<Steps titleSize="h3">

<Step title="Build images">

```bash
make docker-devnet-build
```

This compiles all Rust services into a shared Docker image. The first build
takes 30 minutes to an hour.

</Step>

<Step title="Set up instance management tooling">

You create and configure the escrow instance (`CreateInstance`, `AllowMint`,
`AddOperator`) with the CLI binaries in
[`scripts/devnet`](https://github.com/solana-foundation/solana-private-channels/tree/c9e2240/scripts/devnet),
run from the repository root. They read their signers from keypair files, so
create those first:

```bash
mkdir -p keypairs
# Escrow admin (Instance.admin): signs create_instance, allow_mint, add_operator
solana-keygen new -o ./keypairs/escrow-admin.json -s --no-bip39-passphrase
# User: holds the whitelisted token, signs deposit and withdraw
solana-keygen new -o ./keypairs/user.json -s --no-bip39-passphrase
```

The binaries compile against the Codama-generated escrow and withdraw clients,
which are not checked in. Install the program dependencies and generate the
clients before the first `cargo run`:

```bash
make install
make generate-clients
```

The scripts build their instructions from the program source you checked out,
so the escrow program they call must match it. At `c9e2240` the program differs
from the source of the devnet deploy only in its `declare_id!` line (the
retarget to `9tgHa1`), so the deployed program is current for this commit. To
confirm it hasn't been redeployed since June 23, 2026:

```bash
solana program show 9tgHa1DcnaSSUtmMsst8ovKTe1Gfxzezn27KnH9xXYeU --url devnet   # note "Last Deployed In Slot"
solana block-time <LAST_DEPLOYED_SLOT> --url devnet
```

If the program was redeployed from a newer commit, or you change the program
source, the scripts and the program disagree and `create_instance` can fail
(for example with `NotEnoughAccountKeys`). Redeploy the programs from your
checkout as described in
[Step 0 of the devnet quickstart](https://github.com/solana-foundation/solana-private-channels/blob/c9e2240/docs/DEVNET_QUICKSTART.md#step-0-check-the-on-chain-programs-are-current-upgrade-if-stale).

</Step>

<Step title="Create an escrow instance">

Ensure the escrow admin keypair has Devnet SOL for fees (use the
[Solana Faucet](https://faucet.solana.com/) if needed), then run the CLI script
from `scripts/devnet`, which creates the instance and prints its address
(`escrow_instance_id`). Set that address as `ESCROW_INSTANCE_ID` in
`.env.devnet`.

```bash
cargo run --bin create_instance -- \
  https://api.devnet.solana.com \
  ./keypairs/escrow-admin.json
```

</Step>

<Step title="Generate an operator keypair">

```bash
solana-keygen new -o operator-keypair.json -s --no-bip39-passphrase
solana-keygen pubkey operator-keypair.json
```

Set the keypair contents as `ADMIN_PRIVATE_KEY` in your environment. The public
key isn't an environment variable; you'll pass it directly as the operator
pubkey in the "Configure the instance" step below.

</Step>

<Step title="Finalize environment variables">

Update `.env.devnet` with `ESCROW_INSTANCE_ID`, `DEVNET_RPC_URL`,
`DEVNET_YELLOWSTONE_ENDPOINT`, and `INDEXER_YELLOWSTONE_TOKEN`. Put secrets
(`POSTGRES_PASSWORD`, `POSTGRES_REPLICATION_PASSWORD`, `GF_ADMIN_PASSWORD`,
`ADMIN_PRIVATE_KEY`) in the gitignored `.env` file.

If you decided to enable RBAC
([Access Control: Open vs. RBAC](#access-control-open-vs-rbac)), also add
`JWT_SECRET` and `AUTH_PORT` now.

</Step>

<Step title="Start all services">

Without auth:

```bash
make docker-devnet-up
```

With auth:

```bash
docker compose -f docker-compose.devnet.yml --env-file versions.env --env-file .env.devnet --env-file .env --profile auth up -d
```

Compose disables its automatic `.env` auto-load once any `--env-file` flag is
passed, so the trailing `--env-file .env` is required. Without it,
`POSTGRES_PASSWORD`, `ADMIN_PRIVATE_KEY`, and `JWT_SECRET` (which you put in
`.env` above) resolve empty and the stack fails to start correctly.

> Start services before configuring the instance. The indexer streams events in
> real time, so bringing the stack up first ensures `AllowMint` and your first
> deposit are indexed in order without needing a backfill.

</Step>

<Step title="Configure the instance">

With the stack running, whitelist a token mint and add your operator using the
`scripts/devnet` cargo binaries.

1. **Allow Mint**: whitelist the token mint you want to support (for example
   Devnet USDC, `4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU`):

   ```bash
   cargo run --bin allow_mint -- \
     https://api.devnet.solana.com \
     ./keypairs/escrow-admin.json \
     <INSTANCE_ID> \
     <MINT_ADDRESS>
   ```

2. **Add Operator**: register the operator public key from the "Generate an
   operator keypair" step:

   ```bash
   cargo run --bin add_operator -- \
     https://api.devnet.solana.com \
     ./keypairs/escrow-admin.json \
     <INSTANCE_ID> \
     <OPERATOR_PUBKEY>
   ```

</Step>

</Steps>

<Warning>

This guide targets Solana devnet. For Mainnet:

- Program IDs are compiled in via `declare_id!()`: verify you are using the
  correct Mainnet IDs from the repository
- Yellowstone gRPC endpoints require a Mainnet plan; devnet endpoints will not
  stream Mainnet events
- The operator wallet pays SOL fees for every `ReleaseFunds` call, so size the
  SOL balance for your expected withdrawal volume
- Change all default credentials (Grafana, PostgreSQL) before any public-facing
  deployment

</Warning>

## Operations

### Instance Administration

The escrow admin keypair manages the instance after setup. At `c9e2240`,
`scripts/devnet` has only the setup commands above plus test `deposit` and
`withdraw` commands. Blocking a mint, revoking an operator and transferring the
admin role have no CLI script; send the
[BlockMint](/developers/docs/tools/private-channels/instructions/block-mint),
[RemoveOperator](/developers/docs/tools/private-channels/instructions/remove-operator)
and [SetNewAdmin](/developers/docs/tools/private-channels/instructions/set-new-admin)
instructions with the generated
[escrow program clients](https://github.com/solana-foundation/solana-private-channels/tree/c9e2240/private-channel-escrow-program/clients).
`BlockMint` closes the mint's `AllowedMint` account. New deposits of that mint
fail, and so does `ReleaseFunds`, which reads the same account: withdrawals of
that mint can't settle until you run `allow_mint` for it again.

### Useful Commands

```bash
# View logs (all services)
make docker-devnet-logs

# View logs (specific service)
docker compose -f docker-compose.devnet.yml --env-file versions.env --env-file .env.devnet logs -f indexer-solana

# Stop services
make docker-devnet-down

# Stop and wipe all state (volumes)
make docker-devnet-clean
```

### Observability

The stack includes Prometheus, Grafana, and cAdvisor for metrics and container
monitoring. Grafana is on port `37429`, published on all network interfaces.

<Warning>
  `.env.devnet` sets the Grafana admin password (`GF_ADMIN_PASSWORD`) to
  `admin`. Override it in `.env` before you start the stack, and firewall port
  37429 from networks beyond localhost.
</Warning>

## Troubleshooting

### Channel balance not updating after deposit

1. Confirm the Mainnet deposit transaction landed on a Mainnet explorer
2. Verify `indexer-solana` is running:
   `docker compose -f docker-compose.devnet.yml --env-file versions.env --env-file .env.devnet logs -f indexer-solana`
3. Verify `operator-solana` is running:
   `docker compose -f docker-compose.devnet.yml --env-file versions.env --env-file .env.devnet logs -f operator-solana`
4. Check that your Yellowstone gRPC endpoint is reachable and the token is valid
   (`DEVNET_YELLOWSTONE_ENDPOINT`, `INDEXER_YELLOWSTONE_TOKEN`)
5. Allow up to 30 seconds after onchain confirmation, since the indexer applies
   a finality safety delay before crediting

### Withdrawal not settling to Mainnet

1. Verify `indexer-private-channel` is running:
   `docker compose -f docker-compose.devnet.yml --env-file versions.env --env-file .env.devnet logs -f indexer-private-channel`
2. Verify `operator-private-channel` is running:
   `docker compose -f docker-compose.devnet.yml --env-file versions.env --env-file .env.devnet logs -f operator-private-channel`
3. Confirm the operator keypair in `ADMIN_PRIVATE_KEY` matches the key
   registered with `AddOperator` onchain
4. If `operator-private-channel` exits at startup with `SMT root mismatch` in
   its logs, the SMT root rebuilt from the database doesn't match the onchain
   `withdrawal_transactions_root`. Follow the repository's
   [withdrawal pipeline halt runbook](https://github.com/solana-foundation/solana-private-channels/blob/c9e2240/docs/runbooks/withdrawal_pipeline_halt_runbook.md)
   before restarting

### JWT authentication failures (401 on all requests)

1. Confirm `JWT_SECRET` is identical on both the gateway and auth service
   containers
2. Confirm the stack was started with `--profile auth`
3. Tokens expire after 24 hours; re-authenticate to get a fresh token

### First build takes too long

Expected. The first `make docker-devnet-build` compiles all Rust services and
can take 30-60 minutes on typical hardware. Subsequent builds use Docker layer
cache and are significantly faster.

## Next Steps

<Columns cols={2}>
  <Card
    title="Quickstart"
    href="/developers/docs/tools/private-channels/quickstart/installation"
  >
    Test your deployment: deposit, transfer, and withdraw on devnet.
  </Card>
  <Card
    title="Configuration"
    href="/developers/docs/tools/private-channels/operators/configuration"
  >
    Full environment variable reference for all services.
  </Card>
  <Card
    title="Authentication & Roles"
    href="/developers/docs/tools/private-channels/concepts/auth"
  >
    Configure JWT authentication and provision operator-role users.
  </Card>
  <Card
    title="Instructions"
    href="/developers/docs/tools/private-channels/instructions/create-instance"
  >
    Full reference for all onchain instructions.
  </Card>
</Columns>
