Example code for working with Metaplex compressed NFTs (cNFTs) inside Solana Anchor programs.
This program shows how to add custom logic around the Bubblegum mint via CPI. Two handlers:
mint— mints a cNFT to your collection by CPI'ing Bubblegum. You can also initialize your own program-specific PDA in this handler.verify— verifies that the owner of a given cNFT actually invoked the instruction. Useful as a building block for permissioned cNFT-gated logic.
Use this as a reference for working with cNFTs in your own programs.
programs/cutils/— the Anchor program. The setup uses avalidate/actuatepattern via Anchor'saccess_controlmacro; this pairs well with the cNFT verification logic.
There is no tests/ directory in this example today. The program is intended to be deployed and exercised against a real cluster.
The program ID declared in programs/cutils/src/lib.rs is BuFyrgRYzg2nPhqYrxZ7d9uYUs4VXtxH71U8EcoAfTQZ. Whether this address is currently deployed on any cluster is not tracked in this repo — verify with solana program show <id> against the cluster you care about.
To deploy your own copy, change the program ID in lib.rs and Anchor.toml, then run anchor build && anchor deploy.
Reference implementation only.
- @nickfrosty for the sample code and live demo.
- @HeyAndyS for the groundwork in
cnft-vault. - Switchboard VRF-flip (since archived) for inspiring the validate/actuate setup.