功能
管理集合
Last updated February 24, 2026
Summary
Managing collections for compressed NFTs uses the setCollectionV2 instruction to add, change, or remove MPL-Core collections on existing cNFTs. This page covers setting and removing collections after minting.
- Set an MPL-Core collection on an existing cNFT using setCollectionV2
- Remove a collection from a cNFT
- Change between collections (both authorities must sign)
- Collections must have the BubblegumV2 plugin enabled
cNFT可以在铸造时或之后添加到MPL-Core集合。
如果您不熟悉NFT相关的集合概念,它们是特殊的非压缩NFT,可用于将其他NFT分组在一起。集合的数据因此用于描述整个集合的名称和品牌。自Bubblegum V2以来,它还允许在集合级别提供额外功能,例如允许委托人在无需叶子所有者交互的情况下冻结和解冻cNFT。您可以在此处阅读更多关于MPL-Core集合的信息。 请注意,可以通过使用MintV2指令此处记录直接将压缩NFT铸造到集合中。也就是说,如果您已经铸造了没有集合的cNFT,让我们看看如何在该cNFT上设置集合。与使用具有"已验证"布尔值的Metaplex Token Metadata集合的Bubblegum v1不同,Bubblegum V2使用没有该布尔值的MPL-Core集合。
MPL-Core集合必须包含BubblegumV2插件。
以下部分展示如何在单步交易中为cNFT设置和移除集合。在添加coreCollection和newCoreCollection参数时,也可以在单个指令中执行两个操作。如果两个集合权限不是同一个钱包,则两者都必须签名。
设置压缩NFT的集合
setCollectionV2指令可用于设置cNFT的集合。它也可用于从cNFT移除集合或更改cNFT的集合。
设置压缩NFT的集合
import {
getAssetWithProof,
setCollectionV2,
MetadataArgsV2Args
} from '@metaplex-foundation/mpl-bubblegum';
import {
unwrapOption,
none,
} from '@metaplex-foundation/umi';
const assetWithProof = await getAssetWithProof(umi, assetId, {truncateCanopy: true});
const collection = unwrapOption(assetWithProof.metadata.collection)
const metadata: MetadataArgsV2Args = {
...assetWithProof.metadata,
collection: collection?.key ?? null,
};
const signature = await setCollectionV2(umi, {
...assetWithProof,
newCollectionAuthority: newCollectionUpdateAuthority,
metadata,
newCoreCollection: newCoreCollection.publicKey,
}).sendAndConfirm(umi);
移除压缩NFT的集合
setCollectionV2指令也可用于从cNFT移除集合。
移除压缩NFT的集合
import {
getAssetWithProof,
setCollectionV2,
MetadataArgsV2Args
} from '@metaplex-foundation/mpl-bubblegum'
import {
unwrapOption,
none,
} from '@metaplex-foundation/umi';
const assetWithProof = await getAssetWithProof(umi, assetId, {truncateCanopy: true});
const collection = unwrapOption(assetWithProof.metadata.collection)
const signature = await setCollectionV2(umi, {
...assetWithProof,
authority: collectionAuthoritySigner,
coreCollection: collection!.key
}).sendAndConfirm(umi);
Notes
- The MPL-Core collection must have the
BubblegumV2plugin enabled before cNFTs can be added to it. - Unlike Bubblegum V1 (which uses Token Metadata collections with a "verified" boolean), V2 uses MPL-Core collections without verification flags.
- When changing between collections, both the old and new collection authorities must sign the transaction.
FAQ
Glossary
| Term | Definition |
|---|---|
| setCollectionV2 | The Bubblegum V2 instruction for setting, changing, or removing the collection of a cNFT |
| MPL-Core Collection | A Core standard collection account used to group cNFTs in Bubblegum V2 |
| BubblegumV2 Plugin | An MPL-Core plugin that enables V2 features on a collection (freeze, soulbound, royalties) |
| Collection Authority | The update authority of the MPL-Core collection |
