With the new release of version 2 of the Metaplex Candy Machine on Solana, there are new additions and removals.
I would be writing on how to create a whitelisting spl-token with the candy machine version 2 on the devnet. (Don't be like me that experimented with mainnet-beta).
Phase 1: Setting up your environment
If you don't have solana on your system, you could do that by:
sh -c "$(curl -sSfL https://release.solana.com/v1.9.5/install)"
Update your PATH environment variable, then confirm the installation by running:
solana --version
For windows users, open your command line as an administrator and run:
curl https://release.solana.com/v1.9.5/solana-install-init-x86_64-pc-windows-msvc.exe --output C:\solana-install-tmp\solana-install-init.exe --create-dirs
Paste the following code in your terminal and click enter:
C:\solana-install-tmp\solana-install-init.exe v1.9.5
If there's a security pop-up, accept and sit back to install. Confrim your installation by running:
solana --version
Phase 2: Creating your token
Before you start your token creation, you would have to install the spl-cli. Run:
$ cargo install spl-token-cli
Next is to select your cluster - devnet, testnet or mainnet using the code:
$ solana config set --url //cluster url
Next generate your keypair by running:
solana-keygen new --outfile {$folder}/keypair-name.json
Save your generated key - both phrase and public key which would be printed. Next is to set your keypair and verify.
solana config set --keypair <your keypair>
To verify:
solana-keygen verify <your keypair> keypair-name.json
Next step is to airdrop some sol to the public address to enable you put to test what you are doing.
solana airdrop 10 <your keypair> --url https://devnet.solana.com
Finally, time to create your token. You would be using the spl-token command to create your token.
spl-token create-token
Next is to create an account to hold your token:
spl-token create-account <your token identifier>
Next step in this phase is to mint the number of tokens you want to use for your whitelisting.
spl-token mint <your token identifier> <number of tokens>
Final step in this phase is sending the tokens to the addresses of the recipients.
Phase 3: Creating your whitelist settings.
You now have the number of tokens you want to use for your whitelisting, next is to configure your whitelist settings.
First clone the repository:
git clone -b v1.1.1 https://github.com/metaplex-foundation/metaplex.git ~/metaplex
Next is to build the setting.
yarn install --cwd ~/metaplex/js/
To make sure everything is running as it should, run:
ts-node ~/metaplex/js/packages/cli/src/candy-machine-v2-cli.ts --version
You should have output of 0.0.2.
Make sure you have ts-node installed if not, you would run into errors.
Inside your folder, create a config.json file. Your directory should look like this:
~\metaplex\js\packages\cli\config.json
Then inside your config.json file, create the skeleton to be this way:
{
"price": 1.0,
"number": 10,
"gatekeeper": null,
"solTreasuryAccount": "<YOUR WALLET ADDRESS>",
"splTokenAccount": null,
"splToken": null,
"goLiveDate": "25 Dec 2021 00:00:00 GMT",
"endSettings": null,
"whitelistMintSettings": null,
"hiddenSettings": null,
"storage": "arweave-sol",
"ipfsInfuraProjectId": null,
"ipfsInfuraSecret": null,
"awsS3Bucket": null,
"noRetainAuthority": false,
"noMutable": false
}
The code above can be explained thus:
- Price: The price of your collection/token. If you don't intend to use the whitelist token for presale privileges, you can put 0.
- Number: This is the number of items in your assets folder.
- Gatekeeper: This is a captcha developed to reduce bots. To activate this, change this aspect to:
"gatekeeper": {
"gatekeeperNetwork" : "ignREusXmGrscGNUesoU9mxfds9AiYTezUKex2PsZV6",
"expireOnUse" : true
}
- SolTreasuryAccount: The account you intend to use for receiving payment in SOL.
- SplTokenAccount: This is the account that receives proceeds for the spl-token sale - that is if you want to sell them.
- SplToken: This is the mint address of the token that will be used as a means of payment.
- GoLiveDate: This is the date you intend for your collection to go live.
- WhitelistMintSettings: This is where you configure everything concerning your whitelisting token:
"whitelistMintSettings": {
"mode" : { "burnEveryTime": true },
"mint" : <your token unique id>
"presale" : true,
"discountPrice" : null
}
If you want the whitelist token to be burnt every time after use, leave the above setting. If not, set it to
"mode" : { "neverBurn": true },
If you want the token holders to have presale privileges, leave the presale setting as true, if not, make it false.
For discount price setting, it is set to null, but if you want these holders to have discount privileges, set the discount price eg 0.5 for half the price.
Next is the hidden settings. This setting does two things:
- Allows the creation of larger drops since the metadata is not stored on-chain.
- Allows for the creation of hide-and-reveal drops, where users discover which item(s) they minted after the mint is complete.
To enable this setting:
"hiddenSettings": {
"name":"My Hidden Collection ",
"uri":"uri",
"hash":"44kiGWWsSgdqPMvmqYgTS78Mx2BKCWzd"
}
Note that when enabled, all collection has the same metadata.
After you are satisfied with the above configuration, the next step is to upload your candy machine.
ts-node ~/metaplex/js/packages/cli/src/candy-machine-v2-cli.ts upload -e devnet -k ~/.config/solana/devnet.json -cp ~\metaplex\js\packages\cli\config.json -c example ~\metaplex\js\packages\cli\assets
As it is being uploaded, you will see the candy machine address. This is the address that you would point the machine UI to in your .env file.
And you have created your own whitelisting token with the candy machine v2. This process is the same when you want to deploy to the mainnet, the difference is you would be pointing your cluster to the mainnet-beta API and you would have enough SOL to prevent transaction error.
To know how much it would cost you to deploy your candy machine, https://feecalc.live/ will give you an estimate of what you should have in your wallet before deploying.
Skullmachina
Skullmachina is a collection of 1350 randomly generated gaming characters. Skullmachina is a haven for avid gamers who would love to earn while playing games.
The community is built with gamers in mind and a way to reward, engage and entertain them while looking to collaborate to make the gaming experience unique. Join our community here: https://discord.gg/3TFuWa9XHz