Want to quickly build a web UI for your smart contracts? Etherscan can do that for you! Read on to learn how to verify your Solidity smart contracts on Etherscan.
First, you’ll need it to flatten your Solidity contract into a single file for Etherscan. This means merging your files and their dependencies in the right order.
Flatten your Solidity contract
Navigate into your Truffle project, and run
truffle-flattener. You can copy the results to your clipboard with
Verifying on Etherscan
Go to your contract’s Etherscan page. Click ‘Verify and Publish’:
Select the ‘Solidity (Single file)’ Compiler Type and your Soliditty Compiler Version (e.g.
0.5.11). Press Continue:
Paste in your flattened Solidity contract.
Your constructor arguments should be filled automatically. Otherwise, go to the transaction hash of your contract deployment and retrieve it. Each argument supplied to the constructor is ABI-encoded and looks something like:
If you’ve enabled optimization in your Truffle configuration, be sure to specify ‘Optimization’ and ‘Runs’ to match those settings.
That’s it! You now have a handy web UI you can use to read and write against your smart contracts at
📬 Get updates straight to your inbox!
Subscribe to my newsletter to make sure you don't miss anything.