---
title: Withdraw Funds
description:
  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";

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](/docs/tools/private-channels/instructions#error-codes).
