NFT Mint
NFT collection management with on-chain metadata
Pending
Anchor 0.32
Program ID
HoNCn3uuMYzQ83i4zjHWhUqEBY9DNEqJfu9vKJF8NQWU
Repository
ExpertVagabond/solana-nft-mint
Binary Size
248K
Cluster
Devnet
Instructions
IX
create_collection
Creates a new NFT collection with a name, symbol, and maximum supply cap.
| Parameter | Type | Description |
|---|---|---|
name | String | Collection name (max 32 characters) |
symbol | String | Collection symbol (max 8 characters) |
max_supply | u64 | Maximum number of NFTs that can be minted |
IX
mint_nft
Mints a new NFT within the collection, storing the metadata URI hash on-chain.
| Parameter | Type | Description |
|---|---|---|
uri_hash | [u8; 32] | SHA-256 hash of the metadata URI (JSON stored off-chain) |
IX
update_metadata
Updates the metadata URI hash for an existing NFT. Only callable by the collection authority.
| Parameter | Type | Description |
|---|---|---|
new_uri_hash | [u8; 32] | New SHA-256 hash of the updated metadata URI |
Accounts
Collection
| Field | Type | Description |
|---|---|---|
authority | Pubkey | Collection creator and admin |
name | String | Collection name |
symbol | String | Collection ticker symbol |
max_supply | u64 | Maximum mintable NFTs |
current_supply | u64 | Number of NFTs already minted |
bump | u8 | PDA bump seed |
NftMetadata
| Field | Type | Description |
|---|---|---|
collection | Pubkey | The collection this NFT belongs to |
mint | Pubkey | SPL token mint for this NFT |
token_id | u64 | Sequential token ID within the collection |
creator | Pubkey | Wallet that minted this NFT |
uri_hash | [u8; 32] | Hash of the metadata URI |
created_at | i64 | Unix timestamp of minting |
bump | u8 | PDA bump seed |
PDA Derivation
collection
seeds = [b"collection", authority]
metadata
seeds = [b"metadata", collection, nft_mint]
Error Codes
NameTooLong
Collection name exceeds the maximum 32 character limit
SymbolTooLong
Collection symbol exceeds the maximum 8 character limit
MaxSupplyReached
Cannot mint more NFTs - maximum supply has been reached
Overflow
Arithmetic overflow in supply tracking
Usage Example
import { Program, BN } from "@coral-xyz/anchor"; import { PublicKey, Keypair } from "@solana/web3.js"; import { createHash } from "crypto"; // Create collection const [collectionPda] = PublicKey.findProgramAddressSync( [Buffer.from("collection"), authority.publicKey.toBuffer()], program.programId ); await program.methods .createCollection("My NFT Collection", "MNFT", new BN(10_000)) .accounts({ collection: collectionPda, authority: authority.publicKey, }) .signers([authority]) .rpc(); // Mint an NFT const nftMint = Keypair.generate(); const uriHash = createHash("sha256") .update("https://arweave.net/abc123/metadata.json") .digest(); await program.methods .mintNft([...uriHash]) .accounts({ collection: collectionPda, nftMint: nftMint.publicKey, creator: authority.publicKey, }) .signers([authority, nftMint]) .rpc();