I’m working on creating compressed NFTs on Solana using metaplex tools. I want to use the newer bubblegum v2 library to mint cNFTs within a Merkle tree structure. My goal is to mint an NFT directly into a collection using the mintV2 function.
I wrote this code that uploads metadata and attempts to mint the compressed NFT:
import {mintV2} from '@metaplex-foundation/mpl-bubblegum';
import {some, none} from '@metaplex-foundation/umi';
import loadConfigPath from './loadConfigPath.mjs';
import setupUmi from './setupUmi.mjs';
import uploadAsset from './uploadAsset.mjs';
import uploadMetadata from './uploadMetadata.mjs';
import loadKeypairFromFile from './loadKeypairFromFile.mjs';
import ACCOUNT_ADDRESS from './ACCOUNT_ADDRESS.mjs';
const nftData = {
"name": "Sample NFT",
"description": "Testing compressed NFT creation",
"category": "Digital Art",
}
console.log('Starting image upload process...');
const imageUrl = await uploadAsset(
loadConfigPath('artwork.png'),
'image/png'
);
console.log('Image upload complete! URI:', imageUrl);
const metadataObject = {
name: nftData.name,
image: imageUrl,
description: nftData.description,
external_url: 'https://example.com',
attributes: [
{
trait_type: 'Category',
value: nftData.category,
},
],
properties: {
files: [
{
uri: imageUrl,
type: 'image/png',
},
],
},
};
console.log('Metadata object:', JSON.stringify(metadataObject));
console.log('Uploading metadata to storage...');
const metadataUrl = await uploadMetadata(metadataObject);
console.log('Metadata upload successful! URI:', metadataUrl);
const collectionKeypair = await loadKeypairFromFile('collection-keypair.bin');
const treeKeypair = await loadKeypairFromFile('tree-keypair.bin');
const mintTransaction = await mintV2(setupUmi, {
leafOwner: setupUmi.identity.publicKey,
merkleTree: treeKeypair.publicKey,
metadata: {
name: nftData.name,
uri: metadataUrl,
collection: none(),
sellerFeeBasisPoints: 250,
creators: [
{
address: setupUmi.identity.publicKey,
verified: true,
share: 100,
},
],
},
}).sendAndConfirm(setupUmi);
console.log('Transaction result:', JSON.stringify(mintTransaction));
const {signature} = mintTransaction;
console.log('Transaction signature:', signature);
The code executes without errors but I don’t see the NFT in my Phantom wallet on devnet. How can I verify if the compressed NFT was actually created and determine its account address?