5-minute Tut: verifying your truffle-solidity contracts on Etherscan
This is a quick, 5-minute tutorial on how to verify your solidity contracts, written using truffle, on etherscan.io
Navigate to your contract
First of all, navigate to your contract on the chain. It can be found at https://etherscan.io/address/YOUR_HASH#code
Navigate to Verify and Publish to go to the correct verification page.
We'll need to add some extra parameters, which can only be enabled by pointing your the url to a different endpoint. Change "contractVerify" to "contractVerify2" in your url.
Fill in the correct values
Next up, you'll need to fill in the correct values in the form. Enter the contract name you wish to verify. Choose the correct compiler. You can find the correct compiler by opening a new terminal and entering the following command.
The result will most likely be a non-nightly build.
The correct value for Runs, which is the amount of times the optimization should run, is 0.
Paste the contents of your contracts in the code box. Keep the code as it was when you deployed it, but remove all the imports, as all code will be in a single file, so importing will not be necessary or supported.
If you deployed a contract which contained constructor arguments, you'll need to add them in the following input box. Constructor arguments are expected to be ABI-encoded. More information on ABI-encoding can be found on the page, but remember arguments are right to left. An example for one of our projects can be found below.
Lastly, you'll need to add any libraries you're using. You can find the location of your Libraries in the output of Truffle when you deployed them or in the generated json files.
That's it, hit verify and publish. Your contract should now be verified. Your code should be visible on your contract and methods for reading the state of your contract will be available on the web page.
Why verify your contracts?
The reason we always verify our contracts is easy. First of all, it generated trust. People can see your contracts and verify the code with what you claim they should be doing.
Secondly, it's darn useful to have an easy go-to page to read the state of your contracts.