How to Create your Own ERC-721 Token that runs on Local Testnet

Congratulations! You have just created your own ERC-721 Token. I hope this was a quick guide to get you up to speed on token development in the NFT space. The new ERC-4337 update proposal has been announced recently by Vitalik Buterin.


Femi Omoshona

2 years ago | 3 min read

In a very simple term ERC721 token is one of the token standard used in NFT space which can be found on the Ethereum blockchain.

Token space as a whole is a fast-moving space with new token standards proposed all the time. New ERC-4337 update proposal has been announced recently by Vitalik Buterin. The Ethereum developer has discussed the new features that will be introduced with the update and the possibilities that the new ERC brings to the network.

In this article, you will learn how to create erc721 token.

• Setting up Development Environment• Use OpenZeppelin Contracts• Creating the ERC721 Token• Adding Migrations to Truffle• Deploying the Token to the Truffle Development Network• Mint Token• Transfer Token from one Another to Another Account

Setting up Development Environment

There are just three basic steps for creating any smart contract: Write, Compile and Deploy.

We have multiple options to choose from for the environment. The most popular ones are Truffle and HardHat. They both help with writing, compiling, and deploying our smart contracts to the blockchain. We are going to be using Truffle since it is very easy to get started with.


NodeJS + npm installed. I am using v14.17.6 LTS.

Let's setup Truffle and import the OpenZeppelin Token Library. We are using Truffle 5.3.7 and OpenZeppelin 4.1.0 for this project.

For our token, we will be using Truffle and the OpenZeppelin Contracts. The first step is therefore to initialize a new Truffle Project and add in the OpenZeppelin contracts.

If you haven't installed truffle globally yet, then install truffle first that is very important before you can move forward:

npm install -g truffle

Then create a new folder, open VSCode (Terminal), init a new Truffle project and install OpenZeppelin Contracts:

truffle init npm install @openzeppelin/contracts

Use OpenZeppelin Contracts

From the OpenZeppelin Github Page: A library for secure smart contract development. Build on a solid foundation of community-vetted code.

They come with a preset, so we can easily do an ERC721 Contract that is mintable, pausable, burnable and supports all functions we possibly need to be ERC721 compliant.

We are going to using for our implementation

Creating the ERC721 Token

Create a new file in /contracts/ FemiToken.sol with the following content:

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


contract FemiToken is ERC721PresetMinterPauserAutoId {

constructor()ERC721PresetMinterPauserAutoId("FemiToken", "AIS", "") {}

function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { returnstring(abi.encodePacked(super.tokenURI(tokenId),".json"));

This is a normal ERC721 Contract based on the preset that OpenZeppelin gives us. If we open the ERC721PresetMinterPauserAutoId Contract then you see that it actually does a few things in the constructor:

  1. It sets up a new ERC721 Token Contract with the name and the symbol, in this case "FemiToken" and "AIS".
  2. It sets the tokenURI.
  3. It will grant the deployer pausing rights and minting rights.
  4. Additionally, and completely optional, but we decided to add ".json" to the url for the metadata file automatically, hence modified the tokenURI function.

Adding Migrations to Truffle

Create a migrations file to migrations/2_token_migration.js with the following this content.

const FemiToken = artifacts.require("FemiToken"); module.exports = function (deployer) { deployer.deploy(FemiToken); };

Next: In the truffle-config.js file, edit the compiler settings from 0.5.1 to 0.8.3 as you can see on the screen:

compilers: {solc: { version: "0.8.3", // docker: true, // settings: { // optimizer: { // enabled: false, // runs: 200 // }, // evmVersion: "byzantium" // } }},

Deploying the Token to the Truffle Development Network.

Then simply run the truffle development console

truffle development

This should open the Truffle Development console, just like what we have below:

Now lets just migrate the token and then mint one token:


will deploy the tokens to this test-chain.

These will give us the instance of FemiToken, which will display the whole token contract, include all the functions that our token has.

Mint token[0]);

From this image as you can see the status is true, that means our transaction want through, that is cool right

Transfer token from one another to another account

Transfer from first account to the second account

token.transferFrom(accounts[0], accounts[1], 0);


You have just created your own ERC-721 Token. I hope this was a quick guide to get you up to speed on token development in the NFT space. The new ERC-4337 update proposal has been announced recently by Vitalik Buterin.

Learning to learn, 100% ready to learn, code 247 for real impact in blockchain space

Watch-out for the next upcoming article.


Created by

Femi Omoshona







Related Articles