How Merkle Trees Enable State Compression for NFTs on Solana

As blockchain continues to evolve, new methods for efficiently storing and verifying data emerge. One of these techniques is known as State Compression, which utilizes a cryptographic tree structure called a Merkle Tree. Th In this article, we’ll explore how Merkle Trees and their special variant, Concurrent Merkle Trees, work to enable state compression on Solana. Furthermore, we'll introduce Underdog Protocol, a user-friendly API that manages all aspects of creating and managing compressed NFTs on Solana.

What is State Compression?

State Compression is the art of creating a "fingerprint" or hash of off-chain data and storing this fingerprint on Solana . This allows you to securely validate off-chain data using the security features of the Solana ledger. This "compression" method is beneficial because it enables Solana programs and dApps to use cheap ledger space, as opposed to more expensive account space, for secure data storage.

How Does It Work?

  1. Data Hashing: Any piece of data is first hashed.
  2. Leaf Creation: The hash is stored as a leaf at the bottom of the tree.
  3. Branching: Pairs of leaves are hashed together, creating a branch.
  4. Climbing The Tree: Each branch is hashed together with other branches, progressively moving up the tree.
  5. Root Hash: A final root hash is generated at the top of the tree.

This root hash is stored on-chain as a verifiable proof of all the data within every leaf. It enables cryptographic verification of all off-chain data while storing a minimal amount of data on-chain, significantly reducing storage costs.

Traditional Merkle Trees vs. Concurrent Merkle Trees

Traditional Merkle Trees

A traditional Merkle Tree allows for data verification by using a specific 'proof path' that climbs up the tree from a leaf to the root. However, every time you want to change data, you need to update this root hash, making it not so efficient for high throughput applications.

Concurrent Merkle Trees

Solana improves upon this by introducing Concurrent Merkle Trees, which maintain a secure 'changelog' of the tree on-chain. This enables multiple, rapid changes to the tree in the same block or 'slot', significantly boosting throughput and reducing the likelihood of transaction failure due to rapid changes.

Sizing a Concurrent Merkle Tree

When creating a Concurrent Merkle Tree on Solana, you'll consider three main factors:

  1. Max Depth: Determines the maximum number of data pieces or leaves the tree can handle.
  2. Max Buffer Size: The maximum number of concurrent changes that the tree can handle while retaining a valid root hash.
  3. Canopy Depth: The number of proof nodes stored on-chain to facilitate efficient updates and verifications.

The higher these numbers, the more expensive the cost of tree creation will be.

Underdog Protocol: The One-Stop Solution for Compressed NFTs

One of the most popular use-cases for State Compression on Solana is compressed NFTs. However, managing the complexity of Merkle Trees can be a daunting task for developers. This is where Underdog Protocol comes in.

Underdog Protocol is a seamless API that allows you to mint and manage compressed NFTs effortlessly. The protocol takes care of all the heavy lifting, such as tree sizing, creation, and management of NFTs. With Underdog Protocol, a one million NFT collection could be minted for around 50 SOL, compared to ~12,000 SOL for an uncompressed collection.

How To Use Underdog Protocol

Using Underdog Protocol is simple. You don’t have to bother with the intricacies of tree sizing, as the API manages it all for you. Just connect to the API, and you're good to go. You can focus on the creative aspects of your NFT project while Underdog Protocol takes care of the technical details.

If you're interested in testing out compressed NFTs or wish to integrate them into your dApp or any other product, we highly recommend you check out Underdog Protocol.

Conclusion

Merkle Trees, and particularly their variant, Concurrent Merkle Trees, have opened new doors for efficient data storage and verification on the blockchain. These technologies are particularly beneficial for the burgeoning NFT market on Solana, reducing the cost and increasing the efficiency of these unique digital assets.

With services like Underdog Protocol, even those without a deep understanding of blockchain  can leverage these benefits to create compressed NFTs easily and affordably. So, why wait? Head over to Underdog Protocol and start your journey into the future of NFTs today!