Deploy Your NFT Contract to Goerli Testnet

Shahir Zain
Coinmonks
5 min readJul 24, 2022

--

Hi Folks I’m back with another article. I hope you guys will enjoy and learn from this one too. I will tell you how to deploy the Contract to the Network in this article. Networks are different Ethereum environments You can access them for Development, Testing, and Production. Since Ethereum is a protocol then there may be multiple Ethereum networks here are some abstract lists:

Public Network: Public Network are accessible to anyone throught an internet connection. Anyone read and create transactions on a public blockchain and validate the transaction being executed.

Ethereum Mainnet: Mainnet is the primmary public Ethereum production blockchain Where the actual transaction occurs.

Ethereum Testnets: There are test networks that is used by Blockchain developer to test their smart contract and before deployment on the Mainnet. You can consider the Testnets as the stage environment.

There is a list of Ethereum Testnet but we are going for the Goerli Test network. So how do deployments? How it actually works? I will tell you guys. Connect with me. If you are interested to learn some other stuff don't hesitate to get in touch with me through LinkedIn and through mail: shahirzain100@gmail.com

so for deployment, you need a contract so we start from scratch.

We will walk through creating and deploying ERC-721, You should have
HardHat, Solidity, Metamask, and Alchemy.

Step- 01

make a directory mkdir rich-rhinos and go into the directory cd rich-rhinos

run command npm init -y with -y for a default configuration. Make sure you have Node.js installed on your machine.

Then install the Hardhat command npm i hardhat and then run npx hardhat in your terminal, you should see a welcome message and some options, select create an empty hardhat.config.js

Step-02

create a folder for Contracts and scripts. Create file name rich_Rhinos.sol write your contract in the contract folder Like I have mine

so, after importing statements we have our custom NFT contract. This contract is actually short. If you focus on the constructor we pass two parameters, the first one is an NFT name and the second one is the NFT symbol. Finally, we have the function mintNFT(address recipient, string memory tokenURI) that allows us to mint an NFT!

Step-03

Go to Alchemy, and create your account if you don't have any. Once you get logged in there is an Apps tab on which you have to hover and then click on the create App .

Enter the name of your NFT like mine have Rich Rhinos and chose network like I chose Goerli testnet

go to your app from the Apps drop-down, click on the view key

copy the API KEY and HTTPS go to the project and install dotenv npm install dotenv --save create .env file and paste the copied item like

note: don't commit your .env file please add it to your gitignore file.

Step-04

install Ether.js in your app

this library provides easier interaction with the Ethereum blockchain. so far w have added multiple dependencies so we need to update our hardhat.config.js your hardhat config should look like this

Step-05

now it's time to compile and write the deployment script. To make sure everything is perfect we need to compile our contract by typing this command in the terminal

if everything is perfect then go to the scripts folder and create a file named deploy.js and the below statements

but for the deployment, you should have a digital wallet like metamask, Download metamask and choose the network as goerli.

for the first time you have 0 goerli Eth so deployment needs some gas fees so go to this site https://goerli-faucet.slock.it/for faucet eth.

Now the time has come to run the deployment command in your terminal

you should see something like this.

If we go to the Goerli etherscan and search for our contract address we should be able to see that it has been deployed successfully.

Yayyyyyy! You just deployed your NFT smart contract to the Ethereum chain!

That’s it, folks! hope it was a good read for you. Thank you! ✨

👉 Contact me: shahirzain100@gmail.com

👉 Follow me: GitHub LinkedIn

New to trading? Try crypto trading bots or copy trading

--

--

Shahir Zain
Coinmonks

I am a tech enthusiast and a visionary person and have been in the software industry for the last 3 years, I believe in sharing knowledge with each other.