DEV Community

Robert
Robert

Posted on

How to mint a NFT on Solana?

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

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
  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
  2. Buy Solana for our wallet
  3. Upload the image we will use as NFT
  4. Create and Upload the metadata of our NFT
  5. Minting the Token
  6. Add our local wallet to Phantom
  7. Burn NFTs in Phantom
  8. Conclusion

1. Creation of the local wallet

Assuming you have already installed Solana CLI), 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:

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)
Enter fullscreen mode Exit fullscreen mode

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.

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):
Enter fullscreen mode Exit fullscreen mode

Once entered we will get the following message:

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] ====================================================================
Enter fullscreen mode Exit fullscreen mode

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

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 by following the steps below:

1. Create an account

2. Go to wallet page

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

After that we will select debit card, follow the steps and confirm the deposit.

Alt text

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

After this we will select the currency to which we want to convert, in this case SOL.

Alt text

Alt text

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

Alt text


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

For this example we will use the Code&Jobs Logo, feel free to use or create the image of your choice.

codenjobs-logo

We will upload the image using arloader CLI, but in case you want to do it manually you can follow the instructions in the following post

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:

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).
Enter fullscreen mode Exit fullscreen mode

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 .

Next we will create the metadata of our NFT using the metaplex standard. For this we must open a code editor and create a file named metadata.json, we will copy the following inside that file.

{
    "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
            }
        ]
    }
}
Enter fullscreen mode Exit fullscreen mode

In this line we will place the transaction ID we received in the previous step, and the extension can be .jpg or .png.

"image": "https://arweave.net/[tx_id]?ext=png",
Enter fullscreen mode Exit fullscreen mode

Also in the following

"uri": "https://arweave.net/[arweave_img_tx_id]?ext=png",
"type": "image/png"
Enter fullscreen mode Exit fullscreen mode

In this line we must add the pubKey of our local wallet

"address": "[pub_key]",
Enter fullscreen mode Exit fullscreen mode

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:

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).
Enter fullscreen mode Exit fullscreen mode

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

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
Enter fullscreen mode Exit fullscreen mode

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

6. Add our local wallet to Phantom

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

  1. Click on "Add / Connect Portfolio"

Alt text

  1. Now click on import private key

Alt text

  1. 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

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 and choose one to show it in our user profile.

7. Burn NFTs in Phantom

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

  1. Next select the NFT you want to burn.

Alt text

  1. Click on the button with the three dots ....

Alt text

  1. Now click on burn all tokens tokens.

Alt text

  1. A confirmation window will appear, we will have to check the box followed by clicking Burn.

Alt text

  1. We will see a message saying that the token was burned and the amount in SOL that was deposited in the wallet.

8. Conclusion

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 or by adding me on Discord as Appu#9136.

Thank you very much for your time.

Top comments (0)