Short introduction to NFT’s + Tutorial

Basics of non-fungible tokens and tutorial for creating your very own NFT and deploying it on Ropsten Testnet

Jan Duspeva
Learn Bitcoin & blockchain
10 min readJun 15, 2021

--

What are NFT’s?

The abbreviation NFT stands for non-fungible token, non-fungible meaning unique in a sense that there might be more of the same tokens, but you are able to distinguish every individual token. Sounds strange doesn’t it? To make things easier to understand, let’s imagine coins, coins are like bitcoins, if you trade one for another, they would look the same to you as they are interchangeable. On the other hand, you can imagine some collectible items such as trading cards, of which there is only a limited amount and each item has it’s own serial number, which allows you to distinguish between them and finally you can imagine something like one-of-a-kind artworks, such as Mona Lisa, where there is only one original. NFT’s are like these type of things, each token has its own unique ID.

So far I have made only references to artworks and digital items, which are currently the most prominent use cases, but NFT’s have potential to offer much wider usage in fields like finance (NFT may act as a “ticket” to staking project, valuable NFT might be used as a collateral), music industry (allows better loyalties tracking), with connection to real-world assets (allows to move extremely illiquid items like property to blockchain, or to prove authenticity) or even in areas such as logistics (identifying unique items, their condition, history, journey etc.) and gaming (in-game items in the form of a NFT).

For the purposes of this article, I will focus primarily on the visual art NFT’s.

What is the difference between an ordinary file and a NFT?

How do you create something unique in an environment where creating 1:1 copy or clone of any file is easier than ever? The answer lies in the very nature of the tokens which are sent primarily, but not exclusively, on Ethereum blockchain, which does not only serve the cryptocurrency and smart contracts, but also allows users to attach extra informations to a transaction, enabling users to create NFT’s from any digital file, most notably from digital art. So back to the question, we can say that the difference between an ordinary file and a NFT is that with NFT there is a record on the blockchain, unequivocally identifying the file and its owner.

If you ask about the practical aspects of NFT’s apart from the clear prove of ownership, there really isn’t much to say. The artworks look / sound / work just as an ordinary version, which you might just copy and save to your computer.

So what is the appeal of NFT’s and why are they valuable?

The appeal is in the opportunity to own a digital artwork. This might be beneficial for those who seek to own such an art, as well as for artists who gain access to a mechanism how to sell their digital art without worrying about the piracy. This is the reason why NFT’s are controversial, as there is a dispute between those who see NFT’s as an advancement of classical art and those who do not believe in the concept at all, citing the lack of practical utility.

Which networks support NFTs and what is ERC-721?

The most famous network to work with NFTs is undoubtedly Ethereum, but there are also other networks that support NFTs like Binance Smart Chain, Tron, EOS or Polkadot. It’s important to choose which network you want to use to create your NFT as each network has it’s own NFT token standard, compatible wallet services and marketplaces. That means that if you create your NFT on top of Polkadot network, you will be able to sell it only on platforms that support Polkadot assets. For the purpose of this article we will focus only on the Ethereum network, which brings us to the next point — ERC-721. This is the codename of the interface that “provides basic functionality to track and transfer NFTs.” [https://eips.ethereum.org/EIPS/eip-721]

In other words, it is a part of the Ethereum network, that makes it possible to create, send and receive non fungible tokens, which is exactly what we want to do.

How can I get a NFT?

Basically, there are two options how to get a NFT, you can either create your own, or purchase one on an online marketplace. We will focus on the first option, but it should be noted that the main Ethereum marketplaces include OpenSea, Rarible and Mintable.

NFT Tutorial

The tutorial will focus on deploying and NFT on a Ethereum Ropsten testnet, but before we get to the creation of the NFT itself, we should have a few things prepared beforehand:

Metamask wallet

  • Metamask is a free browser extension and mobile application that will serve as our ETH wallet
  • Available on: metamask.io

Test ETH

  • You will need test ETH tokens to mint the NFT
  • Available on faucets such as: faucet.ropsten.be

The file we want create an NFT from

  • We will try to make it from a photography, but you can choose other file if you wish to.
The artwork I'm going to use to create an NFT, a picture of a llama taken by me at the Prague Zoo

1. Creating the metadata file

1.1 What is IPFS and why do we need it?

The blockchain network itself is not suitable for uploading the files, so we need to store the data somewhere else. We could use HTTP address, but there are a few problems with this approach, HTTP addresses may change their owners over time, but they can also change their content, which means that if we bought some NFT, let’s say a picture of a kitten, that is stored on the address somewebsite.com/kitten.png, the owner of this website could upload any other picture with the same name to the same address that would than be linked to our NFT. This problem is addressed by using IPFS, which stands for InterPlanetary File System. This is a peer-to-peer protocol used to distribute data without servers. One of the key mechanics is that when we upload our file to IPFS, the system generates a unique code — CID — identifying the file. This ensures that the content of our NFT will stay the same over time.

Another important aspect is that with decentralization we do not rely on stability of one server, because there isn’t any central server. Instead, the file is shared and stored on the computers of users using the network.

1.2 IPFS download and installation

Before creating the NFT contract itself, we need to create a metadata file for our artwork. We will use IPFS — peer-to-peer system for sharing and storing files. IPFS is available from the project’s official website ipfs.io where you will be able to download and install the programe based on the operating system you use. If you downloaded and installed the program successfully you shall see this screen after opening it:

1.3 Adding an image to IPFS

Now, we want to add our image to the IPFS system, which means that we should click on “FILES” -> “IMPORT” and choose our file — in my case NFT_Artwork.jpg

1.4 Copy the link including CID

After the successful import of the file you should get the link including CID hash and save it for the next step. You save this address by choosing the “Share link” option and it should look like this:

https://ipfs.io/ipfs/QmddWZugyNAUsupGDsPf4qb7AWaPXLBeTT5qV54Dy19SKL

1.5 Create and add JSON file to IPFS

Now we want to create a JSON file that would include all the information about the file. This can be done using any text editor of your choice, there are even some JSON tools available online. This file will be named “nft.json” (you can name it however you want) and should have the following structure:

“name” — the name of the NFT

“description” — short description of the artwork

“image” — the address of the artwork we prepared in the last step

It should be noted that this is only the very basic structure, which can be extanded to include more information such as serial number, or some specific properties like “damage” and “rarity” for in-game items. If you would like to know more about the metadata conventions I suggest reading the article ERC-721 metadata standards and IPFS from James Morgan.

1.6 Add the json file to IPFS

Now we want to add the JSON file to the IPFS, which is the same process as adding the picture:

Files -> Import -> File -> choose your .json file

And the last step in IPFS is to copy the adress of the json file just as we did with the artwork — by clicking on “Share link” and saving this for later. It should result in something like this:

https://ipfs.io/ipfs/Qmad2Ydmjzv5X5LCVyd1qn55sh96ZQMFh13Pi1A6znuRTX?filename=nft.json

2. Creating the NFT token itself

We will use the ERC-721 ethereum contract to deploy our NFT, which means that we don’t need to write the contract ourselves, but can only import the library and use it using the Ethereum Remix IDE.

2.1 Creating new Solidity script

First we need to create the smart contract of our NFT. This will be done using Ethereum Remix IDE, which is an open source application that allows us to create smart contracts and use various plugins on Ethereum network using Solidity language, which is a specialised language for implementing smart contracts. This application is available as both web and desktop application, but we will use the website so we do not need to install anything.

Now we will go to Ethereum Remix IDE on https://remix.ethereum.org/ and create a new Solidity script including the code that you will find below:

2.2 Copy the code below into the newly created document

This code is from another tutorial on the website quicknode.com, but we can use it just as well for our purposes. We will copy the code below and insert it into the newly created Solidify script.

// SPDX-License-Identifier: MIT

pragma solidity 0.8.0;

import “https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/nf-token-metadata.sol";

import “https://github.com/0xcert/ethereum-erc721/src/contracts/ownership/ownable.sol";

contract newNFT is NFTokenMetadata, Ownable {

constructor() {

nftName = “Synth NFT”;

nftSymbol = “SYN”;

}

function mint(address _to, uint256 _tokenId, string calldata _uri) external onlyOwner {

super._mint(_to, _tokenId);

super._setTokenUri(_tokenId, _uri);

}

}

After copying the code it should look like this. We do not need to change anything in the code, as all changes will be done in the next steps.

2.3 Compile the solidity file

Simply press the “Compile nft.sol” button, there is no need to change the setting.

2.4 Deploy the contract

This must be done using the injected Web3 as environment, to ensure the transaction will run on the ropsten testnet. In Account, there should be your Metamask account and in contract must be the name of the solidity contract you just created — in my case it is “newNTF — nft.sol”.

When you are all set, click “Deploy” and confirm the transaction in your Metamask wallet.

2.5 Edit the contract details

Now we need to go to “Deployed Contracts” section in Remix (which is below the deploy button on the same page) and expand this section.

With the “Deployed Contracts” section expanded we will now enter some details into the mint section.

_to = your Ropsten address (which you can see / copy in Metamask Wallet)

_tokenId = you can enter any number, but I suggest entering 1 as it is your first transaction

_uri = URI of the json file we created, in my case: https://ipfs.io/ipfs/Qmf72qXFuXChqE9q7CYZfxAcFbKzT3Tz97SKkGCCst7WT5

2.6 Click transact

After clicking transact you will once again confirm the transaction in the Metamask wallet. Now you can open your Metamask history and check if the “Contract Deployment” and “Mint” transactions ended successfully, as seen below:

If they did, congratulations, you have successfully created your very own NFT!

If they did not, you should return to Remix and check if there is any error pointing out where there could have been a mistake.

3. Add your NFT to Metamask

Now when you have deployed your NFT to the Testnet, you can add it to your Metamask wallet, but only on mobile, as the browser extension does not support NFT’s yet. So provided that you have the Metamask app on your phone, you should be able to view your NFT.

First, you have to switch from “TOKENS” to NFTs, then enter the Address of the transaction (which you can find in the overview of “MINT” transaction) and ID of the NFT (which you entered as tokenId), if you enter both correctly and refresh Metamask, you should see your NFT in the wallet.

Final Words

Thank you for reading my tutorial and I hope that it helped you to understand NFT’s a little better!

Sources

--

--