重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
npx skills add https://github.com/sendaifun/skills --skill metaplex一份关于使用 Metaplex 协议在 Solana 上构建 NFT、数字资产和代币发行的综合指南——该协议是支撑 99% Solana NFT 和代币的行业标准。
Metaplex 是 Solana 上领先的代币化协议,提供用于创建、销售和管理数字资产的智能合约和工具。从简单的 NFT 到数十亿的压缩合集,从公平的代币发行到混合代币/NFT 系统,Metaplex 提供了基础设施。
Metaplex 为不同的用例提供了多种产品:
| 产品 | 描述 | 每次铸造成本 |
|---|---|---|
| Core | 下一代单账户 NFT 标准 | ~0.0029 SOL |
| Token Metadata | 使用 PDAs 的原始 NFT 标准 | ~0.022 SOL |
| Bubblegum v2 | 压缩 NFT (cNFTs) | ~0.00009 SOL |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 产品 | 描述 |
|---|---|
| Candy Machine | 带有防护机制的 NFT 合集铸造 |
| Core Candy Machine | 用于 Core 资产的 Candy Machine |
| Genesis | 代币生成事件平台 |
| 产品 | 描述 |
|---|---|
| MPL-Hybrid | 在可替代和不可替代代币之间交换 |
| Inscriptions | 链上数据存储(最高 10MB) |
| DAS API | 用于获取数字资产的统一 API |
| Umi | 用于 Solana 客户端的 JavaScript 框架 |
| 程序 | 地址 |
|---|---|
| MPL Core | CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d |
| Token Metadata | metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s |
| Bubblegum | BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY |
| Candy Machine V3 | CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR |
| Candy Guard | Guard1JwRhJkVH6XZhzoYxeBVQe872VH6QggF4BWmS9g |
| Core Candy Machine | CMACYFENjoBMHzapRXyo1JZkVS6EtaDDzkjMrmQLvr4J |
| Core Candy Guard | CMAGAKJ67e9hRZgfC5SFTbZH8MgEmtqazKXjmkaJjWTJ |
| MPL Hybrid | MPL4o4wMzndgh8T1NVDxELQCj5UQfYTYEkabX3wNKtb |
| Inscription | 1NSCRfGeyo7wPUazGbaPBUsTM49e1k2aXewHGARfzSo |
| 程序 | 地址 |
|---|---|
| SPL Token | TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA |
| Token 2022 | TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb |
| Associated Token | ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL |
| Account Compression | cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK |
# Core NFTs (推荐用于新项目)
npm install @metaplex-foundation/mpl-core \
@metaplex-foundation/umi \
@metaplex-foundation/umi-bundle-defaults
# Token Metadata NFTs
npm install @metaplex-foundation/mpl-token-metadata \
@metaplex-foundation/umi \
@metaplex-foundation/umi-bundle-defaults
# Compressed NFTs (Bubblegum)
npm install @metaplex-foundation/mpl-bubblegum \
@metaplex-foundation/umi \
@metaplex-foundation/umi-bundle-defaults
# Candy Machine
npm install @metaplex-foundation/mpl-candy-machine \
@metaplex-foundation/umi \
@metaplex-foundation/umi-bundle-defaults
# Core Candy Machine
npm install @metaplex-foundation/mpl-core-candy-machine \
@metaplex-foundation/umi \
@metaplex-foundation/umi-bundle-defaults
# Genesis (Token Launches)
npm install @metaplex-foundation/mpl-genesis \
@metaplex-foundation/umi \
@metaplex-foundation/umi-bundle-defaults
# File uploads (Arweave via Irys)
npm install @metaplex-foundation/umi-uploader-irys
所有 Metaplex SDK 都使用 Umi,一个模块化的 Solana 框架:
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import { mplCore } from '@metaplex-foundation/mpl-core';
import {
keypairIdentity,
generateSigner
} from '@metaplex-foundation/umi';
// 创建 Umi 实例
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(mplCore());
// 选项 1: 使用生成的密钥对
const signer = generateSigner(umi);
umi.use(keypairIdentity(signer));
// 选项 2: 使用现有的密钥对
import { createSignerFromKeypair } from '@metaplex-foundation/umi';
const keypair = umi.eddsa.createKeypairFromSecretKey(secretKeyBytes);
const signer = createSignerFromKeypair(umi, keypair);
umi.use(keypairIdentity(signer));
// 选项 3: 使用钱包适配器(浏览器)
import { walletAdapterIdentity } from '@metaplex-foundation/umi-signer-wallet-adapters';
umi.use(walletAdapterIdentity(wallet));
具有单账户设计、更低成本和内置插件的下一代 NFT 标准。
| 功能 | Core | Token Metadata |
|---|---|---|
| 每个 NFT 的账户数 | 1 | 4+ |
| 铸造成本 | ~0.0029 SOL | ~0.022 SOL |
| 计算单元 | ~17,000 | ~205,000 |
| 强制执行版税 | 是 | 否 |
| 插件系统 | 是 | 否 |
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import {
mplCore,
create,
fetchAsset
} from '@metaplex-foundation/mpl-core';
import {
generateSigner,
keypairIdentity
} from '@metaplex-foundation/umi';
import { irysUploader } from '@metaplex-foundation/umi-uploader-irys';
// 设置
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(mplCore())
.use(irysUploader());
// 上传元数据
const metadata = {
name: 'My Core NFT',
description: 'A next-gen NFT on Solana',
image: 'https://arweave.net/your-image',
attributes: [
{ trait_type: 'Background', value: 'Blue' },
{ trait_type: 'Rarity', value: 'Legendary' }
]
};
const metadataUri = await umi.uploader.uploadJson(metadata);
// 创建 NFT
const asset = generateSigner(umi);
await create(umi, {
asset,
name: 'My Core NFT',
uri: metadataUri,
}).sendAndConfirm(umi);
console.log('Asset created:', asset.publicKey);
// 获取资产
const fetchedAsset = await fetchAsset(umi, asset.publicKey);
console.log('Asset data:', fetchedAsset);
import {
create,
ruleSet,
plugin,
} from '@metaplex-foundation/mpl-core';
// 创建并强制执行版税
await create(umi, {
asset,
name: 'Royalty Enforced NFT',
uri: metadataUri,
plugins: [
{
type: 'Royalties',
basisPoints: 500, // 5%
creators: [
{ address: creatorAddress, percentage: 100 }
],
ruleSet: ruleSet('None'), // 或 'ProgramAllowList', 'ProgramDenyList'
},
{
type: 'FreezeDelegate',
frozen: false,
authority: { type: 'Owner' },
},
{
type: 'TransferDelegate',
authority: { type: 'Owner' },
},
],
}).sendAndConfirm(umi);
import {
createCollection,
create,
fetchCollection,
} from '@metaplex-foundation/mpl-core';
// 创建合集
const collection = generateSigner(umi);
await createCollection(umi, {
collection,
name: 'My Collection',
uri: collectionUri,
}).sendAndConfirm(umi);
// 在合集中创建资产
const asset = generateSigner(umi);
await create(umi, {
asset,
name: 'Collection Item #1',
uri: assetUri,
collection: collection.publicKey,
}).sendAndConfirm(umi);
import { transfer, burn } from '@metaplex-foundation/mpl-core';
// 转移
await transfer(umi, {
asset: assetPublicKey,
newOwner: recipientPublicKey,
}).sendAndConfirm(umi);
// 销毁
await burn(umi, {
asset: assetPublicKey,
}).sendAndConfirm(umi);
使用程序派生地址的原始 Solana NFT 标准。
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import {
mplTokenMetadata,
createNft,
fetchDigitalAsset,
} from '@metaplex-foundation/mpl-token-metadata';
import { generateSigner, percentAmount } from '@metaplex-foundation/umi';
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(mplTokenMetadata());
// 创建 NFT
const mint = generateSigner(umi);
await createNft(umi, {
mint,
name: 'My NFT',
symbol: 'MNFT',
uri: 'https://arweave.net/metadata.json',
sellerFeeBasisPoints: percentAmount(5.5), // 5.5% 版税
creators: [
{ address: umi.identity.publicKey, share: 100, verified: true }
],
}).sendAndConfirm(umi);
// 获取 NFT
const asset = await fetchDigitalAsset(umi, mint.publicKey);
console.log(asset);
import {
createProgrammableNft,
TokenStandard,
} from '@metaplex-foundation/mpl-token-metadata';
// pNFT 强制执行版税
const mint = generateSigner(umi);
await createProgrammableNft(umi, {
mint,
name: 'My pNFT',
uri: metadataUri,
sellerFeeBasisPoints: percentAmount(10), // 10% 版税
ruleSet: ruleSetPublicKey, // 可选:自定义规则
}).sendAndConfirm(umi);
import {
createFungible,
mintV1,
TokenStandard,
} from '@metaplex-foundation/mpl-token-metadata';
// 创建可替代代币
const mint = generateSigner(umi);
await createFungible(umi, {
mint,
name: 'My Token',
symbol: 'MTK',
uri: 'https://arweave.net/token-metadata.json',
sellerFeeBasisPoints: percentAmount(0),
decimals: 9,
}).sendAndConfirm(umi);
// 铸造代币
await mintV1(umi, {
mint: mint.publicKey,
amount: 1_000_000_000n, // 1 个代币,9 位小数
tokenOwner: recipientPublicKey,
tokenStandard: TokenStandard.Fungible,
}).sendAndConfirm(umi);
import { updateV1 } from '@metaplex-foundation/mpl-token-metadata';
await updateV1(umi, {
mint: mintPublicKey,
data: {
name: 'Updated Name',
symbol: 'UPDT',
uri: 'https://arweave.net/new-metadata.json',
sellerFeeBasisPoints: 500,
creators: null, // 保留现有
},
}).sendAndConfirm(umi);
使用 Merkle 树压缩技术以极低成本创建数十亿个 NFT。
| 合集大小 | Bubblegum 成本 | Token Metadata 成本 |
|---|---|---|
| 10,000 | ~0.27 SOL | ~220 SOL |
| 1,000,000 | ~50 SOL | ~22,000 SOL |
| 1,000,000,000 | ~5,007 SOL | ~22,000,000 SOL |
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import {
mplBubblegum,
createTree,
} from '@metaplex-foundation/mpl-bubblegum';
import { generateSigner } from '@metaplex-foundation/umi';
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(mplBubblegum());
// 创建树(最大深度决定容量)
// maxDepth 14 = 16,384 个 NFT, maxDepth 20 = 1,048,576 个 NFT
const merkleTree = generateSigner(umi);
await createTree(umi, {
merkleTree,
maxDepth: 14,
maxBufferSize: 64,
}).sendAndConfirm(umi);
console.log('Tree created:', merkleTree.publicKey);
import { mintV1 } from '@metaplex-foundation/mpl-bubblegum';
await mintV1(umi, {
leafOwner: recipientPublicKey,
merkleTree: merkleTreePublicKey,
metadata: {
name: 'Compressed NFT #1',
symbol: 'CNFT',
uri: 'https://arweave.net/metadata.json',
sellerFeeBasisPoints: 500,
collection: { key: collectionMint, verified: false },
creators: [
{ address: umi.identity.publicKey, share: 100, verified: true }
],
},
}).sendAndConfirm(umi);
import { mintToCollectionV1 } from '@metaplex-foundation/mpl-bubblegum';
await mintToCollectionV1(umi, {
leafOwner: recipientPublicKey,
merkleTree: merkleTreePublicKey,
collectionMint: collectionMintPublicKey,
metadata: {
name: 'Collection cNFT #1',
symbol: 'CCNFT',
uri: metadataUri,
sellerFeeBasisPoints: 500,
creators: [
{ address: umi.identity.publicKey, share: 100, verified: true }
],
},
}).sendAndConfirm(umi);
import { transfer } from '@metaplex-foundation/mpl-bubblegum';
import { getAssetWithProof } from '@metaplex-foundation/mpl-bubblegum';
// 从 DAS API 获取带证明的资产
const assetWithProof = await getAssetWithProof(umi, assetId);
await transfer(umi, {
...assetWithProof,
leafOwner: currentOwner,
newLeafOwner: newOwner,
}).sendAndConfirm(umi);
import { decompressV1 } from '@metaplex-foundation/mpl-bubblegum';
// 解压会创建链上的 Token Metadata NFT
await decompressV1(umi, {
...assetWithProof,
mint: mintSigner,
}).sendAndConfirm(umi);
用于公平合集发行的领先 NFT 铸造系统。
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import {
mplCandyMachine,
create,
addConfigLines,
} from '@metaplex-foundation/mpl-candy-machine';
import { generateSigner, some, sol, dateTime } from '@metaplex-foundation/umi';
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(mplCandyMachine());
// 创建 candy machine
const candyMachine = generateSigner(umi);
const collection = generateSigner(umi);
await create(umi, {
candyMachine,
collection: collection.publicKey,
collectionUpdateAuthority: umi.identity,
itemsAvailable: 1000,
sellerFeeBasisPoints: percentAmount(5),
creators: [
{ address: umi.identity.publicKey, percentageShare: 100, verified: true }
],
configLineSettings: some({
prefixName: 'My NFT #',
nameLength: 4,
prefixUri: 'https://arweave.net/',
uriLength: 43,
isSequential: false,
}),
guards: {
botTax: some({ lamports: sol(0.01), lastInstruction: true }),
solPayment: some({ lamports: sol(0.5), destination: treasury }),
startDate: some({ date: dateTime('2024-01-01T00:00:00Z') }),
mintLimit: some({ id: 1, limit: 3 }),
},
}).sendAndConfirm(umi);
await addConfigLines(umi, {
candyMachine: candyMachine.publicKey,
index: 0,
configLines: [
{ name: '0001', uri: 'abc123...' },
{ name: '0002', uri: 'def456...' },
{ name: '0003', uri: 'ghi789...' },
],
}).sendAndConfirm(umi);
import {
mintV1,
fetchCandyMachine,
fetchCandyGuard,
} from '@metaplex-foundation/mpl-candy-machine';
const candyMachine = await fetchCandyMachine(umi, candyMachinePublicKey);
const candyGuard = await fetchCandyGuard(umi, candyMachine.mintAuthority);
const nftMint = generateSigner(umi);
await mintV1(umi, {
candyMachine: candyMachine.publicKey,
candyGuard: candyGuard.publicKey,
nftMint,
collectionMint: candyMachine.collectionMint,
collectionUpdateAuthority: candyMachine.authority,
mintArgs: {
solPayment: some({ destination: treasury }),
mintLimit: some({ id: 1 }),
},
}).sendAndConfirm(umi);
| 防护机制 | 描述 |
|---|---|
solPayment | 收取 SOL 铸造费用 |
tokenPayment | 收取 SPL 代币费用 |
nftPayment | 要求 NFT 支付 |
startDate | 设置铸造开始时间 |
endDate | 设置铸造结束时间 |
mintLimit | 限制每个钱包的铸造数量 |
allowList | Merkle 树白名单 |
tokenGate | 要求持有代币 |
nftGate | 要求持有 NFT |
botTax | 惩罚失败的铸造尝试 |
gatekeeper | 验证码验证 |
freezeSolPayment | 冻结 SOL 直到条件满足 |
freezeTokenPayment | 冻结代币直到条件满足 |
addressGate | 限制特定地址 |
allocation | 限制每组的总铸造量 |
redeemedAmount | 在 X 次铸造后停止 |
thirdPartySigner | 要求额外签名 |
token2022Payment | Token-2022 支付 |
nftBurn | 销毁 NFT 以铸造 |
tokenBurn | 销毁代币以铸造 |
programGate | 限制调用程序 |
Solana 上的公平代币生成事件。
| 类型 | 描述 | 价格发现 |
|---|---|---|
| 预售 | 固定价格的代币销售 | 预先确定 |
| 启动池 | 存款决定价格 | 结束时 |
| 统一价格拍卖 | 竞价机制 | 清算价格 |
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import {
mplGenesis,
createGenesis,
addBucket,
finalize,
} from '@metaplex-foundation/mpl-genesis';
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(mplGenesis());
// 创建 genesis 账户
const genesis = generateSigner(umi);
await createGenesis(umi, {
genesis,
name: 'My Token',
symbol: 'MTK',
uri: 'https://arweave.net/token-metadata.json',
decimals: 9,
totalSupply: 1_000_000_000n * 10n ** 9n, // 10 亿个代币
}).sendAndConfirm(umi);
// 添加预售桶
await addBucket(umi, {
genesis: genesis.publicKey,
bucket: {
type: 'Presale',
price: sol(0.001), // 每个代币 0.001 SOL
maxTokens: 100_000_000n * 10n ** 9n, // 1 亿个代币
startTime: dateTime('2024-06-01T00:00:00Z'),
endTime: dateTime('2024-06-07T00:00:00Z'),
},
}).sendAndConfirm(umi);
// 最终确定(锁定配置)
await finalize(umi, {
genesis: genesis.publicKey,
}).sendAndConfirm(umi);
import { deposit, claim } from '@metaplex-foundation/mpl-genesis';
// 存入 SOL
await deposit(umi, {
genesis: genesisPublicKey,
amount: sol(10), // 10 SOL
}).sendAndConfirm(umi);
// 发行结束后,领取代币
await claim(umi, {
genesis: genesisPublicKey,
}).sendAndConfirm(umi);
在可替代代币和 NFT 之间交换。
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import {
mplHybrid,
createEscrow,
swapNftToToken,
swapTokenToNft,
} from '@metaplex-foundation/mpl-hybrid';
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(mplHybrid());
// 创建用于交换的托管账户
await createEscrow(umi, {
escrow: escrowSigner,
collection: collectionPublicKey,
token: tokenMint,
feeWallet: feeWallet,
name: 'My Hybrid Collection',
uri: 'https://arweave.net/escrow-metadata.json',
max: 10000n,
min: 0n,
amount: 1000n, // 每个 NFT 的代币数量
feeAmount: sol(0.005),
path: 0,
}).sendAndConfirm(umi);
// 用 NFT 交换代币
await swapNftToToken(umi, {
escrow: escrowPublicKey,
asset: nftPublicKey,
}).sendAndConfirm(umi);
// 用代币交换 NFT
await swapTokenToNft(umi, {
escrow: escrowPublicKey,
}).sendAndConfirm(umi);
直接在链上存储数据(最高 10MB)。
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import {
mplInscription,
initializeFromMint,
writeData,
fetchInscription,
} from '@metaplex-foundation/mpl-inscription';
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(mplInscription());
// 为现有 NFT 初始化 inscription
const inscriptionAccount = findInscriptionPda(umi, { mint: nftMint });
await initializeFromMint(umi, {
mintAccount: nftMint,
}).sendAndConfirm(umi);
// 写入 JSON 元数据
await writeData(umi, {
inscriptionAccount: inscriptionAccount[0],
value: Buffer.from(JSON.stringify({
name: 'On-chain NFT',
description: 'Fully on-chain!',
})),
offset: 0,
}).sendAndConfirm(umi);
// 分块写入图像
const imageBytes = fs.readFileSync('./image.png');
const chunkSize = 800;
for (let i = 0; i < imageBytes.length; i += chunkSize) {
const chunk = imageBytes.slice(i, i + chunkSize);
await writeData(umi, {
inscriptionAccount: associatedInscriptionAccount,
value: Buffer.from(chunk),
offset: i,
}).sendAndConfirm(umi);
}
// 通过 Inscription Gateway 访问
const gatewayUrl = `https://igw.metaplex.com/mainnet/${inscriptionAccount[0]}`;
用于跨所有 Metaplex 标准获取数字资产的统一 API。
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import { dasApi } from '@metaplex-foundation/digital-asset-standard-api';
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(dasApi());
// 获取单个资产
const asset = await umi.rpc.getAsset(assetId);
// 按所有者获取资产
const assets = await umi.rpc.getAssetsByOwner({
owner: ownerPublicKey,
limit: 100,
});
// 按合集获取资产
const collectionAssets = await umi.rpc.getAssetsByGroup({
groupKey: 'collection',
groupValue: collectionPublicKey,
limit: 1000,
});
// 搜索资产
const searchResults = await umi.rpc.searchAssets({
owner: ownerPublicKey,
burnt: false,
compressed: true,
});
// 获取资产证明(用于压缩 NFT)
const proof = await umi.rpc.getAssetProof(assetId);
| 程序 | 操作 | 费用 |
|---|---|---|
| Core | 创建 | 0.0015 SOL |
| Core | 执行 | 0.00004872 SOL |
| Token Metadata | 创建 | 0.01 SOL |
| Bubblegum v2 | 创建 | 0.00009 SOL |
| Bubblegum v2 | 转移 | 0.000006 SOL |
| Bubblegum v1 | 创建 | 免费 |
| Genesis | 启动池 | 2% 存款/取款,5% 毕业费 |
| Genesis | 预售 | 2% 存款,5% 毕业费 |
| MPL-Hybrid | 交换 | 0.005 SOL |
| 用例 | 推荐 |
|---|---|
| 新的 NFT 合集 | Core |
| 大型合集(10K+) | Bubblegum |
| 带版税的 PFP | Core 或 pNFT |
| 游戏物品 | Core(插件) |
| 现有生态系统 | Token Metadata |
| 代币发行 | Genesis |
| 混合代币/NFT | MPL-Hybrid |
metaplex/
├── SKILL.md # 此文件
├── resources/
│ ├── program-ids.md # 所有程序地址
│ ├── sdk-packages.md # NPM 包参考
│ └── protocol-fees.md # 费用表
├── examples/
│ ├── core/
│ │ └── create-nft.ts # Core NFT 示例
│ ├── token-metadata/
│ │ └── create-nft.ts # Token Metadata 示例
│ ├── bubblegum/
│ │ └── compressed-nfts.ts # cNFT 示例
│ ├── candy-machine/
│ │ └── launch-collection.ts # Candy Machine 示例
│ └── genesis/
│ └── token-launch.ts # Genesis TGE 示例
├── templates/
│ └── metaplex-client.ts # 即用型客户端
└── docs/
└── troubleshooting.md # 常见问题
每周安装
56
仓库
GitHub 星标
68
首次出现
2026年1月24日
安全审计
安装于
codex45
gemini-cli45
opencode44
cursor43
github-copilot42
claude-code41
A comprehensive guide for building NFTs, digital assets, and token launches on Solana using the Metaplex Protocol - the industry standard powering 99% of Solana NFTs and tokens.
Metaplex is the leading tokenization protocol on Solana, providing smart contracts and tools for creating, selling, and managing digital assets. From simple NFTs to compressed collections of billions, from fair token launches to hybrid token/NFT systems, Metaplex provides the infrastructure.
Metaplex provides multiple products for different use cases:
| Product | Description | Cost per Mint |
|---|---|---|
| Core | Next-gen single-account NFT standard | ~0.0029 SOL |
| Token Metadata | Original NFT standard with PDAs | ~0.022 SOL |
| Bubblegum v2 | Compressed NFTs (cNFTs) | ~0.00009 SOL |
| Product | Description |
|---|---|
| Candy Machine | NFT collection minting with guards |
| Core Candy Machine | Candy Machine for Core assets |
| Genesis | Token Generation Event (TGE) platform |
| Product | Description |
|---|---|
| MPL-Hybrid | Swap between fungible and non-fungible |
| Inscriptions | On-chain data storage (up to 10MB) |
| DAS API | Unified API for fetching digital assets |
| Umi | JavaScript framework for Solana clients |
| Program | Address |
|---|---|
| MPL Core | CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d |
| Token Metadata | metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s |
| Bubblegum | BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY |
| Candy Machine V3 | CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR |
| Candy Guard | Guard1JwRhJkVH6XZhzoYxeBVQe872VH6QggF4BWmS9g |
| Program | Address |
|---|---|
| SPL Token | TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA |
| Token 2022 | TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb |
| Associated Token | ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL |
| Account Compression | cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK |
# Core NFTs (Recommended for new projects)
npm install @metaplex-foundation/mpl-core \
@metaplex-foundation/umi \
@metaplex-foundation/umi-bundle-defaults
# Token Metadata NFTs
npm install @metaplex-foundation/mpl-token-metadata \
@metaplex-foundation/umi \
@metaplex-foundation/umi-bundle-defaults
# Compressed NFTs (Bubblegum)
npm install @metaplex-foundation/mpl-bubblegum \
@metaplex-foundation/umi \
@metaplex-foundation/umi-bundle-defaults
# Candy Machine
npm install @metaplex-foundation/mpl-candy-machine \
@metaplex-foundation/umi \
@metaplex-foundation/umi-bundle-defaults
# Core Candy Machine
npm install @metaplex-foundation/mpl-core-candy-machine \
@metaplex-foundation/umi \
@metaplex-foundation/umi-bundle-defaults
# Genesis (Token Launches)
npm install @metaplex-foundation/mpl-genesis \
@metaplex-foundation/umi \
@metaplex-foundation/umi-bundle-defaults
# File uploads (Arweave via Irys)
npm install @metaplex-foundation/umi-uploader-irys
All Metaplex SDKs use Umi, a modular Solana framework:
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import { mplCore } from '@metaplex-foundation/mpl-core';
import {
keypairIdentity,
generateSigner
} from '@metaplex-foundation/umi';
// Create Umi instance
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(mplCore());
// Option 1: Use generated keypair
const signer = generateSigner(umi);
umi.use(keypairIdentity(signer));
// Option 2: Use existing keypair
import { createSignerFromKeypair } from '@metaplex-foundation/umi';
const keypair = umi.eddsa.createKeypairFromSecretKey(secretKeyBytes);
const signer = createSignerFromKeypair(umi, keypair);
umi.use(keypairIdentity(signer));
// Option 3: Use wallet adapter (browser)
import { walletAdapterIdentity } from '@metaplex-foundation/umi-signer-wallet-adapters';
umi.use(walletAdapterIdentity(wallet));
The next-generation NFT standard with single-account design, lower costs, and built-in plugins.
| Feature | Core | Token Metadata |
|---|---|---|
| Accounts per NFT | 1 | 4+ |
| Mint Cost | ~0.0029 SOL | ~0.022 SOL |
| Compute Units | ~17,000 | ~205,000 |
| Enforced Royalties | Yes | No |
| Plugin System | Yes | No |
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import {
mplCore,
create,
fetchAsset
} from '@metaplex-foundation/mpl-core';
import {
generateSigner,
keypairIdentity
} from '@metaplex-foundation/umi';
import { irysUploader } from '@metaplex-foundation/umi-uploader-irys';
// Setup
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(mplCore())
.use(irysUploader());
// Upload metadata
const metadata = {
name: 'My Core NFT',
description: 'A next-gen NFT on Solana',
image: 'https://arweave.net/your-image',
attributes: [
{ trait_type: 'Background', value: 'Blue' },
{ trait_type: 'Rarity', value: 'Legendary' }
]
};
const metadataUri = await umi.uploader.uploadJson(metadata);
// Create NFT
const asset = generateSigner(umi);
await create(umi, {
asset,
name: 'My Core NFT',
uri: metadataUri,
}).sendAndConfirm(umi);
console.log('Asset created:', asset.publicKey);
// Fetch the asset
const fetchedAsset = await fetchAsset(umi, asset.publicKey);
console.log('Asset data:', fetchedAsset);
import {
create,
ruleSet,
plugin,
} from '@metaplex-foundation/mpl-core';
// Create with royalty enforcement
await create(umi, {
asset,
name: 'Royalty Enforced NFT',
uri: metadataUri,
plugins: [
{
type: 'Royalties',
basisPoints: 500, // 5%
creators: [
{ address: creatorAddress, percentage: 100 }
],
ruleSet: ruleSet('None'), // or 'ProgramAllowList', 'ProgramDenyList'
},
{
type: 'FreezeDelegate',
frozen: false,
authority: { type: 'Owner' },
},
{
type: 'TransferDelegate',
authority: { type: 'Owner' },
},
],
}).sendAndConfirm(umi);
import {
createCollection,
create,
fetchCollection,
} from '@metaplex-foundation/mpl-core';
// Create collection
const collection = generateSigner(umi);
await createCollection(umi, {
collection,
name: 'My Collection',
uri: collectionUri,
}).sendAndConfirm(umi);
// Create asset in collection
const asset = generateSigner(umi);
await create(umi, {
asset,
name: 'Collection Item #1',
uri: assetUri,
collection: collection.publicKey,
}).sendAndConfirm(umi);
import { transfer, burn } from '@metaplex-foundation/mpl-core';
// Transfer
await transfer(umi, {
asset: assetPublicKey,
newOwner: recipientPublicKey,
}).sendAndConfirm(umi);
// Burn
await burn(umi, {
asset: assetPublicKey,
}).sendAndConfirm(umi);
The original Solana NFT standard using Program Derived Addresses (PDAs).
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import {
mplTokenMetadata,
createNft,
fetchDigitalAsset,
} from '@metaplex-foundation/mpl-token-metadata';
import { generateSigner, percentAmount } from '@metaplex-foundation/umi';
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(mplTokenMetadata());
// Create NFT
const mint = generateSigner(umi);
await createNft(umi, {
mint,
name: 'My NFT',
symbol: 'MNFT',
uri: 'https://arweave.net/metadata.json',
sellerFeeBasisPoints: percentAmount(5.5), // 5.5% royalty
creators: [
{ address: umi.identity.publicKey, share: 100, verified: true }
],
}).sendAndConfirm(umi);
// Fetch NFT
const asset = await fetchDigitalAsset(umi, mint.publicKey);
console.log(asset);
import {
createProgrammableNft,
TokenStandard,
} from '@metaplex-foundation/mpl-token-metadata';
// pNFTs have enforced royalties
const mint = generateSigner(umi);
await createProgrammableNft(umi, {
mint,
name: 'My pNFT',
uri: metadataUri,
sellerFeeBasisPoints: percentAmount(10), // 10% royalty
ruleSet: ruleSetPublicKey, // Optional: custom rules
}).sendAndConfirm(umi);
import {
createFungible,
mintV1,
TokenStandard,
} from '@metaplex-foundation/mpl-token-metadata';
// Create fungible token
const mint = generateSigner(umi);
await createFungible(umi, {
mint,
name: 'My Token',
symbol: 'MTK',
uri: 'https://arweave.net/token-metadata.json',
sellerFeeBasisPoints: percentAmount(0),
decimals: 9,
}).sendAndConfirm(umi);
// Mint tokens
await mintV1(umi, {
mint: mint.publicKey,
amount: 1_000_000_000n, // 1 token with 9 decimals
tokenOwner: recipientPublicKey,
tokenStandard: TokenStandard.Fungible,
}).sendAndConfirm(umi);
import { updateV1 } from '@metaplex-foundation/mpl-token-metadata';
await updateV1(umi, {
mint: mintPublicKey,
data: {
name: 'Updated Name',
symbol: 'UPDT',
uri: 'https://arweave.net/new-metadata.json',
sellerFeeBasisPoints: 500,
creators: null, // Keep existing
},
}).sendAndConfirm(umi);
Create billions of NFTs at minimal cost using Merkle tree compression.
| Collection Size | Bubblegum Cost | Token Metadata Cost |
|---|---|---|
| 10,000 | ~0.27 SOL | ~220 SOL |
| 1,000,000 | ~50 SOL | ~22,000 SOL |
| 1,000,000,000 | ~5,007 SOL | ~22,000,000 SOL |
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import {
mplBubblegum,
createTree,
} from '@metaplex-foundation/mpl-bubblegum';
import { generateSigner } from '@metaplex-foundation/umi';
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(mplBubblegum());
// Create tree (max depth determines capacity)
// maxDepth 14 = 16,384 NFTs, maxDepth 20 = 1,048,576 NFTs
const merkleTree = generateSigner(umi);
await createTree(umi, {
merkleTree,
maxDepth: 14,
maxBufferSize: 64,
}).sendAndConfirm(umi);
console.log('Tree created:', merkleTree.publicKey);
import { mintV1 } from '@metaplex-foundation/mpl-bubblegum';
await mintV1(umi, {
leafOwner: recipientPublicKey,
merkleTree: merkleTreePublicKey,
metadata: {
name: 'Compressed NFT #1',
symbol: 'CNFT',
uri: 'https://arweave.net/metadata.json',
sellerFeeBasisPoints: 500,
collection: { key: collectionMint, verified: false },
creators: [
{ address: umi.identity.publicKey, share: 100, verified: true }
],
},
}).sendAndConfirm(umi);
import { mintToCollectionV1 } from '@metaplex-foundation/mpl-bubblegum';
await mintToCollectionV1(umi, {
leafOwner: recipientPublicKey,
merkleTree: merkleTreePublicKey,
collectionMint: collectionMintPublicKey,
metadata: {
name: 'Collection cNFT #1',
symbol: 'CCNFT',
uri: metadataUri,
sellerFeeBasisPoints: 500,
creators: [
{ address: umi.identity.publicKey, share: 100, verified: true }
],
},
}).sendAndConfirm(umi);
import { transfer } from '@metaplex-foundation/mpl-bubblegum';
import { getAssetWithProof } from '@metaplex-foundation/mpl-bubblegum';
// Get asset with proof from DAS API
const assetWithProof = await getAssetWithProof(umi, assetId);
await transfer(umi, {
...assetWithProof,
leafOwner: currentOwner,
newLeafOwner: newOwner,
}).sendAndConfirm(umi);
import { decompressV1 } from '@metaplex-foundation/mpl-bubblegum';
// Decompress creates on-chain Token Metadata NFT
await decompressV1(umi, {
...assetWithProof,
mint: mintSigner,
}).sendAndConfirm(umi);
The leading NFT minting system for fair collection launches.
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import {
mplCandyMachine,
create,
addConfigLines,
} from '@metaplex-foundation/mpl-candy-machine';
import { generateSigner, some, sol, dateTime } from '@metaplex-foundation/umi';
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(mplCandyMachine());
// Create candy machine
const candyMachine = generateSigner(umi);
const collection = generateSigner(umi);
await create(umi, {
candyMachine,
collection: collection.publicKey,
collectionUpdateAuthority: umi.identity,
itemsAvailable: 1000,
sellerFeeBasisPoints: percentAmount(5),
creators: [
{ address: umi.identity.publicKey, percentageShare: 100, verified: true }
],
configLineSettings: some({
prefixName: 'My NFT #',
nameLength: 4,
prefixUri: 'https://arweave.net/',
uriLength: 43,
isSequential: false,
}),
guards: {
botTax: some({ lamports: sol(0.01), lastInstruction: true }),
solPayment: some({ lamports: sol(0.5), destination: treasury }),
startDate: some({ date: dateTime('2024-01-01T00:00:00Z') }),
mintLimit: some({ id: 1, limit: 3 }),
},
}).sendAndConfirm(umi);
await addConfigLines(umi, {
candyMachine: candyMachine.publicKey,
index: 0,
configLines: [
{ name: '0001', uri: 'abc123...' },
{ name: '0002', uri: 'def456...' },
{ name: '0003', uri: 'ghi789...' },
],
}).sendAndConfirm(umi);
import {
mintV1,
fetchCandyMachine,
fetchCandyGuard,
} from '@metaplex-foundation/mpl-candy-machine';
const candyMachine = await fetchCandyMachine(umi, candyMachinePublicKey);
const candyGuard = await fetchCandyGuard(umi, candyMachine.mintAuthority);
const nftMint = generateSigner(umi);
await mintV1(umi, {
candyMachine: candyMachine.publicKey,
candyGuard: candyGuard.publicKey,
nftMint,
collectionMint: candyMachine.collectionMint,
collectionUpdateAuthority: candyMachine.authority,
mintArgs: {
solPayment: some({ destination: treasury }),
mintLimit: some({ id: 1 }),
},
}).sendAndConfirm(umi);
| Guard | Description |
|---|---|
solPayment | Charge SOL for minting |
tokenPayment | Charge SPL tokens |
nftPayment | Require NFT payment |
startDate | Set mint start time |
endDate | Set mint end time |
mintLimit | Limit mints per wallet |
Fair token generation events (TGEs) on Solana.
| Type | Description | Price Discovery |
|---|---|---|
| Presale | Fixed-price token sale | Predetermined |
| Launch Pool | Deposits determine price | At close |
| Uniform Price Auction | Bidding mechanism | Clearing price |
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import {
mplGenesis,
createGenesis,
addBucket,
finalize,
} from '@metaplex-foundation/mpl-genesis';
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(mplGenesis());
// Create genesis account
const genesis = generateSigner(umi);
await createGenesis(umi, {
genesis,
name: 'My Token',
symbol: 'MTK',
uri: 'https://arweave.net/token-metadata.json',
decimals: 9,
totalSupply: 1_000_000_000n * 10n ** 9n, // 1 billion tokens
}).sendAndConfirm(umi);
// Add presale bucket
await addBucket(umi, {
genesis: genesis.publicKey,
bucket: {
type: 'Presale',
price: sol(0.001), // 0.001 SOL per token
maxTokens: 100_000_000n * 10n ** 9n, // 100M tokens
startTime: dateTime('2024-06-01T00:00:00Z'),
endTime: dateTime('2024-06-07T00:00:00Z'),
},
}).sendAndConfirm(umi);
// Finalize (locks configuration)
await finalize(umi, {
genesis: genesis.publicKey,
}).sendAndConfirm(umi);
import { deposit, claim } from '@metaplex-foundation/mpl-genesis';
// Deposit SOL
await deposit(umi, {
genesis: genesisPublicKey,
amount: sol(10), // 10 SOL
}).sendAndConfirm(umi);
// After launch ends, claim tokens
await claim(umi, {
genesis: genesisPublicKey,
}).sendAndConfirm(umi);
Swap between fungible tokens and NFTs.
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import {
mplHybrid,
createEscrow,
swapNftToToken,
swapTokenToNft,
} from '@metaplex-foundation/mpl-hybrid';
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(mplHybrid());
// Create escrow for swapping
await createEscrow(umi, {
escrow: escrowSigner,
collection: collectionPublicKey,
token: tokenMint,
feeWallet: feeWallet,
name: 'My Hybrid Collection',
uri: 'https://arweave.net/escrow-metadata.json',
max: 10000n,
min: 0n,
amount: 1000n, // Tokens per NFT
feeAmount: sol(0.005),
path: 0,
}).sendAndConfirm(umi);
// Swap NFT for tokens
await swapNftToToken(umi, {
escrow: escrowPublicKey,
asset: nftPublicKey,
}).sendAndConfirm(umi);
// Swap tokens for NFT
await swapTokenToNft(umi, {
escrow: escrowPublicKey,
}).sendAndConfirm(umi);
Store data directly on-chain (up to 10MB).
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import {
mplInscription,
initializeFromMint,
writeData,
fetchInscription,
} from '@metaplex-foundation/mpl-inscription';
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(mplInscription());
// Initialize inscription for existing NFT
const inscriptionAccount = findInscriptionPda(umi, { mint: nftMint });
await initializeFromMint(umi, {
mintAccount: nftMint,
}).sendAndConfirm(umi);
// Write JSON metadata
await writeData(umi, {
inscriptionAccount: inscriptionAccount[0],
value: Buffer.from(JSON.stringify({
name: 'On-chain NFT',
description: 'Fully on-chain!',
})),
offset: 0,
}).sendAndConfirm(umi);
// Write image in chunks
const imageBytes = fs.readFileSync('./image.png');
const chunkSize = 800;
for (let i = 0; i < imageBytes.length; i += chunkSize) {
const chunk = imageBytes.slice(i, i + chunkSize);
await writeData(umi, {
inscriptionAccount: associatedInscriptionAccount,
value: Buffer.from(chunk),
offset: i,
}).sendAndConfirm(umi);
}
// Access via Inscription Gateway
const gatewayUrl = `https://igw.metaplex.com/mainnet/${inscriptionAccount[0]}`;
Unified API for fetching digital assets across all Metaplex standards.
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import { dasApi } from '@metaplex-foundation/digital-asset-standard-api';
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(dasApi());
// Get single asset
const asset = await umi.rpc.getAsset(assetId);
// Get assets by owner
const assets = await umi.rpc.getAssetsByOwner({
owner: ownerPublicKey,
limit: 100,
});
// Get assets by collection
const collectionAssets = await umi.rpc.getAssetsByGroup({
groupKey: 'collection',
groupValue: collectionPublicKey,
limit: 1000,
});
// Search assets
const searchResults = await umi.rpc.searchAssets({
owner: ownerPublicKey,
burnt: false,
compressed: true,
});
// Get asset proof (for compressed NFTs)
const proof = await umi.rpc.getAssetProof(assetId);
| Program | Operation | Fee |
|---|---|---|
| Core | Create | 0.0015 SOL |
| Core | Execute | 0.00004872 SOL |
| Token Metadata | Create | 0.01 SOL |
| Bubblegum v2 | Create | 0.00009 SOL |
| Bubblegum v2 | Transfer | 0.000006 SOL |
| Bubblegum v1 | Create | Free |
| Genesis | Launch Pool | 2% deposit/withdraw, 5% graduation |
| Genesis | Presale | 2% deposit, 5% graduation |
| Use Case | Recommended |
|---|---|
| New NFT collection | Core |
| Large collection (10K+) | Bubblegum |
| PFP with royalties | Core or pNFT |
| Gaming items | Core (plugins) |
| Existing ecosystem | Token Metadata |
| Token launch | Genesis |
| Hybrid token/NFT | MPL-Hybrid |
metaplex/
├── SKILL.md # This file
├── resources/
│ ├── program-ids.md # All program addresses
│ ├── sdk-packages.md # NPM packages reference
│ └── protocol-fees.md # Fee schedule
├── examples/
│ ├── core/
│ │ └── create-nft.ts # Core NFT examples
│ ├── token-metadata/
│ │ └── create-nft.ts # Token Metadata examples
│ ├── bubblegum/
│ │ └── compressed-nfts.ts # cNFT examples
│ ├── candy-machine/
│ │ └── launch-collection.ts # Candy Machine examples
│ └── genesis/
│ └── token-launch.ts # Genesis TGE examples
├── templates/
│ └── metaplex-client.ts # Ready-to-use client
└── docs/
└── troubleshooting.md # Common issues
Weekly Installs
56
Repository
GitHub Stars
68
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
codex45
gemini-cli45
opencode44
cursor43
github-copilot42
claude-code41
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
125,600 周安装
| Core Candy Machine | CMACYFENjoBMHzapRXyo1JZkVS6EtaDDzkjMrmQLvr4J |
| Core Candy Guard | CMAGAKJ67e9hRZgfC5SFTbZH8MgEmtqazKXjmkaJjWTJ |
| MPL Hybrid | MPL4o4wMzndgh8T1NVDxELQCj5UQfYTYEkabX3wNKtb |
| Inscription | 1NSCRfGeyo7wPUazGbaPBUsTM49e1k2aXewHGARfzSo |
allowList |
| Merkle tree allowlist |
tokenGate | Require token ownership |
nftGate | Require NFT ownership |
botTax | Penalize failed mints |
gatekeeper | Captcha verification |
freezeSolPayment | Freeze SOL until conditions met |
freezeTokenPayment | Freeze tokens until conditions met |
addressGate | Restrict to specific addresses |
allocation | Limit total mints per group |
redeemedAmount | Stop after X mints |
thirdPartySigner | Require additional signature |
token2022Payment | Token-2022 payment |
nftBurn | Burn NFT to mint |
tokenBurn | Burn tokens to mint |
programGate | Restrict calling programs |
| MPL-Hybrid | Swap | 0.005 SOL |