NOTE: This repo will prob only work on unix-based environments.
The NFT Candy Factory project is designed to let users fork, customize, and deploy their own candy machine mint app to a custom domain, ultra fast.
A candy machine is an on-chain Solana program for managing fair mint. Fair mints:
- Start and finish at the same time for everyone.
- Won't accept your funds if they're out of NFTs to sell.
It builds on top of the the work started at https://github.com/exiled-apes/candy-machine-mint, abstracting away a few things (like having one-command shortcuts in the package.json that instantly setups dev env), improving DX and adding new tools for managing the source files.
Techwise, it builds on top of NextJS and TailwindCSS for the frontend (as well as Solana Labs toolchain and Serum Anchor libs for interacting with the Solana network); and Metaplex and Solana clis for deployment on the Solana network. It also adds Strapi as the nft-manager
which is in reality used just as a UI for managing the JSON and PNG files. More details below.
-
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.
To run the project, first create a .env
file at the root directory and define the following variables:
NEXT_PUBLIC_CANDY_MACHINE_CONFIG="redacted"
This is a Solana account address. You can get the value for this from the .cache/temp
file. This file is created when you run the metaplex upload
command in terminal.
NEXT_PUBLIC_CANDY_MACHINE_ID="redacted"
Same as above; this is a Solana account address. You can get the value for this from the candy-machine-log.txt
log file. This file is created when you run the metaplex create_candy_machine
command in terminal.
NEXT_PUBLIC_CANDY_START_DATE=1630422000000
This is a unix time stamp that configures when your mint will be open. Use the same one used in the setup-metaplex-env.sh
script. You can get the value for this from the candy-machine-start-date.txt
log file (don't forget to add three zeros at the end of this value).
NEXT_PUBLIC_SOLANA_NETWORK=devnet
This identifies the Solana network you want to connect to. Options are devnet
and mainnet-beta
.
NEXT_PUBLIC_SOLANA_RPC_HOST=https://explorer-api.devnet.solana.com
This identifies the RPC server your web app will access the Solana network through.
NEXT_PUBLIC_TREASURY_ADDRESS="redacted"
This the Solana address that receives the funds gathered during the minting process.
! NOTE: Be sure to an instance of postgresql running on port 6432. For ease of use, one is provided using docker + docker-compose by running yarn start-nft-manager-db
This repo features an NFT manager so you do not need to create all nfts by editing a JSON file that is powered by Strapi. Just run yarn nft-manager
and add:
- A collection
- An NFT that links to that collection
! NOTE: Be sure to create an user, after you login with the admin account, that has the role "authenticated", username "admin" and pass "Admin123", as well as add all collections and upload related permissions to the "authenticated" role; otherwise, the yarn update-creator-all-rows
and yarn generate-nft-sources
commands will not work.
Then you are good to go: run yarn generate-nft-sources
for generating the JSON and PNG files in the nfts-sources
folder in the root of the project. Following that, you can go for deployment on production (section below) OR test it in dev using yarn setup-dev
.
You are able to change the NFT manager form default values by editing the file ./nft-manager/api/nf-ts/models/nf-ts.settings.json
.
In the project root directory, you can run:
yarn nft-manager
-- Setup development server of the NFT-Manager, which is a UI for managing all NFTs.
! - The following commands of the nft-manager needs the nft-manager running, so be sure to run yarn nft-manager
before running them:
yarn update-creator-all-rows
-- Set a new creator address to all NFT rowsyarn generate-nfts-sources
-- Generate nft source files based on the nft-manager data; allow to generate randomized or DB index order
yarn setup-dev
-- Setup development environment: needs solana and metaplex cli installed (it will create a new Solana wallet, drop some sols there, and upload the resources to the devnet Metaplex program, making it ready to test using yarn dev...). This command automatically generates the.env.local
file for you with the start date, candy machine addresses, and treasury addresses.
Note: you still need to run yarn generate-nfts-sources for it to work.
ALERT: Running this command will replace your Solana devwallet generated before at ~/.config/solana/candyfactory-devnet.json
as well as all previous environment stuff you had, like your .env.local
. It is a nuke solution for resetting development environment. If you already have the setup done use the scripts declared in this command or tweak them (they are available in the devtools
folder in the root of the project)
yarn dev
-- Run NextJS devserver; it features a modal for connecting with Phantom, Solflare and Sollet (more can be added using the Solana Labs wallet library); minting of the NFT; success/error messages; and UI countdown based on the candy machine start date.
yarn deploy-mainnet
-- Setup production environment: needs Solana and Metaplex cli installed. Refer to the #Deployment section below.yarn build
-- Bundle for production environmentyarn start
-- Start production build project
- Don't forget to use the wallet you want to earn the mint value for both metaplex uploading (
yarn deploy-mainnet
) and in the NFT's creators.address[0] (NFT-Manager properties editor of a specific NFT) for earning the royaties. - You still need to run
yarn generate-nfts-sources
if you have not created the source files yet - You should have all your NFTs ready before deploying. Incremental deploying of NFTs is not supported right now. Feel free to add a PR tho if you find a solution for this
For deploying your collection on the mainnet just run yarn deploy-mainnet
and answer the questions as prompted. It will store your wallet key in our path: ~/.config/solana/candyfactory-mainnet.json
(if you want to edit that just tweak setup-solana-mainnet.sh). It is the same process as used for the development environment but asking for importing a Wallet PK (that should have enough SOLs and will be the one that will receive the mint value).
After the deployment is over, it will generate all envs that your frontend dApp needs in a file called .env.local.production
in the root of the project. These env values should then be added as environment variables where you build your dAapp (if Vercel, you need to add to their ENVIROMENT VARIABLES
config section).
If this helped you on shipping your first NFT candy factory, feel free to drop a donation on:
- Solana Network: Ggm8Pmwx2HSv3LMTT7mGSSGKU14d4WnTnnXozmx9m46a
- Ethereum Network: 0x0aa037390619Ecb58974A983131986210cd03dF5
Also, if possible, follow me on https://twitter.com/kevinfaveri_ and https://twitter.com/aiphotos_ (which is the art project that inspired this repository) :)