Right now verifying our smart contracts in Blockscout has been quite difficult with Hardhat, mainly due to the fact that multiple licenses are embedded when flattening the smart contract, as well as the usage of abiencoder v2
. The first issue can be seen documented here, and the second one has been describe already here. The "official" solution by NomicLabs is being tracked here. For the time being, to solve this, we implemented this workaround.
- Create flatten version using workaround script
yarn workspace @hoprnet/hopr-ethereum run hardhat flat contracts/HoprChannels.sol --output HoprChannels-flatten.sol
-
Go to https://blockscout.com/xdai/mainnet/address/$address_to_verify/contract_verifications/new, select
Via flattened source code
and click "Next". -
Fill the "New Solidity Smart Contract Verification" form with the following information:
Contract Name: HoprChannels.sol
Include nightly builds: No
Compiler: v0.8.9+commit.e5eed63a (as of time of writing, this might change, this also depends on the contract you are verifying)
EVM Version: default
Optimization: yes
Optimization runs: 200 (as of time of writing, might change)
Enter the Solidity Contract Code: *copy the contents of HoprChannels-flatten.sol*
Try to fetch constructor arguments automatically: yes
- Click "Verify & Publish"