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

# Reset SMT Root

> Rotates the Sparse Merkle Tree, resetting the withdrawal root for a new tree epoch

Operator-only instruction that rotates the Sparse Merkle Tree by incrementing
`Instance.current_tree_index` and resetting the withdrawal root, allowing a new
epoch of 65,536 withdrawals.

<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)).
  On upstream `main` (as of commit `acdbb4b`, 2026-09-27) this instruction is
  replaced by `RotateBitmap(expected_generation)` (discriminator 8), and
  `ReleaseFunds` takes `(amount, user, transaction_nonce)` plus new
  `withdrawal_bitmap` and `memo_program` accounts.
</Info>

## Accounts

| Account                          | Writable | Signer | Description                                            |
| -------------------------------- | -------- | ------ | ------------------------------------------------------ |
| `payer`                          | ✓        | ✓      | Fee payer                                              |
| `operator`                       |          | ✓      | Operator signer                                        |
| `instance`                       | ✓        |        | Escrow instance PDA (`current_tree_index` incremented) |
| `operator_pda`                   |          |        | Operator PDA proving the signer is provisioned         |
| `event_authority`                |          |        | Event authority PDA for `EmitEvent` CPI                |
| `private_channel_escrow_program` |          |        | Escrow Program (self-reference for CPI)                |

## Parameters

| Parameter                     | Type  | Description                                                              |
| ----------------------------- | ----- | ------------------------------------------------------------------------ |
| `expected_current_tree_index` | `u64` | Replay guard; must match `Instance.current_tree_index` or the call fails |

## Returns

Returns a `TransactionBuilder` that can be used to build and send the
transaction.

## Example

```typescript
import { getResetSmtRootInstruction } from "../private-channel-escrow-program/clients/typescript/src/generated/instructions/resetSmtRoot";

const resetIx = getResetSmtRootInstruction({
  payer: operatorPayerSigner,
  operator: operatorSigner,
  instance: instancePda,
  operatorPda: operatorPdaAddress,
  eventAuthority: eventAuthorityPda,
  privateChannelEscrowProgram: ESCROW_PROGRAM_ID,
  expectedCurrentTreeIndex: currentTreeIndex // u64
});
```

## Important Notes

- Operator-only: requires a valid `operator_pda`; throws `InvalidOperatorPda`
  otherwise
- `expected_current_tree_index` must equal `Instance.current_tree_index` at call
  time; a stale value throws `UnexpectedTreeIndex`, guarding against replaying a
  reset that already landed
- Increments `Instance.current_tree_index`; nonces valid in the previous tree
  epoch are invalidated after rotation
- The `operator-private-channel` service calls this automatically when
  `transaction_nonce % 65536 == 0` (and `nonce > 0`), signaling the start of a
  new epoch; it should not need to be called manually under normal operation
- After rotation, the withdrawal root resets to the empty tree, so new
  withdrawals start from a fresh SMT
- Emits an event via `EmitEvent` CPI
