next-candy-machine
The Candy-Machine-Mint project is designed to let users fork, customize, and deploy their own candy machine mint app to a custom domain, ultra fast.
This Candy Machine takes heavily from Exiled Apes and kevinfaveri, and would not be possible without them, but attempts to simplify and provide an easy-to-follow and complete guide.
This guide will not cover topics such as XXX.
I recommend using Linux to make this process as easy as possible.
Getting Set Up
Prerequisites
-
Ensure you have recent versions of both
node
andyarn
installed. -
Follow the instructions here to install the Solana Command Line Toolkit.
-
Follow the instructions here to install the Metaplex Command Line Utility.
- Installing the Command Line Package is currently an advanced task that will be simplified eventually.
Installation
- Clone the project
git clone https://github.com/maxwellfortney/next-candy-machine
- Install yarn dependencies
cd next-candy-machine
yarn install
- rename the
.env.template
file at the root directory to.env.local
.
Initialize treasury SOL keypair
- Set URL to devnet
solana config set --url https://api.devnet.solana.com
- Generate a new keypair
solana-keygen new --outfile ~/.config/solana/devnet.json
- Set the keypair in your Solana config
solana config set --keypair ~/.config/solana/devnet.json
pubkey
, and will be our treasury SOL address. Set NEXT_PUBLIC_TREASURY_ADDRESS
in our .env.local
to this address.
This will output our 1st required environment variable into the terminal as - Airdrop SOL to wallet (repeat command if desired)
solana airdrop 1
Create, upload, and verify images and metadata
This guide will not cover creating images and metadata. For more info see Token Metadata Standard as well as Prepare NFT Assets.
The following commands assume your images and metadata are located at the home directory under nft-assets ~/nft-assets/
.
- Upload assets
ts-node ~/metaplex-foundation/metaplex/js/packages/cli/src/candy-machine-cli.ts upload ~/nft-assets --env devnet --keypair ~/.config/solana/devnet.json
initialized config for a candy machine with publickey
, and will be a SOL address. Set NEXT_PUBLIC_CANDY_MACHINE_CONFIG
in our .env.local
to this address.
This will output our 2nd required environment variable into the terminal as initialized config for a candy machine with publickey
if not output into the terminal, delete the file located at ./cache/devnet-temp.json
and re-run the command in step 1 above.
If - (Optional, but recommended) Verify your assets. If all is well, this command will finish with output
ready to deploy!
ts-node ~/metaplex-foundation/metaplex/js/packages/cli/src/candy-machine-cli.ts verify -k ~/.config/solana/devnet.json
Create a candy machine
- Run the following command to create a candy machine
ts-node ~/metaplex-foundation/metaplex/js/packages/cli/src/candy-machine-cli.ts create_candy_machine -k ~/.config/solana/devnet.json
candy machine pubkey
, and will be a SOL address. Set NEXT_PUBLIC_CANDY_MACHINE_ID
in our .env.local
to this address.
This will output our 3rd required environment variable into the terminal as Update our new candy machine
We need to set a price in SOL, as well as a mint start date for our candy machine.
- This command will set the price to 1 SOL, and the mint start date to the current time in epoch time.
ts-node ~/metaplex-foundation/metaplex/js/packages/cli/src/candy-machine-cli.ts update_candy_machine -k ~/.config/solana/devnet.json -p 1 -d now
updated startDate timestamp
, and will be a epoch time. Set NEXT_PUBLIC_CANDY_START_DATE
in our .env.local
to this time.
This will output our 4th required environment variable into the terminal as We are done!!
You can now start the NextJs app by running yarn dev
and navigating to http://localhost:3000/
, connect your desired wallet and begin minting your devnet new NFTs.
Deployment to Vercel and migration to mainnet-beta
.env.local
variables
Changing your - Change
NEXT_PUBLIC_SOLANA_NETWORK
tomainnet-beta
- Change
NEXT_PUBLIC_SOLANA_RPC_HOST
tohttps://api.mainnet-beta.solana.com
your preffered RPC URL such as QuickNode
Deploying to Vercel
- Connect your Github account to Vercel
- Create a new project from your repo
- Before clicking
Deploy
, add all of your environment variables - Click
Deploy