Skip to content

Instantly share code, notes, and snippets.

@jamland
Last active November 26, 2021 17:50
Show Gist options
  • Save jamland/00a88e29829353ce8cb91a347efcbb0e to your computer and use it in GitHub Desktop.
Save jamland/00a88e29829353ce8cb91a347efcbb0e to your computer and use it in GitHub Desktop.
Metaplex Candy Machine help

@metaplex/cli aka Candy Machine Help

Format

  • Folder with files named from 0-1.png
  • JSON file with attributes, format
    • Array with indices matching images
    • Contains: title, description and array of traits ({"display_type":"number","trait_type":"generation","value":2})

Quick Start

1. Build

Install dependencies inside js folder

cd metaplex/js
yarn install
yarn bootstrap
yarn build

Build metaplex cli tool

yarn run package:macos
// or
npx pkg . -d --targets node14-macos-x64 --output bin/macos/metaplex

Add metaplex cli to $PATH

sudo cp bin/macos/metaplex /usr/local/bin

Alternatively use can use unpacked version after build with node command:

node ./build/candy-machine-cli.js 

2. Use

Upload assets to the arweave and register for candy-machine (get keypair path with solana config get). Should follow Metaplex NFT Standard

metaplex upload ./assets --env devnet -k path_to_your_keypair

Verify assets

 metaplex verify -k path_to_your_keypair

Start candy_machine

metaplex create_candy_machine  -e devnet -k path_to_your_keypair

Set sale start date

metaplex update_candy_machine -d "20 Sep 2021 10:12:00 GMT" -k path_to_your_keypair

Mint NFT to your wallet

metaplex mint_one_token -e devnet -k path_to_your_keypair

Verify NFT inside your wallet. Should be one new token with balance 1

spl-token accounts

Assets Folder

  • Folder with file pairs named from with growing integer numbers starting from 0.png and 0.json
  • the image has to be a PNG
  • JSON format can be checked out here: https://docs.metaplex.com/nft-standard. example below:
{
  "name": "Solflare X NFT",
  "symbol": "",
  "description": "Celebratory Solflare NFT for the Solflare X launch",
  "seller_fee_basis_points": 0,
  "image": "image.png",
  "animation_url": "https://www.arweave.net/efgh1234?ext=mp4",
  "external_url": "https://solflare.com",
  "attributes": [
    {
      "trait_type": "web",
      "value": "yes"
    },
    {
      "trait_type": "mobile",
      "value": "yes"
   },
   {
      "trait_type": "extension",
      "value": "yes"
    }
  ],
  "collection": {
     "name": "Solflare X NFT",
     "family": "Solflare"
  },
  "properties": {
    "files": [
      {
        "uri": "image.png",
        "type": "image/png"
      },
    ],
    "category": "image",
    "creators": [
      {
        "address": "creator_sol_address",
        "share": 100
      }
    ]
  }
}

SPL Token use

The main modifications are:

create_candy_machine has two new options spl-token and spl-token-account. spl-token specifies the spl token to price the mint in. spl-token-account specifies the token account the mint payments are sent to. mint_one_token has one new option spl-token-account. This specifies the token account the user wishes to pay from. Example usage:

metaplex create_candy_machine --env devnet --keypair /Users/crisp/.config/solana/id.json --spl-token 91MgcgxP8vNg66bb9YDPLdBVbMo5spM9uHbWho85A117 --spl-token-account AQiwnd9uVyY39n32ZWnmpwEgBeq9TQJsBHeq3jWDKpvf

metaplex mint_one_token --env devnet --keypair /Users/crisp/.config/solana/id.json --spl-token-account AQiwnd9uVyY39n32ZWnmpwEgBeq9TQJsBHeq3jWDKpvf
@jamland
Copy link
Author

jamland commented Oct 26, 2021

also, consider asking questions on metaplex discord (they have candy-machine channel) or writing me on Twitter for quicker response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment