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

  • Saudi Arabia Depletes 86% of Patriot Missile Stockpile

    According to British media reports, within the first 38 days after the outbreak of the war, Saudi Arabia launched approximately 2,400 PAC-3 (Patriot-3) interceptor missiles, accounting for about 86% of the country's total stockpile of 2,800 missiles. By April of last year, Saudi Arabia had only about 400 interceptor missiles remaining. Other Gulf Arab states also consumed missile reserves on a similar scale, highlighting the military crisis facing the region. (Jin Shi)

  • Experts: The Strait of Hormuz 'Will Never' Return to Pre-War Status

    Ali Akbar Dareini, a researcher at the Iranian Strategic Studies Center, stated that Iran and Oman are about to reach an agreement on the future management of the Strait of Hormuz, with the main obstacle being U.S. pressure on Oman to adopt a position more aligned with Washington. Dareini emphasized that Iran considers future control of the strait crucial for its national security. In recent months, the U.S. has conducted strikes against Iran, which Iran claims were launched from bases in the region. Dareini noted that the ongoing negotiations between Iran and Oman present the U.S. with a 'good opportunity to extricate itself from this quagmire' by recognizing Iran and Oman as the countries that will determine the 'future' of the Strait of Hormuz. 'However, the Strait of Hormuz will never return to its pre-war status,' he continued. 'The geopolitical landscape of the region has changed.'

  • Iran: Negotiations with Oman Unrelated to Reopening of Strait of Hormuz

    On August 8, a spokesperson for the Islamic Revolutionary Guard Corps of Iran stated that the reopening of the Strait of Hormuz is unrelated to negotiations between Iran and Oman, but rather depends on whether the United States fully accepts Iran's conditions and ceases interference in regional negotiations. "Once the United States accepts Iran's conditions, the Strait will undoubtedly reopen." (CCTV News)

  • Whale Shorting $102 Million in Bitcoin Faces Partial Liquidation, Remaining Liquidation Price Around $65,300

    On August 8, TheDataNerd reported that a whale using 40x leverage to short $102 million in Bitcoin recently faced partial liquidation, incurring a loss of $1.46 million over the past week. Currently, the margin call has reduced the short position to approximately $60 million, with an opening price of $64,212.5 and a liquidation price of $65,310.2.

  • BTC Falls Below $65,000

    Market data shows BTC has fallen below $65,000, currently reported at $64,999.23, with a 24-hour increase of 1.01%. Market volatility is high, please exercise risk control.

  • Hedge Fund AISituational Awareness's Mysterious $400 Million Investment Targets Chip Startup Source Foundry

    On August 8, sources revealed that the hedge fund Situational Awareness, managed by former OpenAI researcher Leopold Aschenbrenner, made a mysterious $400 million investment in the chip manufacturing startup Source Foundry just days after facing imminent collapse. Previously, Bloomberg reported that the hedge fund invested in a private company backed by Sequoia Capital, but did not disclose the name of the specific company. The Wall Street Journal had earlier reported that the recipient of the investment was Source Foundry, unveiling the target of this mysterious funding deployment by Situational Awareness.

  • US Spot Bitcoin ETF Sees $101.79M Net Inflow Yesterday

    On August 8, according to Trader T's monitoring, US spot bitcoin ETFs saw a net inflow of $101.79 million yesterday.

  • US Official: Ukraine Agrees to Avoid Strikes on Non-Russian Tankers and Black Sea Oil Facilities

    On August 8, according to a US official, Ukraine has agreed not to target certain non-Russian tankers and Black Sea infrastructure vital to Kazakhstan's crude oil exports. This follows ship attacks last month that caused loading disruptions. The US official said Ukraine has set up contact points so commercial shipping companies can communicate information and ensure safe passage. The commitment was reached after meetings between senior US government leaders and Ukrainian leadership, marking a potentially significant step toward increasing regional oil shipments. Previously, activity in the region had cooled significantly due to several recent attacks near the Caspian Pipeline Consortium terminal in Russia's Novorossiysk. (Jin Shi)

  • U.S. July Nonfarm Payrolls Fall by 23,000, Missing Market Expectations

    On August 7, U.S. nonfarm payrolls decreased by 23,000 in July, compared with market expectations of an increase of 80,000, and the previous value was an increase of 57,000.

  • US May and June Nonfarm Payroll Additions Revised Down by 103,000 Combined

    On August 7, the US Bureau of Labor Statistics: May nonfarm payroll additions were revised down from 129,000 to 63,000; June nonfarm payroll additions were revised down from 57,000 to 20,000. After the revisions, the combined additions for May and June were 103,000 lower than previously reported.