Create NFT on Solana (Windows)

Table of Contents

Prerequisite
Install Solana Command Line Tool
Generate a Solana Wallet
Generate Token
     - Mint Fungible Token
     - Mint Non-Fungible Token (NFT)

【Prerequisite】

  • To create an NFT using command line tool for Windows system, it is suggested to use command prompt (cmd) opened as an Administer
  • explorer.solana.com as a web-based tool to interactively manage wallet and crypto assets.


【Install Solana Command Line Tool Suite】

First of all we need to install the Solana tool suite. For Windows system, the command:

curl https://release.solana.com/v1.8.6/solana-install-init-x86_64-pc-windows-msvc.exe --output C:\solana-install-tmp\solana-install-init.exe --create-dirs

This downloads Solana installer of version 1.8.6 to directory C:\solana-install-tmp for Windows system. Now Solana installer got into that directory with file name solana-install-init.exe.

Check the version by

solana --version

For Linux system we can reference official tutorial. For my personal convenience I purely show the case of Windows system. Also see the official tutorial for accessing the latest version of the installer (more than 1.8.6), and yours will be newer than mine.

 

【Generate a Solana Wallet】

After getting Solana (command-line) tool installed, we are going to generate a wallet unique to you to store up cryptocurrencies and tokens.

We firstly make a preferred directory for the wallet (you can specify directory and folder name for sure)

mkdir C:Users\User\SolanaWallet

Next on we generate a specific wallet.

solana-keygen new --outfile C:Users\User\SolanaWallet\my-keypair.json

We will then be asked to enter BIP39 passphrase after running the command. Just hit enter to leave it blank at the moment.

In this step we can receive: (1) a public key of the wallet to which everybody can access. it looks like 5ESD5g4fwWnvKWzVbSap23UTTX52SNXrxDHjKVCEW21C

The public key was also written into Json file my-keypair.json.

(2) seed phrase which is composed of a set of English words for log-in use. It must be kept in secret ourselves and hence must not expose it anywhere outside!

Thirdly go to explorer.solana.com on the browser and you will see a web-based interface like below. Make sure you are in Devnet (for development use) by clicking the cluster button on the right above.


Finally, to test the wallet, try airdrop 1 SOL to the wallet.

solana airdrop 1 5ESD5g4fwWnvKWzVbSap23UTTX52SNXrxDHjKVCEW21C --url https://api.devnet.solana.com

If done, one SOL can be seen in balance of the wallet. This SOL can also be seen in the abovementioned web interface by typing the public key of wallet in searching block. This airdropped SOL can support you to mint Token on Devnet.

Paragraph Reference: https://docs.solana.com/wallet-guide/file-system-wallet


【Generate Token】 

Before mining an NFT we need to generate token at first.


change configuration

solana config set --url >https://api.devnet.solana.com

(not mainnet)

solana config set --keypair C:\Users\User\SolanaWallet\my-keypair.json

(the directory where the wallet key is saved)


Mint Fungible Token 

We can now start to create token

spl-token create-token


And then create an account specifically for the token we just created

spl-token create-account 6hWJz2yjNhshy1ywUQKLsyR4Yucggo2FEV7xNa2rP39D


Start to mint (fungible) token by entering unique token account as well as number of tokens to mint (here got 10).

spl-token mint 6hWJz2yjNhshy1ywUQKLsyR4Yucggo2FEV7xNa2rP39D 10

(Note: spl-token mint [token account] [number of token])

When checking the token, we found there are indeed 10 tokens as supply currently. The mint authority below displayed our wallet key.


You can further mint tokens by executing the same command and specifying preferred amount of them (15 in this case).

spl-token mint 6hWJz2yjNhshy1ywUQKLsyR4Yucggo2FEV7xNa2rP39D 15


Now there are 25 current supplies for the token.

Disable future minting – so that the minting for the token account will be unavailable.

spl-token authorize 6hWJz2yjNhshy1ywUQKLsyR4Yucggo2FEV7xNa2rP39D mint --disable

 



Create Non-fungible token (NFT)

Idea of creating NFT is like the way we just created Fungible Token above. The difference is that the NFT cannot be splitted and it is unique to individual address it has.

Again we created a token and this time specify decimals to be 0, because NFT is unique.

spl-token create-token --decimals 0


Then create a token account

spl-token create-account 9W9drYE8tjwJgJS6sdm5kcvahn7qKbsB63rD4LnTVGQJ

Mint one token

spl-token mint 9W9drYE8tjwJgJS6sdm5kcvahn7qKbsB63rD4LnTVGQJ 1

We make it fixed in "1" so that it can be an NFT. Then disable its future mint for this token and make it one and only one token.

spl-token authorize 9W9drYE8tjwJgJS6sdm5kcvahn7qKbsB63rD4LnTVGQJ mint –disable

Check information for this one and only one token, making sure it is unique to you as the only owner.

spl-token account-info 9W9drYE8tjwJgJS6sdm5kcvahn7qKbsB63rD4LnTVGQJ


Paragraph reference: https://spl.solana.com/token


* I got so many hand-by-hand practical ideas from ZappyCode. Highly recommend his video clip tutorial on Youtube.

留言

這個網誌中的熱門文章

Pip doesn't work in Python - Ubuntu

Obtain IP address (Windows / Linux sys.) from Python – plus simple practice