Anchor
使用 Anchor 的 SPL 代币

使用 Anchor 的 SPL 代币

销毁指令

通过将代币从流通中移除来永久销毁代币。这将减少代币的总供应量。

在我们销毁任何代币之前,我们需要已经拥有:

  • 一个已初始化的 Mint 账户。
  • 一个 Token 账户或一个 Associated Token 账户,并且该账户中至少有我们想要销毁的数量。

我们销毁的代币数量是根据小数位数进行“标准化”的。这意味着,如果我们想销毁一个有 6 位小数的代币,我们实际上需要将 1_000_000 作为数量输入。

这是 CPI 到 burn() 指令的样子:

burn(
    CpiContext::new(
        ctx.accounts.token_program.to_account_info(),
        Burn {
            mint: ctx.accounts.mint.to_account_info(),
            from: ctx.accounts.token_account.to_account_info(),
            authority: ctx.accounts.authority.to_account_info(),
        },
    ),
    &1_000_000,
)?;
Blueshift © 2025Commit: fd080b2