How to code your own NFT for free in Solidity? How to create and sell an NFT? On which platforms?

I tell you all about NFTs and their designs in this tutorial!

To create an NFT, you must choose a medium such as an image, a video, a sound or another type of object. Then, you have to host your data in a decentralized way with a service like IPFS. And finally, execute a smart contract to be deployed on a blockchain like Ethereum or Solana.

After reading this article you will know:

  • the difference between an ERC-20 and ERC-721 token
  • write, compile and deploy a smart contract for NFT“>NFT
  • use, sell and store your NFT“>NFT

Let’s start the development of our NFT without further delay!

But first, a bit of theory…

What is an NFT?

An NFT, Non-Fungible token or non-fungible token in French, is a unique token that cannot be replaced by another token.

Unlike crypto-currencies like BTC, ETH or DogeCoin which are interchangeable, a Doge will always be worth a Doge, NFTs are not: there is only one unit of each NFT.

What is an NFT used for?

In art, it solves the problem of authenticity: is a work the original?

If we hold an NFT that represents an object, we can interact with it on the blockchain, whether in one or more games or in other types of dApps.

Want to create an NFT game? Then my article How to create an NFT game will surely interest you.

Which language to create an NFT?

In this tutorial, it is the NFTs developed in Solidity for the Ethereum blockchain that we will see.

If you’re more into Solana, feel free to check out my article for [learn how to develop Solana dApps with Rust])/learn-solana/).

What is the ERC standard?

ERC stands for “Ethereum Request for Comment” or “Request for Ethereum Comments” in French.

The best known ERC standard is ERC20 which is the standard interface for Ethereum Tokens.

On the Ethereum network, tokens such as BNB, BAT, USDT, UNI or even DAI are ERC20. NFTs are ERC721s.

ERC721s can be built and programmed like ERC20s with smart contracts but they come with proof of their transaction history.

What is ERC721?

ERC721 is similar to ERC20 with some variations:

The first is that an ERC721 smart contract have a variable tokenURI.

Then they have a variable tokenIdthat points to the address of its owner (unlike ERC20 smart contracts which point to the address of a scale).

Where an ERC721 really differs from an ERC20 is in its metadata.

You have to show what the NFT looks like and putting files like images or videos on the blockchain would be too expensive.

So we came up with a solution: provide a token URL ( tokenURI) that points to the visual rendering of the NFT.

Often, we will use IPFS to store the visual of our NFT.

What is ERC1125?

ERC1155 is another tokenization standard that aims to make NFT (and token) transfers faster and more efficient.

This standard was developed by Enjin and is also called “the next generation multi token standard”.

With ERC-1125, gas costs are reduced by 90% compared to ERC-721 transfers. The only real downside is that NFT is harder to track in terms of ownership – to save data stored on ERC-1155 blockchain.

ERC1125 would therefore perhaps make more sense for video games on the blockchain, when you need a little less traceability and security but are looking for speed and low costs.

For the rest of this tutorial, however, we will focus on ERC-721 as we seek to “mint” your artistic creations.

How to code an NFT with Solidity?

I made a video that includes the steps of this tutorial to make your life easier.

ow to add a file to IPFS?

Before writing the smart contract for our NFT, we need to host our art and create a metadata file.

To do this, we will use IPFS . IPFS is a free decentralized file storage and sharing system.

Download and install IPFS CLI according to your operating system by following the installation guide in the IPFS documentation .

Step 1: Create an IPFS repo

Once the IPFS Command-line (or Desktop) tool is installed, you will have access to the ipfs init. Type this command to initialize IPFS.

ipfs init

Step 2: Launch the IPFS daemon

Next, you will need to launch the daemon. Still in the terminal, type:

ipfs daemon

Step 3: Add File to IPFS

Then, in another window, you can upload files with the command ipfs add. So let’s add an image called 0.jpeg:

ipfs add 0.jpeg

This command produces a hash that starts with Qmas output. Put this hash aside, it will be useful to access the file you just uploaded.

After a few minutes, go to the link of your file:<LE_HASH_QM_DU_VISUEL>

Step 4: Add the JSON file to IPFS

In addition to visual rendering of our NFT, we must upload a file that contains the information of the NFT such as its name, its description and a link to its image.

So create a file called 0.jsonand copy this content into it:

  "name": "Comment Coder",
  "description": "Logo du site",
  "image": "<LE_HASH_QM_DU_VISUEL>"

To finish with IPFS, we will upload the JSON file that contains the metadata of our NFT.

ipfs add 0.json

Again this command give you a hash. This hash completes the URI that will be useful for “minting” the NFT.<LE_HASH_QM_DU_JSON>

Step 5: Write the smart contract of an NFT

How to code an NFT with Solidity

Finally some code!

For security and simplicity reasons, we will start from a basic smart contract from the “0xcert” github repo on which we will just add the function to “mint” the NFT.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;

import "";
import "";

contract newNFT is NFTokenMetadata, Ownable {
  constructor() {
    nftName = "Le nom de mon NFT";
    nftSymbol = "NOM";

  function mint(address _to, uint256 _tokenId, string calldata _uri) external onlyOwner {
    super._mint(_to, _tokenId);
    super._setTokenUri(_tokenId, _uri);

And that’s all the code we’ll need to create our smart contract!

We now have to compile and deploy our smart contract… and there is a perfect tool for that, without having to install anything on your machine: Remix .

Go to the site and paste the code there after changing the values ​​of the variables nftNameand nftSymbolthe constructor.

Write the smart contract of an NFT

Step 6: Compile the smart contract

In the left menu of Remix, click on the second button “Solidity Compiler”. Change the settings if needed and then clickCompile <VOTRE_SMART_CONTRACT>.sol

Compile the smart contract

Step 7: Deploy the smart contract

Once your smart contract has been compiled, we will have to deploy it on the Ethereum blockchain.

Before you begin, make sure you are on Ethereum’s Ropsten testnet. To get on Ropsten, tap on “Ethereum Mainnet” above the Metamask pop-up and change it to “Ropsten Test Network”.

If this is your first time on Ropsten, you can receive test ETH for free on the Ropsten Ethereum Faucet site .

Using Ropsten as an Ethereum testnet

Go to the “Deploy and run transactions” section by pressing the 3rd icon in the left menu of Remix.

Choose “Inject Web3” and choose the Ropsten testnet with Metamask.

Choose the Ropsten network to deploy a smart contract

Expand the “Mint” field to be able to complete the variables:

  • _to: the address of your metamask wallet (Ropsten)
  • _tokenId: put the value “1” as there will be only one NFT
  • _uri: the IPFS url of your JSON file
Deploy the smart contract

Press the Transact button and you will receive your NFT after confirming your transaction.

Cheer ! Your NFT now lives on the Ethereum Blockchain! We used the Ropsten testnet for this tutorial but you can go to the Ethereum Mainnet and follow the same steps in this tutorial.

Then you can connect to a marketplace to view (or sell) your NFT.

What are the marketplaces for NFT?

Now that you have the code to create NFTs, you might want to put it on a marketplace to sell and possibly buy other NFTs.

There are many marketplaces where you can trade your NFTs.

I have collected the best known (end of 2021) for you below.


OpenSea is a decentralized marketplace for crypto collectibles and NFTs. It includes collectibles and other virtual goods that live on the blockchain. On OpenSea, anyone can buy or sell these NFTs using Ethereum smart contracts.


Rarible is a blockchain-based marketplace for digital art and tokenized NFTs. The platform aims to connect NFT sellers with buyers.


Mintable is a platform built on Ethereum that allows users to create, distribute, buy, sell, and trade digital files on the blockchain through smart contracts.


Cent is basically a social network launched in 2017 with the goal of helping creators make money in crypto. In 2020, Cent launched Valuables, which allows users to sell or buy Tweets as NFTs. If the tweet owner agrees, Cent creates the NFT.


Sorare is NFT project in the form of football game. On Sorare, you can buy and sell football players to create your virtual team with player cards.

How to put your NFT on OpenSea?

How to put your NFT on OpenSea

If you want to create an NFT and sell it without coding your NFT , it is possible on a marketplace like OpenSea.

How to register on OpenSea?

Go to OpenSea and press the login icon.

Choose an option to connect your wallet. If you have no idea what I’m talking about, I advise you to use Metamask.

For this, you will need to install the Metamask browser extension and create a wallet on it.

Then, fill in your profile, validate your email address and voila, your OpenSea account is ready.

How to create an NFT on OpenSea?

To create an NFT on ⛵ OpenSea, press the “Create” button in the top menu.

You arrive on a form on which you can upload your file (jpeg or another image, video, audio or 3d model format), give it a name, a description, a collection and properties.

How to create an NFT on OpenSea?

Once the form is completed, finalize the creation of your NFT by pressing the Create button at the bottom of the page.

How to list an NFT on OpenSea?

After creating or purchasing your NFT, you will be able to sell the NFTs in your possession. Go to the page of the NFT you want to put on sale, press “listing” then “sell”.

Then choose whether you want to sell your NFT at auction or with a fixed price and its price. Other options are also available if you want to make a private sale or decrease the price over time.

Note that listing an NFT on OpenSea costs money as the platform will take a few % if the sale is successful and you will also need to sign the Ethereum transaction.

Don’t have ETH to sign the transaction? Then the paragraph below will be useful to you.

Buy ETH to sell an NFT on OpenSea

As we have seen, you will need Ethereum to list your NFT on OpenSea or the other decentralized platforms.

If you do not yet have ETH in your wallet, you will need to buy some. And if you don’t have crypto on exchanges, you will need to register on an exchange.

To start, I recommend using Coinbase if you are an absolute beginner or Binance if you have a bit more experience in cryptos or trading.



The easiest solution to buy your first cryptocurrencies like Ether, which you will need to list your NFTs on OpenSea, is certainly Coinbase.

Once your ETH has been purchased, you can transfer them to your Metamask addresses and list (or buy) NFTs on OpenSea.



Binance is an exchange where you can buy and sell your cryptos. Binance is therefore similar to Coinbase but a little more complicated to use because it is more complex and complete.

But Binance also has its own marketplace for NFT. The Binance marketplace for NFT is similar to OpenSea without you having to use a wallet like Metamask.

How to secure your NFTs?

When you buy NFTs on platforms like OpenSea, they are on your Metamask Wallet.

Metamask is a “hot wallet”, it is connected to the internet and protected by a password. This means that if someone sees you typing your password and accessing your computer, they can steal your NFTs.

If you want to increase the security of your digital assets, you can switch to physical cold storage like ledger or trezor.


Securing your NFTs with Ledger

Ledger is a French company that sells ultra-secure hardware wallets. For your NFTs, this would be the equivalent of placing your artwork in a safe somewhere.


Securing your NFTs with Trezor

Trezor is another alternative to Ledger, they have been in the market since 2014. Just like ledger, their products combine the simplicity of a hot wallet with the security of cold storage.

Discover a whole new world with NFTs

Congratulation ! You now know what an NFT is, how to code your own smart contract to deploy NFTs on the Ethereum mainnet as well as on testnets. But you also know how to buy, sell and secure your NFTs and other crypto assets.

Blockchain is a dream industry for developers for several reasons:

  • everything remains to be invented on Web3.0
  • crypto companies are short of talent
  • salaries are among the most attractive

Tagged in:

About the Author

Investing Press

we are passionate about science, new technologies, and web development and how to make money on the internet, we share with you tips, tutorials, guides, concerning the creation of blogs and everything related to Web 3.0 and of course the world of Cryptocurrency

View All Articles