Withdraw Funds

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

AccountWritableSignerDescription
userToken owner initiating the withdrawal
mintSPL token mint (burned against)
token_accountUser's channel-side token account (source)
token_programSPL Token Program
associated_token_programAssociated Token Program

Parameters

ParameterTypeDescription
amountu64Amount of tokens to withdraw, in the token's smallest unit
destinationOption<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

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.

Is this page helpful?

Зміст

Редагувати сторінку
Withdraw Funds | Solana