WEB3 MENTORING PROGRAM
👉 Apply here: https://bit.ly/3gteqcP
3 month mentoring program to become a professional Web3 developer Build a killer portfolio of Web3 projects to get a 6 figure job
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.
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…
Error: Contact form not found.