paint-brush
How to Submit Your Smart Contracts to Etherscanby@talktomaruf
511 reads
511 reads

How to Submit Your Smart Contracts to Etherscan

by Abubakar MarufJune 15th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Etherscan is a free blockchain explorer that allows you to search for transactions, blocks, smart contracts, wallet addresses, and other on-chain data. Smart contracts are computer programs stored on the blockchain that allow us to convert traditional contracts into digital parallels. Anybody can view your source code and interact with your smart contract after it's published on Etherscan when you click the link in your terminal. The last argument—**"Hello World!"**—must have the same string value as the one you used in the initial deployment.

Coins Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - How to Submit Your Smart Contracts to Etherscan
Abubakar Maruf HackerNoon profile picture

Etherscan is the Ethereum network blockchain explorer that allows you to search for transactions, blocks, smart contracts, wallet addresses, and other on-chain data. Since Ethereum is a public blockchain, the website is a free blockchain explorer, and it's one of the most popular websites to look through all interactions on the Ethereum blockchain.


According to Ethereum.org, Smart contracts are computer programs stored on the blockchain that allows us to convert traditional contracts into digital parallels. As a computer program, it entails a collection of code—its function— and data—its state. Smart contracts are entirely rational, following an "if/then" pattern. This means they follow the program precisely and cannot be modified.


After the hard work of writing your smart contract, what is next is to share it with the rest of the world by verifying it on Etherscan. Anybody can view your source code and interact with your smart contract aftermath. Below are the steps to submit your smart contract to Etherscan:


STEP 1: Create an API key on your Etherscan account

The Ehterscan API key is essential to authenticate that you own the smart contract you're about to publish. So, log in to your Etherscan account or create one here if you don't have an account.

  • Once you've logged in to your account, click on your username in the top right corner and click on the "My Profile" tab.

  • Then click on the "API Keys" tab from the bottom left corner of the page. Another tab will pop up.

  • Click on the blue tab that reads "+ Add" on the top right corner of this tab to add your API key.

  • Next, input your App name in the field required and click on "Create New API Key."

  • ·         Then you have your API Key, as shown below.


  • Copy the API key to your Notepad or clipboard.


STEP 2: Deploying the smart contract using Hardhat

  • Install the hardhat-etherscan plugin and run the following command in your hello-world directory to install hardhat-etherscan: npm install –save-dev @nomiclabs/hardhat-etherscan
  • Next is to replace the hardhat.config.js with the hardhat-etherscan information in your file. Ensure you include your etherscan API key where required, as shown below:

  • Next is to verify your smart contract on Etherscan by running the command below in the terminal provided in the hello-world directory. The command is:

    npx hardhat verify –network goerli DEPLOYED_CONTRACT_ADDRESS "Hello World!"

  • Ensure that the DEPLOYED_CONTRACT_ADDRESS is the same smart contract address you deployed on the goerli test network. In addition, the last argument—"Hello World!"—must have the same string value as the one you used in the initial deployment.


If everything goes smoothly, your terminal should display the following message:

Congrats! Your smart contract code should be on Etherscan!


STEP 3: Go to Etherscan and check out your smart contract.

You should be able to view your smart contract code, and ABI published on Etherscan when you click the link supplied in your terminal.



Now, anyone can interact with your smart contract.