在 Withdraw Program 上销毁用户的通道侧代币余额,以标记
待处理的提款;操作员随后必须调用 Escrow
Program 上的 ReleaseFunds 以完成结算。
账户
| 账户 | 可写 | 签名者 | 描述 |
|---|---|---|---|
user | ✓ | 发起提款的代币所有者 | |
mint | ✓ | SPL 代币铸造账户(销毁对象) | |
token_account | ✓ | 用户的通道侧 token account(来源) | |
token_program | SPL Token Program | ||
associated_token_program | Associated Token Program |
参数
| 参数 | 类型 | 描述 |
|---|---|---|
amount | u64 | 提取的代币数量,以代币最小单位计 |
destination | Option<Pubkey> | 主网上的目标钱包;若为 None,则默认为签名者的钱包 |
返回值
返回一个 TransactionBuilder,可用于构建并发送
交易。
示例
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});
重要说明
- 此指令属于 Withdraw Program
(
J231K9UEpS4y4KAPwGc4gsMNCjKFRMYcQBcjVW7vBhVi开发网),而非 Escrow Program - 在通道侧销毁代币不会自动释放
主网上的资金;操作员随后必须携带有效的 SMT 排除证明调用 Escrow
Program 上的
ReleaseFunds - 若
amount为 0,将抛出ZeroAmount错误 - 若
destination为None,操作员的ReleaseFunds调用将把 资金释放至签名者的钱包
有关两个程序的完整错误代码参考,请参阅 Instructions -> Error Codes。
Is this page helpful?