Before going into details, we must first know what a Non-Fungible Token (or NFT) is. Generally speaking, tokens such as Bitcoin and Ethereum, are what we called Fungible Tokens. The reason is that every Bitcoin in the world is the same. There is no difference between the Bitcoins you hold and the Bitcoins I hold. For Non-Fungible Tokens, it means that the token is unique. There’s no other token on earth is the same as the NFT you own.
But, how to create it? In fact, it is very similar to create fungible token introduced in previous post. If you are not familiar with it, I suggest you to take a look of previous post ifirst.
First, we need to create an account for your NFT:
$ spl-token create-token --decimals 0
Creating token 4Z2bsoqeLBiqfzJgG1dwXCcZ8E9QhFTV5ntpKwSpz1sD
Then, create associated token account of the NFT:
$ spl-token create-account 4Z2bsoqeLBiqfzJgG1dwXCcZ8E9QhFTV5ntpKwSpz1sD
Creating account 4kLzgscLVaG2fudqH2bB2G7f5ohn3mKNCivCN2rR1P8g
Then, mint one and put it into account:
$ spl-token mint 4Z2bsoqeLBiqfzJgG1dwXCcZ8E9QhFTV5ntpKwSpz1sD 1 4kLzgscLVaG2fudqH2bB2G7f5ohn3mKNCivCN2rR1P8g
Minting 1 tokens
Token: 4Z2bsoqeLBiqfzJgG1dwXCcZ8E9QhFTV5ntpKwSpz1sD
Recipient: 4kLzgscLVaG2fudqH2bB2G7f5ohn3mKNCivCN2rR1P8g
Now, it comes to the most important step. As mentioned above, main difference between NFT and fungible tokens are mainly NFT is unique in the world. Therefore, after minting the first one, we will turn off the future minting function of this token:
$ spl-token authorize 4Z2bsoqeLBiqfzJgG1dwXCcZ8E9QhFTV5ntpKwSpz1sD mint --disable
Now, if you try to mint a new one, you see error messages:
$ spl-token mint 4Z2bsoqeLBiqfzJgG1dwXCcZ8E9QhFTV5ntpKwSpz1sD 1 4kLzgscLVaG2fudqH2bB2G7f5ohn3mKNCivCN2rR1P8g Minting 1 tokens
Token: 4Z2bsoqeLBiqfzJgG1dwXCcZ8E9QhFTV5ntpKwSpz1sD
Recipient: 4kLzgscLVaG2fudqH2bB2G7f5ohn3mKNCivCN2rR1P8g RPC response error -32002: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x5 [5 log messages]
Very Great! You have create your first NFT. If you enjoy this, please stay tuned to our upcoming articles of Solana Development. See you soon!