Sign in

Solana NFTs

Suggest an edit

An NFT is just an SPL Token with three constraints

A Solana NFT is not a separate kind of object. It is an SPL Token, the same token program that runs USDC and Bonk and your project's reward token. What makes it non-fungible is configuration:

  • Supply is 1. There is exactly one of them.
  • Decimals is 0. No fractional units exist.
  • Mint authority is permanently renounced. Nobody can ever mint more.

The token program doesn't know or care that this particular mint represents a JPEG of a cartoon lizard. It enforces the supply constraint, blocks attempts to mint after the authority is renounced, and tracks ownership through token accounts the way it would for any other token. Transferring an NFT is calling the SPL Token transfer instruction on a token account whose balance is 1, the same instruction that moves USDC.

On Ethereum an NFT collection is usually its own ERC-721 contract, which records the owner of every token id and returns each token's metadata URI (ERC-721 and ERC-1155). On Solana nobody deploys a contract per collection. Every NFT is a separate mint in the shared token program, and that program tracks only how many of the token exist and who owns each one. It doesn't store a name, a symbol, an image, a list of attributes, or which collection the NFT belongs to, so that information has to live elsewhere.

Solana NFT: mint, metadata, and owner's token accountA Solana NFT is three linked accounts: the mint account holds supply, decimals, and authority fields; the metadata account, owned by the Metaplex Token Metadata program, holds name, symbol, uri, creators, and collection; both reference the mint. The owner's token account holds amount 1 and points to the mint too, and transferring the NFT just moves this token account between wallets. A Solana NFT is three accounts that point at each other Mint account supply: 1 decimals: 0 mint_auth: None freeze_auth: None just an SPL Token, configured for non-fungibility Metadata account mint: <mint pubkey> name: "Mad Lad #4269" symbol: "MAD" uri: arweave.net/... creators: [...] collection: Some(<pubkey>) owned by the Metaplex Token Metadata program Owner's token account mint: <mint pubkey> owner: <wallet pubkey> amount: 1 the wallet that holds the NFT is whoever owns this account references references The mint is the identity. The metadata describes it. The token account holds the one copy. "Transferring the NFT" means moving the token between token accounts. Nothing else changes.

Metadata lives in a separate account, attached by convention

Metaplex's Token Metadata program is the de facto standard for attaching descriptive information to a mint. When someone says "an NFT," they almost always mean an SPL Token mint plus a Metaplex metadata account that points at it. The two are paired so consistently that wallets, marketplaces, and explorers expect every NFT to have both.

The metadata account is a PDA owned by the Token Metadata program, with seeds derived from the mint's pubkey. This makes the pairing automatic: given any mint address, anyone can compute where its metadata account should live and look up whether one exists. The metadata account stores the name, symbol, URI pointing at off-chain JSON, the list of creators with royalty shares, the collection the NFT belongs to, and various flags.

The URI is where the actual image lives. The metadata account is too small and too expensive to hold image bytes, so the URI points at a JSON file on Arweave or IPFS, which describes the NFT and includes another link to the actual image asset. The chain stores only a pointer to a pointer to the picture. This is fine in practice because Arweave promises permanent storage and IPFS is pinned by enough services that NFT images stay accessible.

A collection is itself an NFT that the other NFTs reference, which is how marketplaces group items together. Metaplex also defines a Master Edition account, which marks the mint as the original that numbered copies (Editions) can be printed from.

Royalties cannot be enforced by the token program

The metadata account lists the creators and their royalty shares, but the token program never reads it. When an NFT is sold on a marketplace such as Magic Eden or Tensor, the marketplace's own program runs the transfer. It can also pay royalties to the creators recorded in the metadata account, but nothing in the transfer requires it. Originally, royalties were a social contract: marketplaces honored them because creators expected it. Then some marketplaces started skipping royalties to compete on fees, and the token program moved the NFTs all the same.

To enforce a royalty, a check has to sit inside the transfer itself. Metaplex responded with programmable NFTs, an extension of the Token Metadata standard that gates transfers through a ruleset. A gate works only if no transfer can go around it, so every wallet and marketplace that moves a programmable NFT has to pass the ruleset. That adds cost and complexity for every program that moves the NFT, and most collections don't use programmable NFTs. Token-2022's transfer hook is another way to put a check inside every transfer, and that lesson shows what such a check costs the programs that integrate the token.

Compressed NFTs and the rent math

The single biggest economic problem with regular Solana NFTs is rent. Every NFT is at least two new accounts on chain. At about 0.007 SOL of rent per NFT, a 10,000-item collection locks up around 70 SOL just to exist, before anyone buys anything. That's been paid by the creator at mint time and is recoverable only if NFTs are burned, which essentially never happens in practice. For collections that are minted for free or as rewards, the rent cost becomes prohibitive.

Compressed NFTs, or cNFTs, solve this with state compression. Instead of storing each NFT's data in its own account, the entire collection is represented as a Merkle tree, the structure from the airdrop example in off-chain computation, on-chain verification. Only the tree's root hash lives on chain, in a single account that can hold up to millions of leaves depending on its configured depth. The actual NFT data, such as names, URIs, and owners, lives off chain in indexers. When you want to prove you own a specific cNFT, you provide a Merkle proof against the on-chain root. A transfer works the same way: the transaction includes a proof showing the leaf's current state, and the cNFT program (Metaplex's Bubblegum) verifies the proof and updates the root.

Rent math: uncompressed NFTs vs compressed cNFTs for a 10,000-item collectionTwo side-by-side panels compare on-chain rent costs. The left panel shows uncompressed regular NFTs needing 10,000 mint and metadata accounts, totaling about 70 SOL locked rent; the right panel shows compressed cNFTs stored in a single Merkle tree account, totaling about 0.1 SOL. A bottom callout notes cNFTs are about 700x cheaper, at the cost of needing an indexer to read individual NFTs back out. Rent math for a 10,000-item collection uncompressed (regular NFTs) accounts on chain: 10,000 mint accounts 82 bytes each 10,000 metadata accounts ~679 bytes each + owner token accounts created on transfer rent per NFT: ~0.00146 SOL (mint) ~0.00561 SOL (metadata) ~0.007 SOL total total locked rent: ~70 SOL paid up front to mint the collection recoverable only if NFTs are burned every NFT has its own pair of accounts. costs scale linearly with collection size. compressed (cNFTs) accounts on chain: 1 Merkle tree account holds the root + buffer size depends on depth leaves stored off chain indexers keep proofs rent per NFT: ~0.00001 SOL spread across the tree total locked rent: ~0.1 SOL one tree, fits 16,384 cNFTs at depth 14 collection state lives in one account. costs scale with tree depth rather than item count. ~700x cheaper for the same collection size in exchange for needing an indexer to read individual NFTs back out

The math works because Merkle trees compress logarithmically. A tree of depth 14 can hold 16,384 NFTs in one account. A tree of depth 20 can hold over a million. The account size grows with the tree's depth rather than with the number of items in it. Rent for the tree account is typically under 1 SOL for collection sizes that would cost dozens or hundreds of SOL as regular NFTs.

The trade-off is that cNFTs cannot be read trivially from chain state alone. Reading a regular NFT means fetching two accounts and decoding them. Reading a cNFT means querying an indexer that maintains the off-chain leaf data and the proofs. A transfer depends on the indexer too, because the proof it carries has to be fetched from there first. Helius, Triton, and others provide cNFT-aware RPC endpoints that let you query a wallet's cNFTs as if they were regular NFTs.

cNFTs are common for use cases that would have been impossible with regular NFTs at scale: game items distributed to every player, achievement badges minted on action, loyalty tokens that an airline gives out by the million. They're less common for art collections in the traditional sense, where the rent is a small fraction of the mint price and the indexer dependency is a friction.

Programs use NFTs to gate access and to represent positions

Even if you never build an NFT-centric protocol, two patterns will show up in your work.

NFTs as access tokens. Many Solana products gate features behind ownership of a specific collection. DAOs gate voting to collection holders this way, games unlock features for certain NFT owners, and alpha groups verify membership. Your program gets a token account and a metadata account from the user and has to tie them together. The token account's owner field must be the user's wallet, and its balance must be 1. The metadata account must be the Token Metadata PDA derived from that token account's mint. Its collection field must reference the expected collection NFT. These three checks tie the accounts to each other, but they are not a complete gate. They do not show who wrote the collection field, and this lesson has not covered who is allowed to write it. Check that in the Token Metadata documentation before you let the field decide access.

NFTs as receipts. Some protocols issue an NFT to represent a position: your stake in a pool, your loan in a lending market, your liquidity position in a CLMM. The NFT is the transferable handle on the position. You burn it to redeem, or sell it to transfer the position to someone else. Raydium's CLMM positions work this way, and the CLMM lesson shows why a position there cannot be a fungible LP token.