Sign in

Creating an NFT in Cardano from scratch

Here we will be exploring how to create our own NFT ourselves, not by using a generator or some marketplace to do it for us. We will create the NFT and actually write it on the blockchain to leave our mark on history and for future generations to see. For this we will need to spend some of our hard-earned cash, as to write transactions on a blockchain you need gas, and gas is paid in cryptocurrency, and cryptocurrency needs to be purchased. To keep costs to a minimum (around 2.50€ at time of writing) we will be using the Cardano blockchain — in Ethereum you would need to cough up about 60€. This is the main reason behind the choice of Cardano, because in all other respects Ethereum is currently better (note the “currently” — Cardano is slowly expanding and improving): in adoption and market acceptance, developer tooling, documentation and community, and even in functionality (Cardano doesn’t even have smart contracts yet, though they are expected soon).

Pre-requisites

Background reading: https://docs.cardano.org/en/latest/index.html.

You will need a computer with:

· Linux (maybe this works in Windows with WSL, or Mac or BSD)

· administrator rights

· 10GB hard-disk space

· an internet connection

You will also need about 13€ (at time of writing) in a bank account (you will get over 10€ of it back).

That’s it! The rest will be covered in the steps in this guide.

Other possibilities include Docker (I have seen at least 3 projects out there but haven’t properly looked into them), VMs, cloud hosting or maybe even things like Raspberry Pi.

Set up cardano-node

Background reading: https://docs.cardano.org/projects/cardano-node/en/latest/index.html.

We need to have a node on the Cardano network to be able to write transactions on the blockchain. For this we should follow the steps described here:

· Install: https://docs.cardano.org/projects/cardano-node/en/latest/getting-started/install.html (at one point my ageing PC — 4 cores and 6GB RAM — went to 100% on all cores for a good few dozen minutes, on more modern machines this should be much faster)

· Configure/run: https://docs.cardano.org/projects/cardano-node/en/latest/stake-pool-operations/getConfigFiles_AND_Connect.html (we just need a passive — relay — node as we won’t be producing any blocks, just transactions)

For the IP I think all you need is to set 127.0.0.1. I had some problems and switched to the local network IP (192.168…) and also forwarded port 3001 to my PC in my router, but I think these steps weren’t necessary at all.

Once you run for the first time you will need to wait a while until the whole blockchain is downloaded.

Create the token

Background reading: this is the reference you see linked everywhere, but at the time of writing returned a 404 — https://developers.cardano.org/en/development-environments/native-tokens/native-tokens/ — instead you can read https://docs.cardano.org/en/latest/native-tokens/learn-about-native-tokens.html.

In this section we will now mine the NFT and place it on the blockchain and into our wallet. For this we should follow the steps described here:

· Purchase and withdraw to your personal wallet 12 ADA (the Cardano cryptocurrency) + exchange withdrawal costs (1 ADA in the case of Binance — 13 ADA in total): https://docs.cardano.org/en/latest/explainers/getting-started-with-cardano/how-to-purchase-ada.html (I used the Yoroi wallet and the Binance exchange)

· Mint the NFT and send it to your wallet: https://docs.cardano.org/en/latest/native-tokens/getting-started-with-native-tokens.html#example-minting-a-new-native-token (I got pretty confused with the transactions and which value went where in the various commands but I got there in the end, though I did end up minting 1700 NFTs instead of 1 (so I basically created a parallel currency rather than an NFT); I also discovered you can specify more than one — tx-in in cardano-cli transaction build-raw)

I found that in some of the commands in the example I had to add a — mary-era parameter or I would get a “EraMismatch” error.

In the final “Transferring tokens” section I made sure I left only 1 ADA behind (the minimum — take the fee into account when making your calculations). It seems a bit of a waste, and I don’t understand why you can’t just somehow use your wallet address rather than generate a new payment address, but at least I now have a payment address for future use and could repeat this section with 1 ADA less. You should end up with over 10 ADA in your wallet as well as the NFT (the reason you need at least 10 ADA is that it is the minimum you need to send for a transfer that includes tokens) — you could now transfer the ADA back to the exchange and from there back into your bank account.

Add metadata

Background reading: https://github.com/cardano-foundation/cardano-token-registry.

We could stop here, we have now written an NFT to the blockchain, but I wanted to go one step further and add metadata. Cardano keeps the token metadata off the blockchain, which to me seems to go completely against de-centralisation and allows changing the metadata (which I find bizarre for an NFT), but I’m sure they have their motives for doing so that I (as a complete noob) don’t yet understand.

Very recently the Cardano Foundation created a central metadata registry. It’s still a pretty manual process (basically a merge request on Github) but I’m sure this will change in the future. To add metadata to the registry this we should follow the steps described here:

· Install tools: https://github.com/input-output-hk/offchain-metadata-tools

· Create metadata: https://github.com/cardano-foundation/cardano-token-registry/wiki/How-to-prepare-an-entry-for-the-registry

· Submit metadata to the registry: https://github.com/cardano-foundation/cardano-token-registry/wiki/How-to-submit-an-entry-to-the-registry

Now all you need to do is wait for the merge request to be accepted (a few hours). Here is mine: https://github.com/cardano-foundation/cardano-token-registry/pull/55. You can add a small image file (which I did). The metadata will eventually show up in your wallet (I think Daedalus has this feature, Yoroi hasn’t developed this yet).

When I am famous I will no doubt be able to sell my first ever NFTs for millions. Good thing I accidentally created 1700 instead of 1.

Further reading (Cardano-specific)

https://github.com/input-output-hk/cardano-ledger-specs/blob/master/doc/explanations/features.rst

https://iohk.io/en/blog/posts/2020/12/08/native-tokens-on-cardano/

https://iohk.io/en/blog/posts/2021/02/18/building-native-tokens-on-cardano-for-pleasure-and-profit/