๐จ Metaplex (NFTs)
Metaplex is the de facto standard and toolkit for NFTs on Solana: metadata (name, description, image), collections, and royalty enforcement. The Metaplex Token Metadata Programย defines the on-chain layout and instructions.
๐ฏ Why Metaplex
- Ecosystem standard โ Magic Edenย , Tensorย , and most Solana NFT apps use Metaplex metadata
- Metadata accounts โ Store URI (pointing to JSON), name, symbol, creators, royalties
- Collections โ Group NFTs under a verified collection
- SDKs โ JS SDKย and Umiย for creating and reading NFTs
๐ Core Concepts
| Concept | Description |
|---|---|
| Mint | SPL Token mint account; the NFT is a token with supply 1 and decimals 0 |
| Metadata account | PDA (Program Derived Address) owned by the Metaplex program; holds URI, name, symbol, creators, etc. |
| Master Edition | For limited prints or verification; used by the Metaplex program |
| JSON off-chain | URI in metadata points to JSON with name, description, image, attributes (e.g. on IPFS or Arweave) |
๐ Metadata JSON (Off-Chain)
Your tokenURI should resolve to JSON like:
{
"name": "My NFT",
"symbol": "MNFT",
"description": "Description here",
"image": "https://arweave.net/...",
"attributes": [
{ "trait_type": "Background", "value": "Blue" }
],
"properties": {
"files": [{ "uri": "https://...", "type": "image/png" }],
"category": "image"
}
}Host on IPFS, Arweaveย , or a CDN. See Metaplex standardย .
๐ Creating an NFT (Metaplex JS)
Using @metaplex-foundation/mpl-token-metadataย and the JS SDK:
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
import { createMetadataAccountV3 } from "@metaplex-foundation/mpl-token-metadata";
import { createSignerFromKeypair, signerIdentity } from "@metaplex-foundation/umi";
import { Keypair } from "@solana/web3.js";
const umi = createUmi("https://api.devnet.solana.com");
const keypair = Keypair.fromSecretKey(/* ... */);
const signer = createSignerFromKeypair(umi, keypair);
umi.use(signerIdentity(signer));
// After creating the mint and token account (e.g. with @solana/spl-token)...
const metadata = {
name: "My NFT",
symbol: "MNFT",
uri: "https://arweave.net/your-metadata-json",
sellerFeeBasisPoints: 500, // 5%
creators: null,
collection: null,
uses: null,
};
await createMetadataAccountV3(umi, {
mint: mintKey,
mintAuthority: signer,
payer: signer,
updateAuthority: signer.publicKey,
data: {
name: metadata.name,
symbol: metadata.symbol,
uri: metadata.uri,
sellerFeeBasisPoints: metadata.sellerFeeBasisPoints,
creators: metadata.creators,
collection: metadata.collection,
uses: metadata.uses,
},
isMutable: true,
collectionDetails: null,
}).sendAndConfirm(umi);๐ Reading NFT Metadata
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
import { fetchMetadata } from "@metaplex-foundation/mpl-token-metadata";
import { publicKey } from "@metaplex-foundation/umi";
const umi = createUmi("https://api.devnet.solana.com");
const mint = publicKey("MintPubkey...");
const metadata = await fetchMetadata(umi, mint);
console.log(metadata.name, metadata.uri);
// Fetch JSON from URI
const json = await fetch(metadata.uri).then((r) => r.json());
console.log(json.image, json.attributes);๐ Resources
Last updated on