Create a Token Metadata NFT Collection on Solana with Candy Machine

If you are looking to launch an NFT Collection on Solana the Sugar CLI toolkit will abstract some of the trickier setup and management steps for you providing you with a automated launch system to create Candy Machines on the Solana blockchain.

Prerequisite

  • Solana CLI installed and configured. Installation
    • File system wallet generated using the CLI
    • Wallet to be funded either with either mainnet or devnet SOL

Initial Setup

Installing Sugar

Mac/Linux

bash <(curl -sSf https://sugar.metaplex.com/install.sh)

Windows

you can install Sugar using the following url to download the installation executable:

https://github.com/metaplex-foundation/winstaller/releases/latest/download/winstaller.exe

Try to run the binary by double-clicking on it. If you get a pop-up message warning about an untrusted binary try clicking More Info and then Run Anyway.

Preparing Your Assets

NFTs have two fundamental parts, the image, and the metadata.

The image is what is showcased and displayed in wallets and markets while the metadata contains all the relevant information for that NFT on the blockchain such as name, what link to find the image at, the attributes of the NFT.

Assets Folder

When executing commands from Sugar, Sugar will expecting to find an assets folder in the directory you are launching the command from.

Both your images and your metadata files will reside in the assets folder.

File Naming

Images and Metadata JSON files are expected to follow an incremental index naming convention starting from 0.

If any indices are missed of if the image and metadata folders do not include the same amount of files then folder validation will fail.

assets/
├─ 0.png
├─ 0.json
├─ 1.png
├─ 1.json
├─ 2.png
├─ 2.json
├─ ...

Metadata JSON

FieldTypeDescription
namestringName of the asset.
descriptionstringDescription of the asset.
imagestringURI pointing to the asset's logo.
animation_urlstringURI pointing to the asset's animation.
external_urlstringURI pointing to an external URL defining the asset — e.g. the game's main site.
attributesarrayArray of attributes defining the characteristics of the asset.
  • trait_type (string): The type of attribute.
  • value (string): The value for that attribute.
propertiesobjectAdditional properties that define the asset.
  • files (array): Additional files to include with the asset.
    • uri (string): The file's URI.
    • type (string): The file's type. E.g. image/png, video/mp4, etc.
    • cdn (boolean, optional): Whether the file is served from a CDN.
  • category (string): A media category for the asset. E.g. video, image, etc.
{
  "name": "My NFT #1",
  "description": "My NFT Collection",
  "image": "https://arweave.net/26YdhY_eAzv26YdhY1uu9uiA3nmDZYwP8MwZAultcE?ext=jpeg",
  "external_url": "https://example.com",
  "attributes": [
    {
      "trait_type": "trait1",
      "value": "value1"
    },
    {
      "trait_type": "trait2",
      "value": "value2"
    }
  ],
  "properties": {
    "files": [
      {
        "uri": "https://www.arweave.net/abcd5678?ext=png",
        "type": "image/png"
      }
    ],
    "category": "image"
  }
}

Example Images and Metadata

If you wish to use example images and metadata to create your Candy Machine you can download them from our github here in zip format by clicking the green code button and selecting the `zip format.

https://github.com/metaplex-foundation/example-candy-machine-assets

Alternatively if you have git installed you can clone the assets to your system or download a zipped copy from the link provided

git clone https://github.com/metaplex-foundation/example-candy-machine-assets.git

Image and Metadata Generators

If you need to generate artwork images and metadata from layers there are several automated scripts and websites where you can supply the generator with your image layers and some basic information about your project and it will generate x number of Asset Image and JSON Metadata combos based on your parameters given.

NametypeDifficultyRequirementsFree
nftchefscript⭐⭐⭐⭐JS knowledge
hashlipsscript⭐⭐⭐⭐JS knowledge
Nft Art Generatorweb UI⭐⭐
buenoweb UIunknown

Collection Details

For the creation of the Collection we need the same details we would as a NFT Asset which is a image file, and a metadata json file. These would be placed in the root of the asset/ folder folder like so:

assets/
├─ collection.jpg/
├─ collection.json/
├─ 0.png
├─ 0.json
├─ 1.png
├─ 1.json
├─ 2.png
├─ 2.json
├─ ...

The collection metadata file is the same format as a NFT Asset json file. In the case of the Collection you can omit filling out the attributes field.

{
  "name": "My Collection",
  "description": "This is My Nft Collection",
  "image": "collection.jpg",
  "external_url": "https://example.com",
  "properties": {
    "files": [
      {
        "uri": "https://example.com/1.jpg",
        "type": "image/jpg"
      }
    ],
    "category": "image"
  }
}

Sugar

By default Sugar will use the same config configuration file used by the Solana CLI to load the default values to use such as:

  • The wallet set by Solana CLI
  • The RPC URL set by Solana CLI

Sugar Launch

Once your assets folder is in good order you can start the deployment process with Sugar. The first command we will run is

sugar launch

This will start Sugars CLI process to gather information regarding the deployment of your Candy Machine.

If sugar does not find a configuration file it was ask you to create one.

The following questions will then be asked for you till fill out

Found xx file pairs in "assets". Is this how many NFTs you will have in your candy machine?
Found symbol "xxxx" in your metadata file. Is this value correct?
Found value xxx for seller fee basis points in your metadata file. Is this value correct?
Do you want to use a sequential mint index generation? We recommend you choose no.
How many creator wallets do you have? (max limit of 4)

Create wallets are used to distribute royalties. If selection you will be asked to enter the address and share amount for each wallet.

Which extra features do you want to use? (use [SPACEBAR] to select options you want and hit [ENTER] when done)

For this guide we are going to leave hidden settings unselected and proceed by hitting enter

What upload method do you want to use?

For this guide we are going to select Bundlr

Do you want your NFTs to remain mutable? We HIGHLY recommend you choose yes.

Select yes(y) for this option so we can edit the NFTS in the future if we need to.

Sugar should now start the process of

  • Creating and uploading the Collection NFT
  • Uploading your assets to Arweave using Irys (formerly known as Bundlr)
  • Create the Candy Machine

If successful you will be greeted with the following message but containing your own Candy Machine address within the link:

https://www.solaneyes.com/address/Beag81WvAPUCeFpJ2qFnvd2f1CFCpQBf3abTJXA1fH9o?cluster=devnet

Congratulations you just created a Candy Machine on Solana. If you click the above link you can view your Candy Machine details on chain.

Updating the Candy Machine with Guards and Groups

Currently your Candy Machine has no Guards attached. By default if no Candy Guard is attached to the Candy Machine only the mint authority (which is you) can mint from the Candy Machine.

So solve this we have to attach Guards to the Candy Machine which allows the public to mint from the Candy Machine following a set of rules. For example we might want the public to be able to mint from the Candy Machine while charging the user 1 SOL. For this we can use a Sol Payment Guard.

Adding Guard (SOL Payment)

To add the Sol Payment Guard to the Candy Machine we will need to open up the config.json file that Sugar generated in the root of our folder where we launched sugar launch in the terminal.

The config file will look like this:

{
  "tokenStandard": "nft",
  "number": 16,
  "symbol": "NUMBERS",
  "sellerFeeBasisPoints": 500,
  "isMutable": true,
  "isSequential": false,
  "creators": [
    {
      "address": "B1kwbSHRiXFPYvNbuhCX92ibngzxdmfBzfaJYuy9WYp5",
      "share": 100
    }
  ],
  "uploadMethod": "bundlr",
  "ruleSet": null,
  "awsConfig": null,
  "sdriveApiKey": null,
  "nftStorageAuthToken": null,
  "shdwStorageAccount": null,
  "pinataConfig": null,
  "hiddenSettings": null,
  "guards": null,
  "maxEditionSupply": null
}

Here we can edit the guards field towards the end of the configuration file and fill out the destination address we want the SOL Payment to go to.

"guards": {
    "default": {
        "solPayment": {
            "value": 1,
            "destination": "11111111111111111111111111111111"
        }
    }
},

Once you have added the guard to the config.json save the file and run the command:

sugar guard add

If you had previously already created a Candy Guard you can instead run the command:

sugar guard update

This will create the Candy Guard and add the SOL Payment Guard to default guard list.

Show the Candy Machine

To show the Candy Machine details in your terminal you can run the command

sugar show

This will list out all the Candy Machine and Guard Details minus all the inserted items.

Show the Candy Guard

To show the Candy Machine details in your terminal you can run the command

sugar guard show

This will list out all the Candy Machine and Guard Details minus all the inserted items.

Next Steps

Now you have a functioning Candy Machine you would now need to host the Candy Machine on a web UI so that people are able to mint from the Candy Machine.

You can either generate your own UI and use the umi client wrapper and mpl-candy-machine SDK or you can use a prebuilt community UI and just supply the details of your Candy Machine.

Developing a UI Resources

Further Reading