Cointime

Download App
iOS & Android

State Compression Brings Down Cost of Minting 1 Million NFTs on Solana to ~$110

Cointime Official

Solana, the industry leader in building web3 experiences at scale, has introduced state compression, a new way to store data directly on-chain that cuts down on cost by magnitudes of scale. State compression is already being used by teams across the Solana ecosystem, including Dialect and Crossmint, to power large, user-friendly experiences.

Although state compression can be used to store any sort of data on-chain, the first use of this innovative technology is compressed NFTs, which drastically reduces the cost of minting NFTs. State compression is a novel technology primitive that takes advantage of Merkle trees, allowing developers to store a small bit of data on-chain and updates directly in the Solana ledger, cutting the data storage cost down dramatically while still using the security and decentralization of Solana's base layer.

Jon Wong is technical lead on the ecosystem engineering team at the Solana Foundation.

After numerous phases of development, adoption, and rollout, compressed NFTs are live on Solana’s mainnet-beta and powering the next wave of novel on-chain product experiences. Compressed NFTs are 2,400-24,000x cheaper than their uncompressed counterparts, while still retaining identical structures. Now minting 100 million NFTs on Solana costs only ◎50!

For the developers who want to get started with compressed NFTs, there are five key things to know:

  1. Understand Merkle trees
  2. Initialize the tree
  3. Mint an NFT
  4. Use an RPC to get the latest data
  5. Use proofs to transfer NFTs

Understand Merkle trees

State compression takes advantage of Merkle trees, a data structure known for its capability to “compress” the verifiability of a tree of data into a “hash,” or “fingerprint,” of the current state of the tree. The Merkle roots are stored on-chain and updates are stored directly in the Solana ledger, meaning anyone can verifiably (and permissionlessly) reconstruct the tree, combining a vast amount of verifiable off-chain storage with a low overall cost of on-chain storage.

Engineers at Solana Labs added the capability to concurrently update Merkle trees multiple times in the same block by allowing the fast-forwarding of stale proofs. This capability is unique to Solana. See more in the whitepaper.

Initialize the tree

The first thing you need to do is initialize the Merkle tree. There are three parameters to any Merkle tree: 1) Depth (capacity), 2) buffer size (concurrency / latency), and 3) canopy height (composability).

Depth is easy — the capacity of a perfectly balanced concurrent Merkle tree is 2^{DEPTH}, and trees can be configured to hold anywhere from eight leaves all the way up to a billion (2^30). In this case, leaves can be NFTs.

Buffer size is an approximation of the number of concurrent updates that can happen in the same block. Merkle trees typically have an issue whereby any modification of the tree causes any previously computed proofs to go out-of-date, but with this novel concurrent Merkle tree implementation, stale proofs can be fast-forwarded and still be accepted by the smart contract. A buffer size of 64 means that any given proof will still remain valid for up to 64 updates of the tree, after which it must be recomputed. Buffer size can be anywhere from eight to 2048.

Canopy height specifies the portion of the tree that remains on-chain, reducing the amount of proofs that have to be submitted by clients for verification. Given the current transaction size limits on Solana, this is the only feasible way to pass enough proofs to be able to validate the existence of trees with a depth > 20. Canopy height maxes out at 17.

Rather than initialize one giant tree to hold everything, I recommend issuing numerous, smaller trees of varying sizes. This reduces write-lock contention on the tree account, as well as provides more opportunities for composability by reducing the number of proofs needed to be submitted for any given modification.

Choose a canopy height that maximizes composability — while it costs more in rent, a canopy height that is DEPTH-3 provides a similar interface to existing NFT-related smart contracts that already pass 3 accounts. For example, a tree of depth 20 could have a canopy of 17 so that clients only need to submit three proofs to make any modification to a tree.

Mint an NFT

Tooling for minting compressed NFTs is already live. Bubblegum, the smart contract written by Metaplex that powers compressed NFTs, uses state compression under the hood. Mint, transfer, and replace instructions should be issued against the Bubblegum smart contract. Mints do not require proofs, so anyone can mint compressed NFTs as easily as before.

Use an RPC to get the latest data

Compressed NFTs eschew the typical on-chain account approach, and because data related to trees is being issued into the Solana ledger, RPCs are required to make the “read” experience nice and snappy. HeliusSimpleHash, and Triton all have support for compressed NFTs, and 2/3 implement the Metaplex Read API—a uniform interface for retrieving all the information necessary about both compressed and uncompressed NFTs.

Use proofs to transfer NFTs

Because of how compressed NFTs are stored, any modifications to those NFTs (such as an ownership change, or an update to the metadata like the collection information) requires a modification of the storage tree itself. In order to do so, one must compute the proofs needed to signify that you know the latest state of the tree, along with the signature of the leaf owner (or delegate).

Merkle tree proofs are the set of hashes that can be used to prove that the leaf was in the tree to begin with. RPC nodes can provide this with the `getAssetProof` Read API RPC method. Depending on the canopy height of the tree, one can submit a subset of the proof path and let the on-chain program handle reconciling the rest of it.

Submit the proofs along with the modification you want to make (a new owner!) and send the transaction. Voila!

Once you’ve understood these concepts, you should be ready to take advantage of compressed NFTs and build brand new experiences.

Here are some additional resources for you to explore:

NFT
Comments

All Comments

Recommended for you

  • U.S. Stock Indices Open Lower

    On May 21, U.S. stocks opened with the Dow Jones down 0.27%, the S&P 500 down 0.39%, and the Nasdaq down 0.5%. Microsoft (MSFT.O) rose 1.1% amid reports that Anthropic is in talks to use its artificial intelligence chips. U.S. Rare Earths (USAR.O) increased by 2.7% after being selected for a pilot rare earth processing project by the U.S. Department of Energy. IBM (IBM.N) saw a 3% rise as the company is set to receive $1 billion in U.S. government funding to advance quantum computing development. NIO Inc. (NIO.N) rose by 5%, reporting a 112.2% year-on-year increase in revenue for the first quarter.

  • BTC Falls Below $77,000

    Market data shows that BTC has fallen below $77,000, currently priced at $76,976.12, with a 24-hour decline of 0.06%. The market is experiencing significant volatility, so please ensure proper risk management.

  • Nasdaq China Golden Dragon Index Drops Nearly 3%

    On May 21, the Nasdaq China Golden Dragon Index saw an expanded decline, currently down 2.84%, with the latest reading at 6,568 points.

  • Anthropic in Talks to Lease Microsoft AI Chips

    On May 21, according to two executives who spoke with individuals involved in the discussions, Anthropic is in talks to lease AI server chips designed by Microsoft in order to seek higher computing power to meet its growing AI demands.

  • Putin: Use of Nuclear Weapons Only as a Last Resort

    On May 21, Russian President Putin stated that given the increasingly tense global situation, the country's nuclear triad must serve as a reliable guarantee of the sovereignty of Russia and Belarus. The use of nuclear weapons is only a last resort. (Dongxin News Agency)

  • Bloomberg: Blockchain.com Secretly Files for U.S. IPO

    According to Bloomberg, Blockchain.com has secretly submitted an IPO application in the United States, with its valuation shrinking from a peak of $14 billion in 2022 to approximately $2 billion.

  • Initial Jobless Claims in the U.S. for the Week Ending May 16 at 209,000, Slightly Below Expectations

    On May 21, the number of initial jobless claims in the U.S. for the week ending May 16 was 209,000, slightly below the expected 210,000, and down from the previous value of 211,000.

  • Market News: Turkey Nearly Liquidated All Its U.S. Treasury Holdings in March

    Market news: Turkey nearly liquidated all its U.S. Treasury holdings in March. (Jin Shi)

  • Prediction Website: SpaceX's Valuation Could Exceed $2 Trillion

    On May 21, it was reported that bettors on the prediction website Polymarket anticipate that SpaceX's market value will almost certainly surpass $1 trillion upon its public listing, with a 73% probability of exceeding $2 trillion. These bets are linked to the closing market value on SpaceX's first day of trading. The company plans to go public in June, with an expected target valuation exceeding $1.5 trillion. Additionally, data from Polymarket indicates a 17% probability of its market value exceeding $3 trillion and a 2% probability of surpassing $4 trillion. The prediction market launched betting on SpaceX's valuation about two weeks ago, but currently, trading volumes on related contracts are low, suggesting that there may be some skepticism regarding these probabilities. If SpaceX's market value does indeed exceed $2 trillion, it would surpass at least two of the 'Big Seven' U.S. stocks: Meta Platforms (META.O) and Tesla (TSLA.O), which currently have market values of approximately $1.5 trillion and $1.6 trillion, respectively.

  • Iran's Supreme Leader: Near-Weapons-Grade Uranium Must Remain in Iran

    According to Reuters, two sources have stated that Iran's Supreme Leader has ordered that near-weapons-grade uranium must remain within Iran's borders. The Supreme Leader's directive reflects a consensus within the Iranian regime.