solana/metaplex-nft

Metaplex NFT Minting

solanadocs✅ Verifiedconfidence highhealth 100%
v1.0.0·by Metaplex Foundation·Updated 3/20/2026

Overview

Metaplex is the standard NFT infrastructure on Solana. Candy Machine v3 handles collection minting with guards (payment, whitelist, etc.). The umi SDK is the modern TypeScript client replacing the old @metaplex-foundation/js.

Setup umi

import { createUmi } from '@metaplex-foundation/umi-bundle-defaults'
import { mplCandyMachine } from '@metaplex-foundation/mpl-candy-machine'
import { mplTokenMetadata } from '@metaplex-foundation/mpl-token-metadata'
import { keypairIdentity } from '@metaplex-foundation/umi'

const umi = createUmi('https://api.devnet.solana.com')
  .use(mplTokenMetadata())
  .use(mplCandyMachine())

// Load keypair
const keypair = umi.eddsa.createKeypairFromSecretKey(secretKeyBytes)
umi.use(keypairIdentity(keypair))

NFT Metadata Standard

{
  "name": "My NFT #1",
  "symbol": "MNFT",
  "description": "A description of my NFT",
  "image": "https://arweave.net/abc123/image.png",
  "attributes": [
    { "trait_type": "Background", "value": "Blue" },
    { "trait_type": "Rarity", "value": "Rare" }
  ],
  "properties": {
    "files": [{ "uri": "https://arweave.net/abc123/image.png", "type": "image/png" }],
    "category": "image"
  }
}

Create Collection NFT

import { createNft, fetchDigitalAsset } from '@metaplex-foundation/mpl-token-metadata'
import { generateSigner, percentAmount } from '@metaplex-foundation/umi'

const collectionMint = generateSigner(umi)

await createNft(umi, {
  mint: collectionMint,
  name: 'My Collection',
  symbol: 'MC',
  uri: 'https://arweave.net/metadata.json',
  sellerFeeBasisPoints: percentAmount(5), // 5% royalty
  isCollection: true,
}).sendAndConfirm(umi)

Candy Machine v3

import { create, addConfigLines } from '@metaplex-foundation/mpl-candy-machine'
import { generateSigner, sol, dateTime } from '@metaplex-foundation/umi'

const candyMachine = generateSigner(umi)

// Create
await create(umi, {
  candyMachine,
  collectionMint: collectionMint.publicKey,
  collectionUpdateAuthority: umi.identity,
  itemsAvailable: 1000,
  sellerFeeBasisPoints: percentAmount(5),
  guards: {
    solPayment: { lamports: sol(0.1), destination: umi.identity.publicKey },
    startDate: { date: dateTime('2026-04-01T00:00:00Z') },
  },
}).sendAndConfirm(umi)

// Add items
await addConfigLines(umi, {
  candyMachine: candyMachine.publicKey,
  index: 0,
  configLines: [
    { name: '#1', uri: 'https://arweave.net/item1.json' },
    { name: '#2', uri: 'https://arweave.net/item2.json' },
  ],
}).sendAndConfirm(umi)

Mint from Candy Machine

import { mintV2 } from '@metaplex-foundation/mpl-candy-machine'
import { setComputeUnitLimit } from '@metaplex-foundation/mpl-toolbox'
import { transactionBuilder, generateSigner } from '@metaplex-foundation/umi'

const nftMint = generateSigner(umi)

await transactionBuilder()
  .add(setComputeUnitLimit(umi, { units: 800_000 }))
  .add(mintV2(umi, {
    candyMachine: candyMachine.publicKey,
    nftMint,
    collectionMint: collectionMint.publicKey,
    collectionUpdateAuthority: umi.identity.publicKey,
  }))
  .sendAndConfirm(umi)

Installation

npm install @metaplex-foundation/umi-bundle-defaults
npm install @metaplex-foundation/mpl-candy-machine
npm install @metaplex-foundation/mpl-token-metadata

Reference