An annotated guide to the 'Metaplex Candy Machine' Tutorial
Published: 2021-09-17 23:46:31

{% github https://github.com/exiled-apes/candy-machine-mint %}


NFTS! They are all the craze, and have been for a minute. There is at least something interesting about minting tokens, by the creator of the art, to signify someone "owns" something.  

Earlier this year I got really into computer generated art. I automated some scripts that would take 8 hours on my personal computer down to 5 minutes on AWS. 

I wanted to see if I could combine this computer generated art and timed releases for fun. More on that at a later date. Right now we are focusing on getting through this [tutorial](https://hackmd.io/@levicook/HJcDneEWF). Now I have never touched anything solana before today, and I am up and running. It's possible. 

## Tutorial Annotation as of September 17th, 2021

![Screen Shot 2021-09-17 at 7.15.48 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cdxw3ymdbq3leanh95fe.png)

The only thing I would note about the top instructions is, I would also run 
```
brew install jq
```
The `yarn run package:macos` build step did not work for me. I had to run:
```
npx pkg . -d --targets node14-macos-x64 --output bin/macos/metaplex
```
Next I used zsh and my path is `/usr/local/bin` so my command was
```
 cp bin/macos/metaplex /usr/local/bin
```

I followed the tutorial until:

![Screen Shot 2021-09-17 at 7.28.49 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9g961eyh146vyz48j8ee.png)

I created a folder called assets in a random directory. I then added 5 images and 5 .json files. Here is my json file from 0.png
```json
{
    "name": "png0",
    "symbol": "",
    "description": "testing dreamland",
    "seller_fee_basis_points": 5,
    "image": "https://www.arweave.net/abcd5678?ext=png",
    "external_url": "google.com",
    "collection": {
        "name": "Dreamland Test",
        "family": "Dreamland"
    },
    "properties": {
        "files": [
            {
                "uri": "https://www.arweave.net/abcd5678?ext=png",
                "type": "image/png"
            }
        ],
        "category": "image/png",
        "creators": [
            {
                "address": "REDACTED",
                "share": 100
            }
        ]
    }
}
``` 

Now it's my understanding that matrix replaces the url once you upload. The parts that matter are `seller_fee_basis_points` and `creators`. I'm not totally sure what is _required_, but this was a good read about the [metadata file](https://medium.com/metaplex/metaplex-metadata-standard-45af3d04b541).

Next I verified all the properties they were looking for. This is where `brew install jq` is helpful. Lastly I just `cd` into assets directory so my final command was:

```
metaplex upload . --env devnet --keypair ~/.config/solana/devnet.json
```
The articles mentions multiple errors, I did not get any. Next we need to look at our cache file to grab the config id:
```
code .cache/devnet-temp
```

I would then give it a few minutes. The article says to call a `metaplex verify` but that cannot be done without a create candy machine. To create one in my terminal I run 
```
metaplex create_candy_machine --keypair ~/.config/solana/devnet.json
```
And it returns: `candy machine pubkey`. Keep this value close.

### Setting mint date
To set the mint date you need to pass in a date string. I learned this by running `metaplex update_candy_machine -h`

![Metaplex update options](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/otikytte3p9ovfmnbjjd.png)
 
Now we have all the necessary values set, we need to head over to our .env file on our frontend.

```
// from .cache/devnet-temp
// config value
REACT_APP_CANDY_MACHINE_CONFIG=
// return value from create_candy_machine
// candy machine pubkey
REACT_APP_CANDY_MACHINE_ID=
// I just put my solana wallet address?
REACT_APP_TREASURY_ADDRESS=
// unix date
// 1631923920
REACT_APP_CANDY_START_DATE=1631923920

REACT_APP_SOLANA_NETWORK=devnet
REACT_APP_SOLANA_RPC_HOST=https://explorer-api.devnet.solana.com
```

I didn't include quotes with my values. After all of this you should be able to `Yarn Start` and be able to connect your wallet.

Shout out [Levi Korg](https://twitter.com/levicook_) for putting so much work in. I'm excited to learn more about matrix and hopefully host my own auction.


Hope this helps someone!