Skip to content

Instantly share code, notes, and snippets.

@jamland
Last active November 26, 2021 17:50
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • 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
@anthonyspiteri
Copy link

After building the metaplex cli using the second option... I'm getting this error

bitnami@ip-172-26-0-90:~/metaplex2/js/packages/cli$ metaplex help
pkg/prelude/bootstrap.js:1697
throw error;
^

Error: INTERNAL ERROR this file doesn't exist in the virtual file system :/snapshot/js/node_modules/canvas/build/Release/libpixman-1.so.0
at tryImporting (pkg/prelude/bootstrap.js:2046:19)
at process.dlopen (pkg/prelude/bootstrap.js:2103:7)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19)
at Module.require (pkg/prelude/bootstrap.js:1676:31)
at require (internal/modules/cjs/helpers.js:92:18)
at Object. (/snapshot/js/node_modules/canvas/lib/bindings.js:3:18)
at Module._compile (pkg/prelude/bootstrap.js:1751:22)

any ideas?

@VaxyFX
Copy link

VaxyFX commented Oct 21, 2021

After building the metaplex cli using the second option... I'm getting this error

bitnami@ip-172-26-0-90:~/metaplex2/js/packages/cli$ metaplex help pkg/prelude/bootstrap.js:1697 throw error; ^

Error: INTERNAL ERROR this file doesn't exist in the virtual file system :/snapshot/js/node_modules/canvas/build/Release/libpixman-1.so.0 at tryImporting (pkg/prelude/bootstrap.js:2046:19) at process.dlopen (pkg/prelude/bootstrap.js:2103:7) at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:14) at Module.require (internal/modules/cjs/loader.js:974:19) at Module.require (pkg/prelude/bootstrap.js:1676:31) at require (internal/modules/cjs/helpers.js:92:18) at Object. (/snapshot/js/node_modules/canvas/lib/bindings.js:3:18) at Module._compile (pkg/prelude/bootstrap.js:1751:22)

any ideas?

same problem, have u solved it?

@anthonyspiteri
Copy link

Nope... still waiting for a reply here.

@Solclubsandwich
Copy link

Awesome contribution! Thank you :)

@jamland
Copy link
Author

jamland commented Oct 26, 2021

@anthonyspiteri @VaxyFX sorry for the long reply.
Looks like you have some issue with a compiled version of metaplex. You can use not compiled version instead.
First build source code:

yarn run build

And then use candy-machine like this instead of metaplex command.

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

@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