---
# System prepended metadata

title: All we need to know about NFT in Solana
tags: [solana]

---

###### tags: `solana`

# All we need to know about NFT in Solana

The concept of NFT in Solana is quite different from it is in EVM blockchain. I would say it is more flexable and intuitive in Solana.

## Basic concept of Solana NFT

Unlike EVM, NFT in Solana is just a normal SPL (ERC20 in EVM) token with supply = 1. Then we just simply link an Metadata to this SPL token. 

Metaplex is the one which is incharge of creating the metadata. We can get more clear idea from the graph below:

![](https://i.imgur.com/2BGopC1.png)

## How to mint a NFT

1. Prepare the target image (png/jpeg/gif ...)
2. Create the metadata (.json) to represent the NFT
3. Call Token Program to create a token Mint
4. Call Metaplex Program to create the metadata 

### Image & metadata file preparation

There are many tools to help to generate the images & metadata files ([see here](https://book.solmeet.dev/notes/complete-guide-to-mint-solana-nft)). 

After getting images and metadata, we will need to upload it to *Arweave* blockchain.

We can make use of the [arweave-uploader](https://github.com/DappioWonderland/nft-mint-example/tree/master/arweave-image-uploader). Then we will get the result as below by runing

```
yarn run upload
```

```
(base) macbookpro4eric@Erics-MacBook-Pro arweave-image-uploader % yarn run upload
yarn run v1.22.17
$ node ./uploader.js
name 0
filePath ./public/images/0.png
100% complete, 1/1
imageUrl https://arweave.net/JPsaiCyMsD_zLG2LK46OUq21uerEVQ7i_Cc-NrM6Ang
metadataUrl https://arweave.net/m7IkmP1HBkncGCcfkGgwALADg7fEKCcCtTV_X1qy9OY
name 1
filePath ./public/images/1.png
100% complete, 1/1
imageUrl https://arweave.net/L9cjQVJNaUTfLGXegy0yFMBNYr9YtwJ_yZpMwCZrLZY
metadataUrl https://arweave.net/9EDgT4VGd332xLgGqD8kcDNYzAhoZTQIQKwZoLSyjgM
name 2
filePath ./public/images/2.png
100% complete, 1/1
imageUrl https://arweave.net/2Ne6Bt7m5ziLmGI8jfYUxwClw5F5JJXl87eztYLxP7c
metadataUrl https://arweave.net/ZWFMf6pNZCEpNVaNSYpb62jqXvLeLHU3gcDarWUmgTM
name 3
filePath ./public/images/3.png
100% complete, 1/1
imageUrl https://arweave.net/aEdJuRFmJGZE-3lQr-QUQXSNl1HK4Xq8pgzQgiEC6aQ
metadataUrl https://arweave.net/3sRwAbj20BaWvASZxIMRrDgljHJDJS6F7UcaVCpwvZE
name 4
filePath ./public/images/4.png
100% complete, 1/1
imageUrl https://arweave.net/dL5-ubKeSu2RqEzeu7lhOZqUCFhOTagxKusZ6RQhDzU
metadataUrl https://arweave.net/zA_nC5M1hQBJxGUPWkXzBaSEU0bxPD55SMb5VZXGN64
100% complete, 1/1
metadataUrl https://arweave.net/Kr5TLjMSLIxDzt4yy8tnhTfmMNjAy189ZMXyaTCenII
{
  '0': {
    name: 'ColorfulLife DAO #0',
    uri: 'https://arweave.net/m7IkmP1HBkncGCcfkGgwALADg7fEKCcCtTV_X1qy9OY'
  },
  '1': {
    name: 'ColorfulLife DAO #1',
    uri: 'https://arweave.net/9EDgT4VGd332xLgGqD8kcDNYzAhoZTQIQKwZoLSyjgM'
  },
  '2': {
    name: 'ColorfulLife DAO #2',
    uri: 'https://arweave.net/ZWFMf6pNZCEpNVaNSYpb62jqXvLeLHU3gcDarWUmgTM'
  },
  '3': {
    name: 'ColorfulLife DAO #3',
    uri: 'https://arweave.net/3sRwAbj20BaWvASZxIMRrDgljHJDJS6F7UcaVCpwvZE'
  },
  '4': {
    name: 'ColorfulLife DAO #4',
    uri: 'https://arweave.net/zA_nC5M1hQBJxGUPWkXzBaSEU0bxPD55SMb5VZXGN64'
  },
  collection: {
    name: 'ColorfulLife NFT DAO',
    uri: 'https://arweave.net/Kr5TLjMSLIxDzt4yy8tnhTfmMNjAy189ZMXyaTCenII'
  }
}
✨  Done in 40.24s.
```

Now our metadata has already in blockchain. Then we need to create SPL token and its metadata account
> *IMPORTANT NOTE:* 
> 1. The symbol between collection & NFT need to be the same, otherwise the program instruction will go wrong.
> ```
> Error: RPC response error -32002: Transaction simulation failed: Error processing Instruction 4: custom program error: 0xc [35 log messages]
> ```
> 2. the creators account needs to be changed to signer
> ![](https://i.imgur.com/iSZeoiw.png)



### Mint NFT
We can make use of the script "mint/mint.js" which provided by [Solmeet repo](https://github.com/DappioWonderland/nft-mint-example)

In this case, we will mint our NFTs in devnet, make sure changing the rpc network through solana-cli cmd as below:

```
solana config set --url devnet
```

Then execute the script

```
KEYPAIR=/Users/macbookpro4eric/.config/solana/dappio-1.json RECEIVER=<your pubkey> AUTHORITY=<your pubkey> node mint.js
```

Finally, we can see the stdout like below.
```
nftMint: 9c1qpXVpdspcRdMiXmmazbtqyhfjpT1TD3qvuQpVjCZj
nftMint: Ftt4ndCYm8a7sdwwq9Uv7eNMYzrxfXc5eZaVdoiLGhWz
nftMint: 9abuRinLQv6wJvmnV7G9nrkFfqF2Va5ea72KYn7XfXUq
nftMint: 3Sxz4HiA3HuA849S6u7tUApNxoaz4dPzBQShJvPpet6R
nftMint: Bpg1G7cyG3Nm1owTwxCSiPELZR5yu7Ve3nXtk3eSJp9v
```

Our NFTs already been successfully minted. We can also check the NFT through phantom wallet or solana exploror





![](https://i.imgur.com/HEsxZ6r.png)

![](https://i.imgur.com/vufF0MY.png)
![](https://i.imgur.com/0cc16S5.png)
