:2026-09-09 6:42 点击:6
在Solana生态中发行代币(俗称“发币”)是许多项目方和开发者的常见需求,得益于Solana的高性能、低交易成本和成熟的开发者工具链,整个过程已相对简化,本文将详细介绍Sol链上发币的完整流程、关键工具及注意事项,助你快速上手。
在Solana上发币前,需先确定代币类型,主要分为两类:
对于大多数用户,推荐选择SPL代币,本文以此为重点展开。
发币前需准备以下工具:
npm install -g @solana/web3.js solana-keygen new --outfile ~/.config/solana/id.json # 生成新钱包(或导入现有钱包) solana config set --url https://api.mainnet-beta.solana.com # 切换到主网(测试网用https://api.devnet.solana.com)
Mint(铸币厂)是代币的“源头”,负责控制代币的发行总量,通过Solana CLI或代码创建Mint地址:
代码示例(Node.js):
import { Connection, Keypair, Transaction, SystemProgram, LAMPORTS_PER_SOL } from '@solana/web3.js';
import { createInitializeMintInstruction, getMintLen, getAssociatedTokenAddress, createAssociatedTokenAccountInstruction, MintLayout } from '@solana/spl-token';
const connection = new Connection('https://api.mainnet-beta.solana.com');
const payer = Keypair.fromSecretKey(Uint8Array.from([/* 钱私钥 */]));
const mint = Keypair.generate(); // 生成Mint地址
// 创建Mint账户空间(需租金,约0.899 SOL)
const rentExempt = await connection.getMinimumBalanceForRentExemption(MintLayout.span);
const createAccountParams = SystemProgram.createAccount({
fromPubkey: payer.publicKey,
newAccountPubkey: mint.publicKey,
lamports: rentExempt,
space: MintLayout.span,
programId: TOKEN_PROGRAM_ID,
});
// 初始化Mint(设置 decimals=6,即6位小数,总供应量=1亿)
const initMintParams = createInitializeMintInstruction(
mint.publicKey,
6,
payer.publicKey, // Mint Authority(可控制增发)
payer.publicKey, // Freeze Authority(可选,用于冻结/解冻代币)
TOKEN_PROGRAM_ID
);
const transaction = new Transaction().add(createAccountParams, initMintParams);
await connection.sendTransaction(transaction, [payer, mint]);
console.log('Mint地址:', mint.publicKey.toBase58());
创建Mint时需定义关键参数:

Mint创建后,需向用户或流动性池铸造代币:
createAssociatedTokenAccountInstruction创建用户代币账户(关联其钱包),再用mintTo铸造代币: const userTokenAccount = await getAssociatedTokenAddress(mint.publicKey, userWallet.publicKey); const mintToParams = createMintToInstruction( mint.publicKey, userTokenAccount, payer.publicKey, 1000000 * 10**6 // 铸造100万代币(乘以10^decimals) ); await connection.sendTransaction(new Transaction().add(mintToParams), [payer]);
代币需提供流动性才能交易,主流选择是Raydium或Orca:
若不想写代码,也可使用无代码工具简化流程:
通过以上步骤,你即可在Solana链上完成代币发行,Solana的高性能和低门槛使其成为DeFi、GameFi等项目的理想选择,但发币后仍需注重社区运营和生态建设,才能真正发挥代币价值。
本文由用户投稿上传,若侵权请提供版权资料并联系删除!