How to mint a NFT on Solana?
Tags: solana, typescript, node, javascript
Published: 2022-09-19 13:56:59

We will learn how to mint a NFT manually on Solana.

To follow this post it is not necessary to use the Metaplex CLI, *if you have an alternative, I would be very grateful if you could tell me about it*.
 
## Prerrequisites
 
- [Node.js](https://nodejs.org/en/download/)
- [Solana CLI](https://docs.solana.com/cli/install-solana-cli-tools)
- [Typescript](https://www.typescriptlang.org/download)
- [ts-node](https://www.npmjs.com/package/ts-node#installation)
- [arloader CLI](https://github.com/CalebEverett/arloader/releases/tag/v0.1.61)
- [metaplex CLI](https://github.com/metaplex-foundation/deprecated-clis) 

*Metaplex CLI was deprecated by Metaplex team but still works and you will have no issue following this post. I plan to include another option if I can find it later*
 
 
## Metaplex CLI
 
In order to install Metaplex CLI we need to do the following:
 
1. Open this [link](https://github.com/metaplex-foundation/deprecated-clis)
2. Clone the project with `$ git clone https://github.com/metaplex-foundation/deprecated-clis.git`
3. Locate the project folder and install the dependencies with `$ yarn install` or `$ npm i`
 
 
## Table of Contents
 
1. [Creation of the local wallet](#local-wallet)
2. [Buy Solana for our wallet](#add-funds-to-wallet)
3. [Upload the image we will use as NFT](#upload-image)
4. [Create and Upload the metadata of our NFT](#create-nft-metadata)
5. [Minting the Token](#minting)
6. [Add our local wallet to Phantom](#local-wallet-to-phantom-wallet)
7. [Burn NFTs in Phantom](#burn-nfts)
8. [Conclusion](#conclusion)
 
---
 
## 1. Creation of the local wallet <a name="prerrequisitos"></a>
 
Assuming you have already installed [Solana CLI](https://docs.solana.com/cli/install-solana-cli-tools)), the first thing to do is to point to the mainnet with the following command:
 
`$ solana config set --url https://api.mainnet-beta.solana.com`
 
We will get a message similar to the following:
 
```console
Config File: C:\Users\Rob\.config\solana\cli\config.yml
RPC URL: https://api.mainnet-beta.solana.com
WebSocket URL: wss://api.mainnet-beta.solana.com/ (computed)
```
 
Once this is done we will proceed to create the local wallet with the following command:
 
`$ solana-keygen new --outfile ~/.solana/your-wallet.json`
 
We will then be asked to enter a passphrase that we will use to retrieve the wallet.
 
```console
For added security, enter a BIP39 passphrase
 
NOTE! This passphrase improves security of the recovery seed phrase NOT the
keypair file itself, which is stored as insecure plain text
 
BIP39 Passphrase (empty for none):
```
 
 
Once entered we will get the following message:
 
```console
Wrote new keypair to /Users/Rob/.config/solana/your-wallet.json ==================================================================== pubkey: [wallet_pub_key] ==================================================================== Save this seed phrase and your BIP39 passphrase to recover your new keypair:
[REDACTED] ====================================================================
```
 
*The pubkey will be our wallet address.*
 
Now we will proceed to assign it as our default wallet with the following command:
 
`$ solana config set --keypair ~/.solana/your-wallet.json`
 
## 2. Buy Solana for our wallet <a name="add-funds-to-wallet"></a>
 
 
*To be able to perform the whole process we will need less than 2 USD in SOL.*
 
**In case we have a Phantom Wallet with SOL in it we can just send SOL to the new wallet**.

Otherwise we can acquire SOL using [FTX](https://ftx.com/#a=codenjobs) by following the steps below:
 
### 1. [Create an account](https://ftx.com/onboarding/signup)
### 2. [Go to wallet page](https://ftx.com/wallet)
### 3. Deposit USD or EUR

In the Wallet page we go to the currency (USD or EUR) we want to deposit and click on **DEPOSIT**.
 
![Alt text](https://res.cloudinary.com/codenjobs/image/upload/v1661107296/user/file/czncbscjcmvyjkzbofxv.png)
 
After that we will select debit card, follow the steps and confirm the deposit.
 
![Alt text](https://res.cloudinary.com/codenjobs/image/upload/v1661107376/user/file/dh10kwjoggkkwczp2mro.png)
 
 
 
### 4. Convert to SOL

Once we have done the previous step and we have the balance available in USD or EUR, we can convert it to SOL by clicking on **CONVERT**.
 
![Alt text](https://res.cloudinary.com/codenjobs/image/upload/v1661107384/user/file/qfyf2hueeehbeqh5y2yt.png)
 
After this we will select the currency to which we want to convert, in this case **SOL**.
 
![Alt text](https://res.cloudinary.com/codenjobs/image/upload/v1661107390/user/file/fzre5fucjfugg4ezdeoy.png)
 
![Alt text](https://res.cloudinary.com/codenjobs/image/upload/v1661107397/user/file/okwco2umydbkddf6veff.png)
 
 
### 5. We will pass the amount we converted to SOL to our local wallet.
 
Now we go to the search icon and search for *SOL*, and proceed to click on withdraw **WITHDRAW**, enter the amount we want to withdraw and the pubkey which is our wallet address
 
![Alt text](https://res.cloudinary.com/codenjobs/image/upload/v1661107404/user/file/kz0bxohctwwsyog78vc8.png)
 
![Alt text](https://res.cloudinary.com/codenjobs/image/upload/v1661207157/user/file/mp8errlh7nctg39zkgnh.png)
 
 
- - -
 
Once we have transferred funds to our local wallet we can check them using the following command:
 
`$ solana balance pubkey`
 
## 3. Upload the image we will use as NFT <a name="upload-image"></a>
 
*For this example we will use the Code&Jobs Logo, feel free to use or create the image of your choice.*

![codenjobs-logo](https://www.codenjobs.com/static/logo.png)
 
We will upload the image using [arloader CLI](https://github.com/CalebEverett/arloader/blob/master/README.md#installation), but in case you want to do it manually you can follow the instructions in the following [post](https://www.codenjobs.com/blog?&title=%C2%BFC%C3%B3mo-subir-archivos-con-ardrive-manualmente-y-con-ardrive-CLI?&id=2fd45e9f-37cc-4018-81d8-3c1ba6006d54)
 
With the following command we will specify the path of the image that we are going to upload, and that we will make the payment with our Solana wallet:
 
`$ arloader upload <code&jobs_logo.png> --with-sol --sol-keypair-path ~/.config/solana/your-wallet.json --ar-default-keypair --no-bundle`
 
We are going to get the following message by console:
 
```console
id:             <tx_id>
status:         Submitted
file_path:      <code&jobs_logo.png>
created_at:     2022-08-21 15:43:13
last_modified:  2022-08-21 15:43:13
Uploaded 1 files. Run `arloader update-status  --file-paths ` to confirm transaction(s).
```
 
*Be sure to save the tx_id*.
 
Once this is done we will have to wait a bit for the file to be available, we can check the status with the following command `$ arloader get-status [tx_id]` or with the following URL https://arweave.net/tx_id (in case it is confirmed we will be able to get the image)
 
*While we wait we can move on to the next step.*
 
 
 
## 4. Create and Upload the metadata of our NFT <a name="create-nft-metadata"></a>.
 
Next we will create the metadata of our NFT using the [metaplex standard](https://docs.metaplex.com/token-metadata/specification#token-standards). For this we must open a code editor and create a file named *metadata.json*, we will copy the following inside that file.
 
 
 
```json
{
    "name": "Your Solana NFT",
    "symbol": "ANYSYMBOL",
    "description": "Your first Solana NFT",
    "seller_fee_basis_points": 1000,
    "image": "https://arweave.net/<tx_id>?ext=png",
    "external_url": "https://www.codenjobs.com/user/rtagliavia",
    "attributes":
    [
        {
            "trait_type": "Whatever Trait 1",
            "value": "Fire"
        },
        {
            "trait_type": "Whatever Trait 2",
            "value": "Sunglasses"
        }
    ],
    "properties":
    {
        "files":
        [
            {
                "uri": "https://arweave.net/<tx_id>?ext=png",
                "type": "image/png"
            }
        ],
        "category": "image",
        "creators":
        [
            {
                "address": "[pub_key]",
                "share": 100
            }
        ]
    }
}
```
 
**In this line we will place the transaction ID we received in the previous step, and the extension can be .jpg or .png**.
 
```json
"image": "https://arweave.net/[tx_id]?ext=png",
```
 
**Also in the following**
 
```json
"uri": "https://arweave.net/[arweave_img_tx_id]?ext=png",
"type": "image/png"
```
 
**In this line we must add the pubKey of our local wallet**
 
```json
"address": "[pub_key]",
```
 
Once the fields have been filled and our file has been saved, we will proceed to upload it in the same way as we uploaded the image in the previous step.
 
`$ arloader upload [ruta/de/la/metadata.json] --with-sol --sol-keypair-path ~/.config/solana/[nombre-de-la-cartera].json --ar-default-keypair --no-bundle`
 
We will get a message similar to this one:

```console
id:             [tx_id]
status:         Submitted
file_path:      [ruta/de/la/metadata.json]
created_at:     2022-08-21 15:48:49
last_modified:  2022-08-21 15:48:49
Uploaded 1 files. Run `arloader update-status  --file-paths ` to confirm transaction(s).
```
 
Again we must wait for the confirmations, we can check the progress with the following command `$ arloader get-status [tx_id]` or with the following URL https://arweave.net/tx_id (if the metadata is shown it means it is ready)
 
 
## 5. Minting the Token <a name="minting"></a>
 
Finally we will mint our token we are going to use MetaPlex CLI *as I mentioned before it is obsolete but works perfectly fine*, once installed we go to the project folder
 
`C:\Users\User\deprecated-clis`
 
Once in the project we must go to the src folder and execute the following commands
 
```
$ cd src
$ ts-node cli-nft.ts mint --env mainnet-beta --keypair ~/.config/solana/[nombre-de-la-cartera].json --url https://arweave.net/[tx_id] --max-supply 1
```
 
*In this line we must add the tx-id we obtained when uploading the metadata.*
 
`https://arweave.net/[tx_id] `
 
We will get two URLs, one will show us the details of the transaction and the other the token we just *minted*:
 
![Alt text](https://res.cloudinary.com/codenjobs/image/upload/v1661204706/user/file/zk1tkxblfyzly7biijyd.png)

 
## 6. Add our local wallet to Phantom <a name="local-wallet-to-phantom-wallet"></a>
 
In case we want to add our local wallet to Phantom, the process is very simple, just follow these steps:
 
1. Open the Phantom extension in our browser.
2. Click on the button in the upper left corner.

![Alt text](https://res.cloudinary.com/codenjobs/image/upload/v1661204751/user/file/qg2n8im5demxar1hpcgk.png)


3. Click on "Add / Connect Portfolio"

![Alt text](https://res.cloudinary.com/codenjobs/image/upload/v1661204770/user/file/m1toj2emvgelffhxfxmz.png)


4. Now click on import private key

![Alt text](https://res.cloudinary.com/codenjobs/image/upload/v1661204782/user/file/kroqjmcrrzql82jipjjb.png)


5. Finally we will open our local wallet by going to the folder where it is located and opening the .json file with a code editor, copy all the content and paste it in the *private key* field.
 

![Alt text](https://res.cloudinary.com/codenjobs/image/upload/v1661204806/user/file/a8fh6ahzu9poqtmupuri.png)


With this we will be able to visualize our NFTs from the wallet extension, as well as being able to include them in the crypto section of [Code&Jobs](https://www.codenjobs.com/) and choose one to show it in our user profile.
 

## 7. Burn NFTs in Phantom <a name="burn-nfts"></a>

Phantom has the option of being able to *burn* our NFTs, with this we will eliminate the NFT and we will obtain the refund of the money at the moment of mining the Token, for this we must follow the following steps.

1. Open the Phantom Wallet extension.
2. Click on the *Your Collectibles* button in the bottom bar.

![Alt text](https://res.cloudinary.com/codenjobs/image/upload/v1661295024/user/file/mzaznnstgoyik6jld8sp.png)
 
3. Next select the NFT you want to *burn*.

![Alt text](https://res.cloudinary.com/codenjobs/image/upload/v1661295040/user/file/kgl9pqcxumhvxo9wawzb.png)
 
4. Click on the button with the three dots *...*.
 
![Alt text](https://res.cloudinary.com/codenjobs/image/upload/v1661295050/user/file/r4vsxmvsss7ktlgk3u8e.png)
 
5. Now click on *burn all tokens tokens*.
 
![Alt text](https://res.cloudinary.com/codenjobs/image/upload/v1661295059/user/file/ptuzwox7njzsvyesr3xc.png)
 
6. A confirmation window will appear, we will have to check the box followed by clicking *Burn*.
 
![Alt text](https://res.cloudinary.com/codenjobs/image/upload/v1661295068/user/file/hrb5okpwntenkwi8hri0.png)
 
7. We will see a message saying that the token was burned and the amount in SOL that was deposited in the wallet.


## 8. Conclusion <a name="conclusion"></a>
 
We learned how to mint an NFT on the Solana network manually with the help of various tools.
 
I really hope you were able to get this far without any problems, in case you encountered any issues please let me know with a comment or feel free to contact me by [telegram](https://t.me/rtagliajs) or by adding me on Discord as **Appu#9136**.
 
Thank you very much for your time.