How to write smart contract code for an NFT on FTM

How to write smart contract code for an NFT on FTM

Fantom is one of the most highly-scalable blockchain platforms which has come out throughout the past few years within the crypto space. The main way through which the platform has gathered a high level of popularity and appeal in the eyes of developers is due to the fact that it features smart contracts; however, unlike competing blockchain networks that feature smart contracts as well, it combines them with a high level of speed alongside extremely low costs.

Today, we are going to go over everything you need to know about non-fungible tokens (NFTs), as well as how to write a smart contract through which you can launch an NFT on the Fantom blockchain network. Let’s dive in and go over all steps.

How to write smart contract code for an NFT on FTM

Key Points:

  • An NFT is a digital asset that exists on a blockchain network and is fully unique, and cannot be replicated.
  • NFTs can represent anything from art, music, videos, or even real-world items.
  • You can easily develop and mint an nft smart contract on top of FTM.
  • Use NOWNodes to connect easily to an FTM node.

What is a Non-Fungible Token?

A non-fungible token (or an NFT for short) is essentially a digital asset that is developed as a means of linking ownership to unique physical or digital items, typically works of nft art smart contract, music, or even videos. They are cryptographic assets on a blockchain network that feature unique identification codes as well as metadata that enables users to distinguish them from one another. However, unlike cryptocurrencies such as Bitcoin, Ethereum, or even the FTM token, they cannot be traded or exchanged at equivalency due to the fact that each and every NFT is unique in its own way. So if you were curious about what is a smart contract nft, now you know.

What is a Non-Fungible Token?

You can see NFTs as unique cryptographic tokens, ones that exist on a blockchain network that they are developed and minted on, and ones that cannot be replicated. They can represent both real-world items as well as digital items. Tokenizing real-world tangible assets has given many users the advantage of making buying, selling, and trading them a lot more efficient whilst also reducing fraud. However, NFTs aren’t limited to just that and can also be used to represent identities, property rights, or anything else.

Now that you have a heightened level of understanding as to exactly what non-fungible tokens are, let’s go over how they work and how you can write NFT smart contracts on Fantom (FTM).

How to Write a Smart Contract on FTM

Due to the fact that Fantom is a decentralized blockchain network, anyone is given the opportunity to deploy smart contracts NFT on the blockchain for a low gas cost and host their images or metadata for free, whilst also being able to distribute or sell as they see fit.

How to Write a Smart Contract on FTM

With that in mind, prior to getting started to create nft smart contract, there are a few things that you need to get.

  • You will need a MetaMask wallet that is connected to the Fantom Network.
  • You will need some Fantom tokens that will be used to pay for the gas fees.
  • You will need a Web Browser, such as Google Chrome, Firefox, Opera, Edge, Safari, Brave, or any other browser that you prefer to use.
  • You will also need a text editor.
  • You will need an asset that you will turn into an NFT.

After you have successfully managed to get yourself all of the required software, you can follow along with this step-by-step guide that will give you an in-depth look at how everything works.

Remember that Fantom utilizes the Ethereum Virtual Machine (EVM) in the back-end. What this means is that the smart contracts are written in Solidity, and they can function on Fantom similarly as they would on Ethereum. After you deploy a contract, it will become available to all of the users within the Fantom network, and the smart contract has a Fantom address like other accounts. With all of that in mind, let us dive in.

  • Step 1: You will need to deploy the smart contract.

You will need to navigate to the Remix development environment through the utilization of your internet browser. Ensure that you are connected to the Fantom network, and navigate to the Contracts tab, after which you can add a new contract.

You will need to deploy the smart contract.

Next, you will need to write the smart contract. Now, if you are curious how to write nft smart contract, this will require you to research the Solidity programming language and learn some of the ins and outs of how all of it works.

For the purposes of this tutorial, here is an example of how a Fantom smart contract works; later on, you can extend this contract to feature the properties found within Non-Fungible Tokens.

write smart contract

Within this image, you will be able to find an example of an ERC721 contract which is Ownable or Mintable.

write smart contract

You have the freedom to essentially write the NFT in any way that you see fit and provide it with specific functionalities found within the blockchain network.

The compiler will look like this:

write smart contract

Once everything is written from your end, you will now need to navigate to the Deploy page, after which you can select Injected Web3.

Deploy page

You will receive a prompt to log in to Metamask, after which you will need to make that selection. Now, you can choose the name and the symbol for your token.


After that, you will need to click on the “Transact” button, after which you will be charged a specific gas fee in the form of FTM tokens. 

  • Step 2: Verify and Publish the Token

If this works correctly, you can confirm the transaction and wait for the contract to deploy. Once the contract is confirmed, you can then get the contract address on ftmscan from your recent transactions within the Metamask wallet.

Click on that specific page in Metamask, after which you will be taken to the ftmscan page, where you can navigate to the Contracts tab and click on “Verify and Publish.”

Here, you will need to select “Solidity Single File” as the file type.

Verify and Publish the Token

After that, you need to select the latest compiler which is available at the time of the publishing, which Remix should have defaulted to, to begin with. 

You then need to select “No License,” assuming you did the coding yourself and it is fully open-source.


Afterward, you can click on “Continue.” If everything worked correctly, in that case, you would receive a message that tells you that the contract has been successfully verified. You can then interact with the contract through the utilization of ftmscan as a means of minting your NFTs.

  • Step 3: Hosting the Asset as well as the Metadata

You can utilize Pinata as a means of doing this. To do this, navigate to Pinata and upload the image file for the NFT. Once it’s hosted, you can create metadata for the NFT.

The metadata should look something like this:

  • { “name”: “Example”, “description”: “Description of Example”, “image”: “Link to image” }

Always ensure that the quotation marks are in plain text, as if they are not, the NFT will not show up within your wallet properly.

You can also add rarity attributes through the usage of this code:

Hosting the Asset as well as the Metadata

Later on, save this as a .json file and upload it to Pinata. 

  • Step 4: Mint the NFT

Due to the fact that you have now deployed the contract, as well as have hosted the image and the metadata, you can now finally mint the NFT. You will need to navigate to ftmscan for this and go to the write contracts page in order to mint the contract.

You will now need to connect your Metamask to ftmscan.

Now, navigate to function two and mint, and enter your wallet address. A token number and an URL will also need to be selected here. The URI will be the link to the metadata .json file that you uploaded previously to Pinata. 

You will now need to click on “Write” and confirm the transaction. When the transaction in question gets confirmed, you will be able to see the minting activity on ftmscan. 

That is everything you need to know when it comes to minting your NFT.

Note that if you want to stay up-to-date on the transactions that occur on the Fantom blockchain network, you will need access to a node.

Through the utilization of NOWNodes, which is a blockchain-as-a-service prover, you can access over 40 full nodes which are active 24/7/365. The platform has a 99.95% API uptime, which means that all you have to do is connect and only worry about the development of your NFTs instead of anything else.

Mint the NFT

To get started, navigate to the official NOWNodes website, after which you will need to enter your email and then click on “Get free API Key.” Once you have the API key, you can navigate toward the documentation page, where you will learn how to connect.


Hopefully, now you have learned everything that you need to know when it comes to writing a smart contract code for an NFT as well as minting it on top of the Fantom blockchain network.

While it might have seemed a bit intimating at first, you now have a clear level of understanding of each step involved in doing so and can begin this procedure with a high level of confidence. Remember to stay connected to the Fantom node through the utilization of NOWNodes.