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

# Withdraw Funds

> Burns channel-side tokens to initiate a withdrawal back to the Solana mainnet escrow

Burns a user's channel-side token balance on the Withdraw Program to signal a
pending withdrawal; an operator must subsequently call `ReleaseFunds` on the
Escrow Program to complete settlement.

## Accounts

| Account                    | Writable | Signer | Description                                |
| -------------------------- | -------- | ------ | ------------------------------------------ |
| `user`                     |          | ✓      | Token owner initiating the withdrawal      |
| `mint`                     | ✓        |        | SPL token mint (burned against)            |
| `token_account`            | ✓        |        | User's channel-side token account (source) |
| `token_program`            |          |        | SPL Token Program                          |
| `associated_token_program` |          |        | Associated Token Program                   |

## Parameters

| Parameter     | Type             | Description                                                          |
| ------------- | ---------------- | -------------------------------------------------------------------- |
| `amount`      | `u64`            | Amount of tokens to withdraw, in the token's smallest unit           |
| `destination` | `Option<Pubkey>` | Target wallet on Mainnet; if `None`, defaults to the signer's wallet |

## Returns

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

## Example

```typescript
import { getWithdrawFundsInstruction } from "../private-channel-withdraw-program/clients/typescript/src/generated/instructions/withdrawFunds";

const withdrawIx = getWithdrawFundsInstruction({
  user: userSigner,
  mint: mintAddress,
  tokenAccount: channelTokenAccount,
  tokenProgram: TOKEN_PROGRAM_ID,
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
  amount: 1_000_000n,
  destination: null // null = release to signer's Mainnet wallet
});
```

## Important Notes

- This instruction is on the **Withdraw Program**
  (`J231K9UEpS4y4KAPwGc4gsMNCjKFRMYcQBcjVW7vBhVi` devnet), not the Escrow
  Program
- Burning tokens on the channel side does **not** automatically release funds on
  Mainnet; an operator must subsequently call `ReleaseFunds` on the Escrow
  Program with a valid SMT exclusion proof
- `ZeroAmount` error is thrown if `amount` is 0
- If `destination` is `None`, the operator's `ReleaseFunds` call will release
  funds to the signer's wallet

For the full error code reference for both programs, see
[Instructions -> Error Codes](/developers/docs/tools/private-channels/instructions#error-codes).
