Bubblegum is the Metaplex Protocol program for creating and interacting with compressed NFTs (cNFTs) on Solana. Compressed NFTs make it possible to scale the creation of NFTs to new orders of magnitude by rethinking the way we store data on-chain.
Find the language or library of your choice and get started with compressed NFTs.
Looking for something specific? Have a peak at our API References and find your answer.
As NFTs have flourished on the Solana blockchain, there’s been an increasing need for NFTs to be as ubiquitous as any digital asset on the Internet: every single item in your game’s inventory, proof-of-engagement in your favourite consumer app, or even a profile for every human on the planet.
So far, though, these types of products have been held back by the cost of rent for NFTs on Solana, which is relatively cheap (0.012 SOL) but scales linearly; a billion NFTs would cost 12,000,000 SOL! From 10,000 NFTs at 3.5 SOL (34x), 1 million NFTs at 5 SOL (2,400x), and 1 billion NFTs at 500 SOL (24,000x), compression for NFTs drastically reduces the cost of on-chain storage of NFTs to enable creators to be as expressive with the technology as they wish.
|Number of cNFTs||Storage Cost||Transaction Cost||Total Cost||Cost per cNFT|
These compressed NFTs can be transferred, delegated, and even decompressed into regular NFTs for interoperability with existing smart contracts.
Merkle Trees, leaves and proofs
Compressed NFTs only exist in the context of a Merkle Tree. We explain in a dedicated advanced guide what Merkle Trees are but, for the sake of this overview, you can think of a Merkle Tree as a collection of hashes that we call Leaves. Each Leaf is obtained by hashing the data of the compressed NFT.
For each Leaf in the Merkle Tree, one can provide a list of hashes — called a Proof — that enables anyone to verify that the given Leaf is part of that tree. Whenever a compressed NFT is updated or transferred, its associated Leaf will change and so will its Proof.
As such, Merkle Trees act as an on-chain structure that allows anyone to verify a given compressed NFT exist. They do this without storing any NFT data which makes them so scalable.
Which brings us to an important question: where is the NFT data stored?
When we mint a new compressed NFT, its data is hashed and added as a new Leaf in a Merkle Tree. But there’s more. Additionally, the entire NFT data is stored in the transaction that created the compressed NFT. Similarly, when a compressed NFT is updated, its updated data is, once again, saved on the transaction as a changelog. So, whilst there aren’t any accounts keeping track of that data, one can look at all previous transactions in the ledger and find that information.
Crawling through millions of transactions every time just to fetch the data of one NFT is admittedly not the best user experience. Therefore, compressed NFTs rely on some RPCs to index that information in real time to abstract this away from the end-user. We call the resulting RPC API, which enables fetching compressed NFTs, the Metaplex Read API.
Note that not all RPCs support the Read API. As such, you may be interested in the “Read API RPCs” page to select an appropriate RPC when using compressed NFTs in your application.
We talk about this in more detail in our advanced “Storing and indexing NFT data” guide.
Even though NFT data does not live inside accounts, it is still possible to execute a variety of operations on compressed NFTs. This is possible by requesting the current NFT data and ensuring its hashed Leaf is valid on the Merkle Tree. As such, the following operations can be performed on compressed NFTs:
- Mint a cNFT with or without an associated collection.
- Transfer a cNFT.
- Update the data of a cNFT (Coming Soon).
- Burn a cNFT.
- Decompress a cNFT into a regular NFT. Note that this enables interoperability with existing smart contracts but creates on-chain accounts with rent fees.
- Delegate a cNFT.
- Verify and unverify a cNFT collection.
- Verify and unverify the creators of a cNFT.
Now that we know how compressed NFTs work at a high level, we recommend checking out our Getting Started page which enumerates the various languages/frameworks that one can use to interact with compressed NFTs. Afterwards, the various feature pages can be used to learn more about the specific operations that can be performed on cNFTs. Finally, advanced guides are also available to deepen your knowledge of cNFTs and Merkle Trees.