hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

Enforce contract verification

Open rimrakhimov opened this issue 1 year ago • 1 comments

Description

On contract verification, blockscout differentiates source codes on partial and full matches. In case of partially verified contracts re-verification of such contracts is allowed. But it is not possible to re-verify such contracts via Hardhat rn, as it always returns "The contract {contract_address} has already been verified on Etherscan."

Suggestion

We suggest to add a new flag on verify:verify subtask - --skip-is-verified-check. That should disable the if(isVerified) condition to prevent verification attempt.

A kind of similar approach has been adopted by foundry - https://github.com/foundry-rs/foundry/pull/6461.

I may try to create a PR with corresponding changes. Just would like to ensure that you are fine with suggested approach.

Minimal Reproducible Steps

  1. Create a new template project and update Lock.sol contract to have a contract named ModifiedMetadataHashLock.
  2. config hardhat network:
const config: HardhatUserConfig = {
  solidity: "0.8.24",
  networks: {
    sepolia: {
      url: 'https://endpoints.omniatech.io/v1/eth/sepolia/public',
      accounts: [PRIVATE_KEY],
    },
  },
  etherscan: {
    apiKey: 'ETHERSCAN_API_KEY',
    customChains: [
      {
        network: "sepolia",
        chainId: 11155111,
        urls: {
          apiURL: "https://eth-sepolia.blockscout.com/api",
          browserURL: "https://eth-sepolia.blockscout.com/",
          // apiURL: "https://api-sepolia.etherscan.io/api",
          // browserURL: "https://sepolia.etherscan.io/",
        }
      }
    ]
  }
};
  1. npx hardhat verify 0xcA30DBB0Cb79cef0194f6e212B49fa1EB7246b61 --network sepolia 123
  2. Output (even though the contract has been verified only partially and can be re-verified):
The contract 0xcA30DBB0Cb79cef0194f6e212B49fa1EB7246b61 has already been verified on Etherscan.
https://eth-sepolia.blockscout.com/address/0xcA30DBB0Cb79cef0194f6e212B49fa1EB7246b61#code

Search terms

No response

rimrakhimov avatar Apr 15 '24 10:04 rimrakhimov

This is a feature we want to see, though we would suggest --force instead of --skip-is-verified-check as the flag.

kanej avatar Apr 17 '24 11:04 kanej