How to Interact with cNFTs

Overview

This guide details the specific requirements for interacting with compressed NFT (cNFT) assets using JavaScript on Eclipse's devnet and mainnet. For a more comprehensive overview of creating cNFTs, see the Create 1,000,000 NFTs on Eclipse with Bubblegum guide.

Required Package

This guide makes use of a specific beta npm package for @metaplex-foundation/mpl-bubblegum. Install using:

npm -i @metaplex-foundation/[email protected]

Connecting to Eclipse

Note you will need to create your umi instance using the endpoint.

import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";

const umi = createUmi('<RPC endpoint for the Eclipse devnet/mainnet>')
  .use(mplBubblegum())
  .use(mplTokenMetadata())
  ...

List of RPCs for Eclipse devnet/mainnet

Creating a Tree

Tree Cost

Creating a tree can be done using the same createTree function that is used on Eclipse devnet/mainnet. However, we must override the default logWrapper and compressionProgram values. This could be accomplished as simply as:

However, a helper function has been provided to automatically resolve these program IDs, and this is the recommended approach as it will work on Eclipse devnet/mainnet to which Bubblegum has been deployed:

Mint and Transfer a cNFT

Similarly to creating the Merkle tree on Eclipse, other SDK functions such as mintV1 and transfer will also require specifying the compression programs. Again we use the getCompressionPrograms helper.

Was this helpful?