How to Deploy and Mint NFTs on Solana? (via Metaplex)

Speedrunner
4 min readNov 23, 2021

--

Hello NFT developers/enthusiasts, in this article I would like to touch on the most pressing task for you — upload & minting process of your beautiful NFTs.

You finally explained to your artist what you want and after a while he gave you the desired result, after sitting for a couple of days over the generation script, you create your 10,000 unique NFTs. But whats next?

Next, you need to upload them somewhere and allow your community to mint them. And I will tell you how to do it.

First, let’s check if we are ready to start.

git version // min version 2.31.1
node — version // min version v14.17.0
yarn — version // min version 1.22.11
ts-node — version // min version v10.2.1
solana — verison // at least 1.6

If you dont have solana-cli, you can download and install it based on this doc.

Also, you need to create solana address using `solana-keygen new` and fund it via `airdrop solana airdrop 2`

Then let’s clone and build our main tool in Solana NFT world — Candy Machine (cool name, right?)

git clone https://github.com/metaplex-foundation/metaplex
cd metaplex/js
yarn install

Okay, now we have this magic tool in our hands, let’s use it! Go to src folder

cd packages/cli/src

And create assets folder via: `mkdir assets`

Is this folder you should move all your NFTs with metadata json file. Be sure, that your NFTs started from 0 and has sequential numbers for each file/image, if no — you might have issues during deploy process. Valid NFTs image and metadata names.

Let’s talk a little bit more about metadata. Metadata defines the NFT as an object and all details about it. As it might be video/music/gif or image. We need to specify what kind of NFT we create, in this tutorial we gonna use image format (png), but you can use any other media formats.

Metaplex has its own metadata standart, so you can check it here.

But for this tutorial we gonna use only few of them.

{
"name":"Solana Car #2",
"symbol":"SC",
"description":"Some Description",
"seller_fee_basis_points":500,
"image":"1.jpg",
"attributes":[{
"trait_type":"hilux",
"value":"common"
}],
"collection":{
"name":"SolanaCars",
"family":"SolanaCars"
},
"properties":{
"files":[{
"uri":"1.jpg",
"type":"image/jpg"
}],
"category":"image",
"creators":[{
"address":"ABPFLP4QUcPnarugwn9i2MLGoFWwNE2cqpPqY5wb4icK",
"share":100
}]
}
}

Now, as we have our NFTs ready to deploy, it’s time for upload process. Just for default, candy-machine will use Arweave for metadata storage, but you can use IPFS or S3 for it.

Let’s upload our NFTs:

ts-node candy-machine-cli.ts upload ./assets — env devnet — keypair ~/.config/solana/devnet.json

If everything is ok, you will see something like with:

Now, let’s create you own candy-machine instance with this command:

ts-node candy-machine-cli.ts create_candy_machine --env devnet --keypair ~/.config/solana/devnet.json

You should see something like this:

wallet public key: 5Jx7Kj49D6nUUQU2GX1MSVjpn6inpDLPQNxn5WmjWFepcreate_candy_machine finished. candy machine pubkey: 4x2aVfRsnmZPgmSELtLh15uDdxvEvRxrgRTHEaZSCe2w

And the final one, set price and mint date for your token sale:

ts-node candy-machine-cli.ts update_candy_machine --price 0.2 --date "21 Oct 2021 00:00:00 EST" --env devnet --keypair ~/.config/solana/devnet.json

Result:

Then go to cache folder and copy all data in it: config, date, authority and candyMachineAddress addresses.

So, we uploaded all our NFTs, but now we want to mint and view some of them in our wallet, for this purpose we can you candy-machine-mint repo.

It’s just the minimum set of features for mint NFTs using web3 solana and anchor libs.

git clone https://github.com/exiled-apes/candy-machine-mint
cd candy-machine-mint
yarn install

Remove .example from .env.exmple file and change all ENV variables based on data that you copy from cache folder.

Start mint website:

npm start

Open your browser and check localhost:3000

Final step — click on Mint and wait until transaction will confirm. If everything is good — open your phantom wallet and NFT tab = you should see your minted NFT.

Nice! If you made it through all the steps, you have successfully upload and mint your own NFT on the Solana blockchain. Well done. Now you can send it to your friend on devnet or do the same process on mainet and start your own NFT startup ;).

--

--

Speedrunner
Speedrunner

Written by Speedrunner

Working on some blockchain projects, love cryptoanarhysm ideas.

No responses yet