Develop, Deploy, Verify an NFT (ERC721) token with Hardhat and Ethers.js

👉 Apply here:

3 month mentoring program to become a professional Web3 developer Build a killer portfolio of Web3 projects to get a 6 figure job

👉 Program:
👉 Testimonials:
👉 Questions? julien [at] eattheblocks [dot] com

ERC-721 is a free, open standard that describes how to build non-fungible tokens on the Ethereum blockchain. All ERC-721 tokens are unique from one another. During this tutorial I’ll go through how to develop, deploy and verify an ERC-721 token while using Hardhat.

Keep in mind that this is going to be bare bones NFT. We’re just going to implement the essentials of what it takes to make an ERC721 contract for Ethereum. This basic NFT concept could be expanded and be made into something far more interesting but that would take more time and development. Anyway, let’s get into it.

Hey, my name is Anthony. At Eat The Blocks, we help teach web3 development.

The first thing that we want to do is open a Terminal and navigate to our desktop.

Let’s make a folder for our project.

And now CD into that folder.

We have to install all of these dependencies for our project in order to do what we want it to do, which is deploy and verify an ERC721 token on Ethereum. We’re also setting up Hardhat which is a JavaScript framework and it’s going to help us deploy and verify  our smart contract.

The install of these installs might take some time to finish so just sit back, be patient but once they are installed you can open up your project in a code editor.

Now that we have our project open in a code editor let’s first change the name of our smart contract. This contract came with Hardhat and it’s just a template so we can do whatever we want to it.

Let’s name our contract: OneOfAKind.sol

As we jump into our template contract that came with Hardhat, We can delta everything inside of this contract that we don’t actually need and modify it to do what we want it to do, so let’s add our token name at the top.

We have to import one of the OpenZeppelin contracts that we installed called ERC721 and we’ll inherit that contract into our own smart contract to implement this NFT function that we want to do.

Inside of a constructor we’ll set some parameters for our token and give it a name and a symbol.

That’s literally it! Here is a very simple ERC721 NFT token. It has everything that we need for this demonstration so now we can move onto the next part…

We now have to modify the hardhat configuration script which is going to be necessary for actually communicating with a node provider url and our metamask account.

At the top of the hardhat config script we have to import a few things such as the Nomic Labs plugin for Etherscan and a dotenv dependency.

Let’s also specify the network that we want to actually deploy to today. In our case we want to deploy to the Ethereum goerli testnet

We also want to set up the etherscan plugin apiKey so that we can verify this contract with hardhat after we deploy it.

Now we have to modify our deploy script in order to successfully deploy our token with hardhat.

We can delete everything inside of this file that we don’t need.

Ethers.js is a great library for Ethereum development. We’ll use it for defining our token during the deployment process. Basically, Ether.js is communication with our smart contract and setting up the token credentials from inside of our constructor function. Here we can specify our token name and its symbol. And then console.log our deployment so it’ll let us know if our token was successfully deployed or not.

After we complete our deploy script we want to create a dotenv file that holds our sensitive information such as our metamask private key, our alchemy node url endpoint and an etherscan apiKey. You never want to share this information with anybody because you’ll be vulnerable to hacks. So it’s best practice to really keep this information private no matter what. Once you set your variables and match the same variables from your hardhat config file, then your project will actually be able to communicate with Alchemy, Metamask and Etherscan.

Also add “Dot Config” to the end of this require statement.

Finally we can start the deployment process by opening up a terminal and compiling our contract to check for any errors that may pop up.

Since we don’t have any errors we can now deploy our contract with hardhat to the Ethereum Goerli testnet and we’ll use this command to do that. Keep in mind that the actual deployment process will take some time because now we’re interacting with Ethereum and our contract needs to be processed by a Validator in order to be published on the blockchain.

Ok sweet! It looks like our deployment was successful and here is our smart contract address that we can now view on the Etherscan.

If you’ve made it this far, congratulate yourself because you now deployed an NFT to an Ethereum testnet…

(Visited 24 times, 1 visits today)

You might be interested in


Your email address will not be published. Required fields are marked *

EOS (EOS) 0,698667 2,71%
Aave (AAVE) 78,24 0,24%
The Graph (GRT) 0,228787 1,61%
Kusama (KSM) 28,23 0,22%
Waves (WAVES) 2,27 5,06%
Dash (DASH) 26,48 1,47%
Bitcoin (BTC) 58.025,44 1,26%
Ethereum (ETH) 2.806,55 0,65%
Cardano (ADA) 0,413318 0,67%
Tether (USDT) 0,937285 0,03%
XRP (XRP) 0,453282 1,40%
Solana (SOL) 129,49 4,82%
Polkadot (DOT) 6,10 1,25%
USDC (USDC) 0,937034 0,03%
Dogecoin (DOGE) 0,137784 0,89%
Uniswap (UNI) 6,71 2,78%
Terra Luna Classic (LUNC) 0,000091 0,59%
Litecoin (LTC) 73,81 1,20%
Chainlink (LINK) 12,38 0,95%
Bitcoin Cash (BCH) 432,88 0,95%
Algorand (ALGO) 0,156528 0,00%
Polygon (MATIC) 0,607665 2,69%
Stellar (XLM) 0,101545 1,02%
Cosmos Hub (ATOM) 7,52 0,37%
Filecoin (FIL) 5,42 0,63%
TRON (TRX) 0,100289 2,32%
Ethereum Classic (ETC) 23,66 0,38%
Dai (DAI) 0,936859 0,05%
Tezos (XTZ) 0,880753 0,08%
Monero (XMR) 107,31 2,06%