Theme

Candy Machine Commands

Candy Machine Commands

The MPLX CLI provides comprehensive support for creating and managing MPL Core Candy Machines on Solana. These commands allow you to create NFT collections with configurable minting rules, upload assets, and manage the entire candy machine lifecycle through an intuitive command-line interface.

Quick Start

Get started quickly with the interactive wizard:

mplx cm create --wizard

This single command handles everything to create a candy machine: asset validation, upload, candy machine creation including guard configuration, item insertion with progress tracking.

Command Overview

CommandPurposeKey Features
createCreate a new candy machineInteractive wizard, template generation, manual config
uploadUpload assets to storageIntelligent caching, progress tracking, validation
insertInsert items into candy machineSmart loading detection, batch processing
validateValidate asset cacheComprehensive validation, error reporting
fetchFetch candy machine infoDisplay configuration, guard settings, status
withdrawWithdraw and deleteClean withdrawal, balance recovery

Key Features

Interactive Wizard

  • Guided Setup: Step-by-step candy machine creation
  • Asset Validation: Comprehensive file and metadata validation
  • Progress Tracking: Real-time indicators for all operations
  • Error Recovery: Detailed error messages with actionable guidance

Intelligent Asset Management

  • Smart Caching: Reuses existing uploads when possible
  • Batch Processing: Efficient asset upload and insertion
  • File Validation: Ensures proper naming and metadata format
  • Collection Support: Automatic collection creation

Flexible Configuration

  • Guard Support: All Core Candy Machine guards supported
  • Guard Groups: Create different minting phases with distinct rules
  • Template Generation: Quick directory structure setup
  • Manual Configuration: Advanced users can create custom configs

Directory Structure

All candy machine commands work from a candy machine asset directory with this structure:

my-candy-machine/
├── assets/
│   ├── 0.png              # Image files (PNG, JPG)
│   ├── 0.json             # Metadata files
│   ├── 1.png
│   ├── 1.json
│   ├── ...
│   ├── collection.png      # Collection image
│   └── collection.json     # Collection metadata
├── asset-cache.json        # Asset upload cache (generated)
└── cm-config.json          # Candy machine configuration (generated when using the wizard)

Workflow Options

Perfect for beginners and most use cases:

mplx cm create --wizard

What it does:

  1. Validates assets and configuration
  2. Uploads all assets with progress tracking
  3. Creates the candy machine on-chain
  4. Inserts all items with transaction progress
  5. Provides comprehensive completion summary

Option 2: Manual Mode (Advanced)

For advanced users who want full control:

# 1. Set up directory and config manually
mkdir my-candy-machine && cd my-candy-machine
# (create assets/ directory and add your assets)

# 2. Upload assets
mplx cm upload

# 3. Create candy machine
mplx cm create

# 4. Insert items
mplx cm insert

# 5. Validate (optional)
mplx cm validate

Guard Configuration

The CLI supports all Core Candy Machine guards and guard groups:

Global Guards

{
  "guardConfig": {
    "solPayment": {
      "lamports": 1000000000,
      "destination": "111111111111111111111111111111111"
    },
    "mintLimit": {
      "id": 1,
      "limit": 1
    }
  }
}

Guard Groups (Minting Phases)

{
  "groups": [
    {
      "label": "wl",
      "guards": {
        "allowList": {
          "merkleRoot": "MerkleRootHash..."
        },
        "solPayment": {
          "lamports": 500000000,
          "destination": "111111111111111111111111111111111"
        }
      }
    },
    {
      "label": "public",
      "guards": {
        "solPayment": {
          "lamports": 1000000000,
          "destination": "111111111111111111111111111111111"
        }
      }
    }
  ]
}

Available Guards

The CLI supports all Core Candy Machine guards:

Payment Guards: solPayment, solFixedFee, tokenPayment, token2022Payment, nftPayment, assetPayment, assetPaymentMulti

Access Control: addressGate, allowList, nftGate, tokenGate, assetGate, programGate, thirdPartySigner

Time-Based: startDate, endDate

Limits: mintLimit, allocation, nftMintLimit, assetMintLimit, redeemedAmount

Burn Guards: nftBurn, tokenBurn, assetBurn, assetBurnMulti

Special: botTax, edition, vanityMint

Freeze Guards: freezeSolPayment, freezeTokenPayment

For detailed guard documentation, see the Core Candy Machine Guards reference.

Best Practices

🎯 Directory Organization

  • Keep each candy machine in its own directory
  • Use descriptive directory names
  • Maintain consistent asset naming (0.png, 1.png, etc.)
  • Back up your candy machine directories

📁 Asset Preparation

  • Use consistent naming (0.png, 1.png, etc.)
  • Ensure metadata JSON files match image files
  • Validate image formats (PNG, JPG supported)
  • Keep file sizes reasonable (< 10MB recommended)
  • Include collection.json with a valid "name" field

⚙️ Configuration

  • Test on devnet before mainnet
  • Use the wizard for guided configuration
  • Back up configuration files
  • Document guard settings
  • Consider adding at least one guard or guard group

🚀 Deployment

  • Verify candy machine creation
  • Test minting functionality
  • Monitor transaction status
  • Keep explorer links for verification

Next Steps

  1. Install the CLI if you haven't already
  2. Create your first candy machine using the wizard
  3. Explore guard configuration for advanced minting rules
  4. Learn about guard groups for phased launches
Previous
Fetch Asset or Collection