销毁指令
通过将代币从流通中移除来永久销毁代币。这将减少代币的总供应量。
在我们销毁任何代币之前,我们需要已经拥有:
- 一个已初始化的
Mint
账户。 - 一个
Token
账户或一个Associated Token
账户,并且该账户中至少有我们想要销毁的数量。
这是 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,
)?;