功能
转移压缩NFT
Last updated February 24, 2026
Summary
Transferring a compressed NFT moves ownership from one wallet to another using the transferV2 instruction. This page covers transfers by owner, delegate, permanent transfer delegate, and transferability checks.
- Transfer a cNFT to a new owner using transferV2
- Authorize transfers via leaf owner, leaf delegate, or permanent transfer delegate
- Check if a cNFT can be transferred using the canTransfer helper
- Pass the coreCollection parameter when the cNFT belongs to a collection
transferV2指令可用于将压缩NFT从一个所有者转移到另一个。要授权转移,当前所有者或委托权限(如果有)必须签署交易。委托权限可以是叶子委托人或集合的permanentTransferDelegate。
请注意,此指令更新压缩NFT,因此会替换Bubblegum树上的叶子。这意味着必须提供额外的参数来验证压缩NFT的完整性。由于这些参数对于所有改变叶子的指令都是通用的,它们在以下FAQ中有记录。幸运的是,我们可以使用辅助方法,该方法将使用Metaplex DAS API自动为我们获取这些参数。
交易大小
如果遇到交易大小错误,请考虑在getAssetWithProof中使用{ truncateCanopy: true }。详见FAQ。
转移Bubblegum V2压缩NFT
该指令接受以下参数:
- 叶子所有者:压缩NFT的当前所有者。默认为交易的付款人。
- 叶子委托人:压缩NFT的当前所有者及其委托权限(如果有)。其中一个必须签署交易。
- 权限:签署交易的可选权限。可以是叶子所有者或
permanentTransferDelegate,默认为交易的payer。 - 新叶子所有者:压缩NFT新所有者的地址
- 默克尔树:Bubblegum树的地址
- 根:Bubblegum树的当前根
- 数据哈希:压缩NFT元数据的哈希
- 创作者哈希:压缩NFT创作者的哈希
- Nonce:压缩NFT的nonce
- 索引:压缩NFT的索引
- 集合:压缩NFT的核心集合(如果cNFT是集合的一部分)
使用JavaScript时,我们建议首先使用getAssetWithProof函数获取参数,然后将它们传递给transferV2指令。
转移压缩NFT
import { getAssetWithProof, transferV2 } from '@metaplex-foundation/mpl-bubblegum';
const assetWithProof = await getAssetWithProof(umi, assetId, {
truncateCanopy: true,
})
// 然后leafOwnerA可以用它将NFT转移给leafOwnerB。
const leafOwnerB = generateSigner(umi)
await transferV2(umi, {
// 从带证明的资产传递参数。
...assetWithProof,
authority: leafOwnerA,
newLeafOwner: leafOwnerB.publicKey,
// 如果cNFT是集合的一部分,传递核心集合。
//coreCollection: coreCollection.publicKey,
}).sendAndConfirm(umi)
压缩NFT的可转移性检查
canTransfer函数可用于检查压缩NFT是否可以转移。如果NFT可以转移则返回true,否则返回false。已冻结和NonTransferable的cNFT不能转移。
import { canTransfer } from '@metaplex-foundation/mpl-bubblegum'
const assetWithProof = await getAssetWithProof(umi, assetId, {
truncateCanopy: true,
})
const canBeTransferred = canTransfer(assetWithProof)
console.log("canBeTransferred", canBeTransferred ? "Yes" : "No")
Notes
- After a transfer, the leaf delegate is automatically reset to the new owner.
- Frozen cNFTs and soulbound (non-transferable) cNFTs cannot be transferred. Use
canTransferto check. - The permanent transfer delegate can transfer without the owner's signature if the
PermanentTransferDelegateplugin is enabled on the collection.
FAQ
Glossary
| Term | Definition |
|---|---|
| transferV2 | The Bubblegum V2 instruction that transfers a cNFT from one owner to another |
| Permanent Transfer Delegate | A collection-level authority that can transfer any cNFT without owner consent |
| canTransfer | A helper function that checks whether a cNFT can be transferred (not frozen or soulbound) |
| Leaf Owner | The current owner of the compressed NFT |
| New Leaf Owner | The wallet address that will receive ownership of the cNFT after transfer |
