快速入门
销毁同质化代币
Last updated November 28, 2025
销毁同质化代币以从Solana区块链的流通中永久移除。
销毁代币
在以下部分,您可以看到完整的代码示例以及需要更改的参数。销毁代币会永久销毁它们——此操作无法撤销。
1// To install all the required packages use the following command
2// npm install @metaplex-foundation/mpl-toolbox @metaplex-foundation/umi @metaplex-foundation/umi-bundle-defaults
3import {
4 burnToken,
5 findAssociatedTokenPda,
6} from '@metaplex-foundation/mpl-toolbox';
7import {
8 keypairIdentity,
9 publicKey,
10} from '@metaplex-foundation/umi';
11import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
12import { readFileSync } from 'fs';
13
14// Initialize Umi with Devnet endpoint
15const umi = createUmi('https://api.devnet.solana.com')
16
17// Load your wallet/keypair
18const wallet = '<your wallet file path>'
19const secretKey = JSON.parse(readFileSync(wallet, 'utf-8'))
20const keypair = umi.eddsa.createKeypairFromSecretKey(new Uint8Array(secretKey))
21umi.use(keypairIdentity(keypair))
22
23// Your token mint address
24const mintAddress = publicKey('<your token mint address>')
25
26// Find the token account to burn from
27const tokenAccount = findAssociatedTokenPda(umi, {
28 mint: mintAddress,
29 owner: umi.identity.publicKey,
30})
31
32// Burn 100 tokens
33await burnToken(umi, {
34 account: tokenAccount,
35 mint: mintAddress,
36 amount: 100,
37}).sendAndConfirm(umi)
38
39console.log('Burned 100 tokens')
40console.log('Mint:', mintAddress)
41console.log('Token Account:', tokenAccount)
参数
根据您的销毁操作自定义以下参数:
| 参数 | 描述 |
|---|---|
mintAddress | 代币铸币地址 |
amount | 要销毁的代币数量 |
工作原理
销毁过程涉及2个步骤:
- 查找代币账户 - 使用
findAssociatedTokenPda定位您的代币账户 - 销毁代币 - 使用
burnToken执行销毁
何时销毁代币
销毁代币的常见用例:
- 减少供应量 - 降低总流通供应量
- 通缩机制 - 实现随时间减少供应量的代币经济学
- 错误修正 - 移除错误铸造的代币
重要说明
- 销毁是永久性的,无法撤销
- 您只能销毁您拥有的代币
amount需要考虑小数位数(例如,如果是9位小数,销毁1个代币需要amount: 1_000_000_000)
