How to (manually?) verify a solidity smart contract on etherscan

Antisocial Extrovert
Blockchain thoughts
3 min readAug 21, 2020

--

Etherscan

If you are a solidity smart contract developer, one of the biggest issues you face with deploying a contract to production (and having people use it), usually is verifying a contract.
A verified contract basically gives the ability for people to call your smart contract functions directly form etherscan. It looks like this:

Implement smart contract functions

I’m going to use an example ERC20 Token contract. source code is available here.
First, you need to install sol-merger. I usually just add to my npm scripts as
flatten: "sol-merger \"./contracts/*.sol\” ./flatten"
this helps me flatten my contracts using npm run flatten

Now that your contract has been flattened, head over to Remix to deploy your contract. if you’re not familiar with deployments via remix, head over to their docs here.
Create a .sol file, paste your flattened contract and compile. After which you deploy to your preferred network. For this example, I used ropsten.

Once your contract is deployed, head over to your contract address on etherscan. click on contract -> verify and publish

fill your details like so

It takes you to a new page, where you paste your solidity code (which you deployed from remix). set your optimisation.

On the next tab, you see a Constructor Arguments ABI-Encoded tab, this is for contracts which have to be deployed with a constructor.
Back in your remix environment, copy the ABI associated with that compiled contract, head over to hashex. hashex helps parse your constructor to generate ABI-encoded output

Hashex’s page

Copy the ABI encoded constructor output, paste in etherscan’s constructor arguments, perform the captcha then click on verify

Make sure the constructor parameters you entered in remix match what you enter in hashex. made this mistake at first

Your contract should be verified. you can head over to your contract address. you should see

Verified Jude Token

If all this is way too much stress, checkout truffle-plugin-verify package on github.

--

--