Skip to content

Repository files navigation

NFT Mint Program

A Solana smart contract built with Anchor for minting NFTs with a capped collection size of 444. This program integrates Metaplex Token Metadata for standardized NFT creation.

Features

  • Capped Collection: Limits the total number of NFTs minted to 444.
  • Metaplex Metadata: Utilizes Metaplex's Token Metadata standard for NFT attributes.
  • Mint Tracking: Uses a counter account to track the number of NFTs minted.
  • Cross-Program Invocation (CPI): Creates metadata accounts via CPI with Metaplex's Token Metadata program.

Requirements

  • Solana CLI: Install from Solana Docs.
  • Rust: Install from Rust-Lang.
  • Anchor 0.30.1: Install with cargo install --git https://github.com/coral-xyz/anchor anchor-cli --locked --force.
  • Node.js: Recommended version 16.x or higher.
  • Metaplex Token Metadata v5.1.0: Included via Cargo.toml dependency.

Installation

  1. Clone the Repository:
git clone https://github.com/your-repo/nft-mint-program.git
cd nft-mint-program
  1. Install Dependencies:
npm install
  1. Build the Program:
anchor build

Usage

Key Accounts

  • mint_counter: PDA (Program Derived Address) tracking the total minted NFTs (max 444).
  • mint: The NFT mint account (SPL Token).
  • metadata: Metaplex metadata account storing NFT attributes (name, symbol, URI, etc.).
  • token_account: Associated Token Account (ATA) for the payer to receive the minted NFT.
  • payer: The wallet signing and funding the transaction.

Functionality

The mint_nft instruction:

  1. Checks the mint_counter to enforce the 444 NFT limit.
  2. Creates a metadata account via CPI with Metaplex.
  3. Mints 1 token to the payer's ATA.
  4. Increments the mint_counter.

Security Precautions

  • Private Keys: Excluded via .gitignore. Never commit target/, node_modules/, or wallet keypairs.
  • Audits: Review code and dependencies before deployment.
  • Environment: Use a secure wallet and avoid exposing sensitive data in client-side code.

Information

Cargo.toml Configuration

To avoid compilation errors with Anchor and Anchor-SPL IDLs, update Cargo.toml with:

idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"]

This ensures the IDL is built correctly for both Anchor and Anchor-SPL dependencies.

Disclaimer

This code is for educational purposes. Audit and test thoroughly before deploying to mainnet.

About

A simple nft mint programme on the Solana network.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages