UUPS Implementation Contract not verifyable? Msg: contract was unfortunately not detected

TLDR: UUPS Implementation contract is not able to be verified on etherescan goerli. I followed documentation here:

I tried both manual & automatic verification:

  • i.e npx hardhat verify --network goerli *imp/verify address*
    and I tried verifying both proxy and implementation contracts. Below is the error I get:
Failed to verify implementation contract at 0xA19C88A53D487f455f2200a2863b6cF9F1A53c69: The contract verification failed.
Reason: Fail - Unable to verify
Verifying proxy: 0x0D52665Aa58b03157783e4bB565B914ACC5b8C9B
Contract at 0x0D52665Aa58b03157783e4bB565B914ACC5b8C9B already verified.
Linking proxy 0x0D52665Aa58b03157783e4bB565B914ACC5b8C9B with implementation
Failed to link proxy 0x0D52665Aa58b03157783e4bB565B914ACC5b8C9B with its implementation. Reason: A corresponding implementation contract was unfortunately not detected for the proxy address.
Error: Verification completed with the following errors.

Error 1: Failed to verify implementation contract at 0xA19C88A53D487f455f2200a2863b6cF9F1A53c69: The contract verification failed.
Reason: Fail - Unable to verify

Error 2: Failed to link proxy 0x0D52665Aa58b03157783e4bB565B914ACC5b8C9B with its implementation. Reason: A corresponding implementation contract was unfortunately not detected for the proxy address.

:1234: Code to reproduce


:computer: Environment

I am deploying with hardhat. Below are dependencies

    "@nomicfoundation/hardhat-toolbox": "^2.0.0",
    "@nomiclabs/hardhat-etherscan": "^3.1.3",
    "@openzeppelin/contracts-upgradeable": "^4.8.0",
    "@openzeppelin/hardhat-upgrades": "^1.21.0",
    "dotenv": "^16.0.3",
    "hardhat": "^2.12.3"

below is smart contract

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

contract MyTokenV1 is Initializable, ERC20Upgradeable, UUPSUpgradeable, OwnableUpgradeable {
    function initialize() initializer public {
      __ERC20_init("MyToken", "MTK");
      __Ownable_init();
      __UUPSUpgradeable_init();
      _mint(msg.sender, 1000 * 10 ** decimals());
    }

    function _authorizeUpgrade(address) internal override onlyOwner {}


    /// AK_NOTES: idk if this is needed. look into later. 
    /// @custom:oz-upgrades-unsafe-allow constructor
   constructor() initializer {}
}

below is deployment code

import { ethers, upgrades, run } from "hardhat";

async function main() {
  const MyTokenV1 = await ethers.getContractFactory("MyTokenV1");
  const myToken = await upgrades.deployProxy(MyTokenV1, { kind: "uups" });
  const resp = await myToken.deployed();
}

This looks like the problem is with verifying the implementation contract at address 0xA19C88A53D487f455f2200a2863b6cF9F1A53c69. The other errors seem to be caused by that.

Please follow How to verify a contract on Etherscan/BscScan/PolygonScan and see if you can verify the implementation contract by itself. For example, try passing in the implementation contract address to the npx hardhat verify command which will use hardhat-etherscan directly.

1 Like