Theme

Features

Transferring Compressed NFTs

The transferV2 instruction can be used to transfer a Compressed NFT from one owner to another. To authorize the transfer, either the current owner or the delegate authority — if any — must sign the transaction. The delegated authority can either be a leaf delegate or the permanentTransferDelegate of the collection.

Note that this instruction updates the Compressed NFT and therefore replaces the leaf on the Bubblegum Tree. This means additional parameters must be provided to verify the integrity of the Compressed NFT. Since these parameters are common to all instructions that mutate leaves, they are documented in the following FAQ. Fortunately, we can use a helper method that will automatically fetch these parameters for us using the Metaplex DAS API.

Transaction size

If you encounter transaction size errors, consider using { truncateCanopy: true } with getAssetWithProof. See the FAQ for details.

Transfer a Bubblegum V2 Compressed NFT

The instruction accepts the following parameters:

  • Leaf Owner: The current owner of the Compressed NFT. It defaults to the payer of the transaction.
  • Leaf Delegate: The current owner of the Compressed NFT and its delegate authority if any. One of these must sign the transaction.
  • Authority: An optional authority that signs the transaction. It can be the Leaf Owner or the permanentTransferDelegate and defaults to the payer of the transaction.
  • New Leaf Owner: The address of the Compressed NFT's new owner
  • Merkle Tree: The address of the Bubblegum Tree
  • Root: The current root of the Bubblegum Tree
  • Data Hash: The hash of the metadata of the Compressed NFT
  • Creator Hash: The hash of the creators of the Compressed NFT
  • Nonce: The nonce of the Compressed NFT
  • Index: The index of the Compressed NFT
  • Collection: The core collection of the Compressed NFT (if the cNFT is part of a collection)

When using JavaScript we suggest to use the getAssetWithProof function first to fetch the parameters and then pass them to the transferV2 instruction.

Transfer a Compressed NFT

import { getAssetWithProof, transferV2 } from '@metaplex-foundation/mpl-bubblegum';
const assetWithProof = await getAssetWithProof(umi, assetId, {
  truncateCanopy: true,
})

// Then leafOwnerA can use it to transfer the NFT to leafOwnerB.
const leafOwnerB = generateSigner(umi)
await transferV2(umi, {
  // Pass parameters from the asset with proof.
  ...assetWithProof,
  authority: leafOwnerA,
  newLeafOwner: leafOwnerB.publicKey,
  // If the cNFT is part of a collection, pass the core collection.
  //coreCollection: coreCollection.publicKey, 
}).sendAndConfirm(umi)

Transferability Check for Compressed NFTs

The canTransfer function can be used to check if a Compressed NFT can be transferred. It will return true if the NFT can be transferred and false otherwise. Frozen and NonTransferable cNFTs cannot be transferred.

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")
Previous
Fetching cNFTs