How To Verify Smart Contracts On Etherscan in Remix IDE

Eze Amaka
6 min readApr 1, 2022

--

Verifying smart contracts on Etherscan allows users to see your solidity smart contract code and be able to interact with the smart contract from Etherscan. So, this article is going to walk you through how to verify smart contracts from the Remix IDE (Solidity online smart contract writing tool).

To successfully verify our smart contract, here are some prerequisites;

  • You need Metamask installed
  • You need to create an account with Etherscan
  • You need some test faucets (I will be using Rinkeby)

If you have these three things done, let's begin.

We will be using this MyContacts smart contract code for this demo. You can simply copy the code to Remix and test it.

However, I am more interested in showing you how to verify this smart contract on Etherscan. So, if you have tested the code and it's working, then let's proceed.

Disclaimer! from step1 to step5 is how to create and deploy a smart contract. If you already know how to do this, you can jump to step6 to see how to actually verify the smart contract

Step1: Install Metamask

If you don’t already have Metamask installed on your computer, visit metamask to download and install the chrome extension. Metamask will be used to sign out transactions (in these cases deploy the contract to Etherscan as the owner of the smart contract).

However, if you have it installed, you can continue to the next step.

Step2: Get Your Etherscan API Key

As the owner of the smart contract, you need an API to be able to verify on etherscan that you are the real owner of the smart contract. So, if you have already created an account, log in to Etherscan.io or sign up, if you don’t have one.

Click on my profile, under my profile, scroll down to the Others Section and click on API Keys

API Key section — How to verify smart contract on Etherscan from Remix IDE

You can now generate a new API Key.

Note! You can only generate 3 API Keys, so if you want to verify your fourth smart contract, you will need to delete one API Key and generate a new one. Or, better still, use one Key to verify multiple smart contracts.

Now that you have generated your API Key, let’s move to the next step.

Step3: Download The Etherscan Plugin Remix IDE

The next to do is to download the Etherscan Verification Plugin on Remix.

  • Click on the Plugin section on the Remix IDE
Remix — Eherscan smart contract verification
  • In the search box, search for Etherscan Contract Verification
  • Click on activate, to activate the plugin, then click the settings
  • Inside the setting paste the Etherscan API Key that you generated in step2 and click Save API Key
Save api key

If you have followed through till now, congratulations.

Step4: Connecting Remix to Rinkeby Testnet

As I said, I will be using Rinkeby for this verification. Feel free to use any of the Testnet that you like, just make sure you have some faucets available in your Metamask account. You can get some faucets from chainlink.

With that out of the way, let’s connect our Remix to the Rinkeby.

  • Click the deploy tab, in the Environment section, click the drop-down and select Injected Web3
connecting to metamask
  • Metamask will pop up asking you to allow the connection with Remix. Confirm the transaction and connect to Remix.
  • For most persons, your Metamask may be on the mainnet network. So, you have to change it to testnet that you have some faucets that will allow you to pay for the gas fee.
  • Click on the Metamask icon on the chrome extension panel, click on the networks tab, and change to the testnet that you have faucets. If you did not see any testnet. Click on the hide/show test networks

Once connected successfully, you can now proceed to deploying and verifying the smart contract on Etherscan.

Step5: Deploying The Smart Contract

To deploy the contract, simply click on the Deploy and Run Tab. This smart contract takes in a unit num. You will see why, during the verification.

Add the number. This is the total amount of contacts the smart contract can save. For example, if you enter 5, the smart contract will only be able to save 5 contacts.

After adding the number, click on deploy and copy the contract address

deploying smart contract

Once you click deploy, Metamask will pop up, asking you to confirm the transaction and pay the gas fee. Click confirm.

After confirmation, the contract will be deployed to Etherscan and you can view the deployed smart contract details. Click on the newly created contract address to see more details about the contract.

smart contract creation

If you clicked on the address, you are going to see a page that is similar to the one below. This contract address will be different from yours.

contract details on etherscan — deploying and verifying smart contracts

Click on the Contract tab to see more details and you will a section that says

Are you the contract creator? Verify and Publish your contract source code today!

Step6: Verifying The Smart Contract

Here is the real deal. I know this is the section that you have been waiting for. So, let’s now verify our MyContact smart contract.

  • Goto Remix, click on the Etherscan verification plugin we installed earlier
  • Select the contract you want to verify in the Contract section
  • In the Contract Address, paste the contract address that was created in Etherscan
  • In the Constructor Arguments section, you can leave it blank if your constructor does not require any values. But, in this example, our smart contract needs a value. The total amount of contacts that can be saved. So, we need to pass in a constructor argument and it must be a hex-encoded value. Visit ABI Encoding to convert the constructor argument to a hex-encoded value and copy the hex-encoded and paste it into the Constructor Arguments section
  • Then click verify
Contract verification

If you have followed the step correctly, you will have your smart contract verified.

Now, go back to Etherscan, and click the Contract section, you see that the smart contract will have been verified. You will know with the green checkmark.

Congratulations if you made it this far. You have successfully verified your smart contract.

If this post was interesting to you, do follow me here on Medium and GitHub for more

Also, before you leave, if you are interested in crypto and making money with crypto, you can read this article on the best trading strategy for beginners

Thanks

--

--

Eze Amaka

A detail-oriented Solidity Smart Contract Developer and Technical Writer with a knack for conceptualizing and delivering quality content