โ Back to Home
๐ณ
Gasless cNFT Minting (Metaplex Bubblegum)
Mint compressed NFTs using Metaplex Bubblegum
๐ค LazorKit x Bubblegum
Regular NFT
- ~0.02 SOL per mint
- 4 accounts created
- 6 instructions
- User pays rent
Compressed NFT
- 0 accounts created
- 1 instruction
- Gas sponsored by paymaster
- Truly gasless!
* Tree creation is a one-time cost paid by the platform
Making Bubblegum Work with LazorKit
1.Build Bubblegum Mint Instruction
Use Umi with Bubblegum to mint to a pre-created merkle tree:
// From lib/nft-utils.ts
const umi = createUmi(RPC_URL).use(mplBubblegum());
umi.use(signerIdentity(dummySigner));
const mintBuilder = mintV1(umi, {
leafOwner: umiPublicKey(walletAddress),
merkleTree: umiPublicKey(merkleTreeAddress),
metadata: {
name: nftName,
symbol,
uri: metadataUri,
sellerFeeBasisPoints: 0,
collection: none(),
creators: [{ address, verified: false, share: 100 }],
},
});2.Extract Asset ID from Transaction Logs
cNFTs don't have mint addresses. Extract Asset ID from logs:
// From lib/nft-utils.ts
async function extractCNftAssetId(signature: string) {
const tx = await connection.getTransaction(signature, {
commitment: 'confirmed',
maxSupportedTransactionVersion: 0,
});
for (const log of tx.meta.logMessages) {
const match = log.match(
/Leaf asset ID: ([1-9A-HJ-NP-Za-km-z]{32,44})/
);
if (match) return match[1];
}
}3.Sign & Send via LazorKit
LazorKit handles signing with passkey and gas sponsorship:
// From page.tsx
const { signAndSendTransaction } = useWallet();
const signature = await signAndSendTransaction({
instructions,
transactionOptions: {
computeUnitLimit: 400_000,
},
});The merkle tree is created once by the platform. Users just mint to it - no accounts created per mint!
What You'll Learn
- โUse Metaplex Bubblegum with LazorKit
- โMint to existing merkle trees (zero rent!)
- โExtract Asset ID from transaction logs
- โView cNFTs via DAS-compatible explorers
Connect Your Wallet
Use LazorKit to mint compressed NFTs for free
๐ณDemo Merkle Tree
HiTxt5DJMYSpwZ7i3Kx5qzYsuAfEWMZMnyGCNokC7Y2u
Capacity: 16,384 cNFTs โข Shared by all cookbook users