Publish and Verify your Smart Contract for it’s Authenticity on Etherscan

Hemant Juyal
Coinmonks
5 min readJun 25, 2022

--

We will learn how to verify our deployed solidity Smart Contract on Etherscan for its Authenticity.

Note: This is the next stage of our previous work where we learnt how to interact with a deploy a Smart Contract on a Blockchain.

Why to Verify our Smart Contract?

It’s always good to publish your smart contract so that it can be verified as a proof of authenticity. The source code of a smart contract or token contract becomes publicly available and verifiable once it has been validated. Through this process transparency and trust are established.

Smart Contract: Verification for Authenticity
Smart Contract: Verification for Authenticity

For newbies, Etherscan is a Ethereum block explorer. Any user can access Etherscan to obtain statistics about the Ethereum network. The platform’s prime objective is to present data about the network’s blocks and transactions.

Create Etherscan Account and Generate API Key

For the verification process first of all we need to create an account in Etherscan which can be done using the link. Once our Etherscan account is created then using My Profile link we can navigate to Account Overview screen and select API Keys

Smart Contract: Etherscan Account Overview Screen
Smart Contract: Etherscan Account Overview Screen

Create Etherscan API Key

Creating an Etherscan API key is very simple you have provide an App Name and hit the Create New API Key button. Voila!!!! it’s done

Smart Contract: Create Etherscan API Keys
Smart Contract: Create Etherscan API Keys

Make a note of API Key token from the newly created API Key as we will be using it later as a configuration parameter in our project.

Smart Contract: Etherscan API Key Details
Smart Contract: Etherscan API Key Details

Smart Contract Project

Refer to Smart Contract project setup section if you haven’t done the project set-up earlier, as we will go through the configuration files to verify our deployed smart contract. What we have done in our previous stages is checked-out the greetings smart-contract project code from Github into our local directory.

After cloning the project, you will see the project structure as

Smart Contract: Github project set-up
Smart Contract: Github project set-up

.env Configuration Updation
We had .env file created during our contract interaction and deployment process which has our Smart Contract project configurations.

To publish and verify our Smart Contract, we will update our .env file by adding ETHERSCAN_API_KEY as an updated configuration. Remember we will use the same API Key that we have noted in our previous step i.e. Create Etherscan API Key right after creating Etherscan Account.

Note: In the previous post section we have done configuration for interacting with our deployed Smart Contracts

With this our .env file will looks like

Smart Contract: .env file updated configuration for verification

Verifying your deployed Smart Contract

Run the command in the CLI to start the source code publishing and verification process

As per our .env configuration the command will look like below where 0xac2726........672ba6 represents the CONTRACT_ADDRESS

Note: Change the CONTRACT_ADDRESS with the mentioned .env file configuration param value which refers to our deployed Smart Contract address. You can refer to previous post where we have created and deployed a Smart Contract.

Running the above command in CLI will produce output as

In your CLI / Terminal screen, copy the verified Smart Contract URL and navigate to the link which will show the Etherscan page having published details for our verified Smart Contract

Smart Contract: Published and Verified source code
Smart Contract: Published and Verified source code

Yeeeeyyyy….. our Smart Contract is published and verified on Etherscan. Now anyone can have a look at the source code to verify the Authenticity as whether our Smart Contract is really doing what it’s supposed to perform.

Along with this through Etherscan, we can also play with our published Smart Contract as it has Read Contract and Write Contract features which acts as an add-on to verify the operations through exposed interfaces.

Congratulations!! We have done it and at the end let’s do some super celebration.

Smart Contract: Verification successful and now it’s time for super celebration
Smart Contract: Verification successful and now it’s time for super celebration

Images Credit: Paramount Pictures and Leonardo DiCaprio.

Glossary:

Ethereum: Ethereum is a decentralized, open-source blockchain with smart contract functionality. From Wikipedia

Etherscan: Etherscan is a service on which any user can view Ethereum network statistics. From Wikipedia

Solidity: Solidity is an object-oriented programming language for implementing smart contracts on blockchain platforms. It’s influenced by C++, JavaScript and Python.

Hardhat: Hardhat is a development environment to compile, deploy, test, and debug Ethereum based softwares.

--

--

Hemant Juyal
Coinmonks

I am a Technologist with a passion for innovation, I always love staying on top of the most recent advancements and developments in the field of technology.