Sol.College

NFTs with Metaplex

Most Solana NFTs follow Metaplex standards. Token Metadata attaches a metadata account to a supply-1 mint, and Metaplex Core is a newer single-account asset standard. Code typically builds these instructions with the Umi framework on the client, or calls the Metaplex programs through CPI from a program.

Reference: Metaplex developer docs · Solana docs: Tokens

Real code, line by line

2 excerpts from different projects. Each caption links the exact lines at the fork's pinned commit. The notes below each excerpt explain the lines that matter.

asimnecip/gree · web/src/app/gree/gree-data-access.tsx L6–31 @ 7ef8c89 · MIT · original
import { useCluster } from '../cluster/cluster-data-access';import { useAnchorProvider } from '../solana/solana-provider';  // import { walletAdapterIdentity } from "@metaplex-foundation/umi-signer-wallet-adapters";// import { getAssociatedTokenAddress } from "@solana/spl-token";// import {// 	findMasterEditionPda,// 	findMetadataPda,// 	mplTokenMetadata,// 	MPL_TOKEN_METADATA_PROGRAM_ID,// } from "@metaplex-foundation/mpl-token-metadata";// import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";// import { publicKey } from "@metaplex-foundation/umi"; // import {// 	TOKEN_PROGRAM_ID,// 	ASSOCIATED_TOKEN_PROGRAM_ID,// } from "@solana/spl-token";    export function useGreeProgram() {  const { connection } = useConnection();  const { cluster } = useCluster();
restacked-dev/valhalla · web/src/instructions/create.tsx L27–52 @ 7aa9ddf · MIT · original
import { ICreateForm } from "../utils/interfaces";import { Thread } from "@clockwork-xyz/sdk";import { WalletContextState } from "@solana/wallet-adapter-react";import axios from "axios";import { isPublicKey } from "@metaplex-foundation/umi";import { randomBytes } from "crypto";import { sendTransaction } from "../utils/sendTransaction";import { toast } from "react-toastify"; export const createVault = async (  connection: Connection,  wallet: WalletContextState,  vaultsToCreate: ICreateForm[],  totalVestingDuration: number): Promise<{ txIds: string[] }> => {  for (let i = 0; i < vaultsToCreate.length; i++) {    const isValid = await vaultValid(      connection,      wallet,      vaultsToCreate[i],      vaultsToCreate    );     if (!isValid) {      toast.error("There is an issue with the vault. Please check the form.");      return { txIds: [] };
  1. Line 33 import { sendTransaction } from "../utils/sendTransaction";: Submits the signed transaction to the cluster.

Go further