How to verify UUPS implementation contract with etherscan

Hi! I'm Attempting to verify an implementation contract with etherscan at deployment time. It is a UUPS proxy.

I get this error but I don't understand why. Should I be verifying the implementation contract another way?

Failed to verify contract: Error: ENOENT: no such file or directory, open '<user path>/artifacts/build-info/8c4184211ce21779256de79bc0ee0021.json'

:1234: Code to reproduce

Here is a deploy script I was playing around with.

import hre from "hardhat";

export async function deployContract(): Promise<void> {
  const { ethers } = hre;
  const [deployer] = await ethers.getSigners();
  const deployerAddress = await deployer.getAddress();

  console.log(`Deploying contracts as ${deployerAddress}`);

  const factory = await ethers.getContractFactory("Test");
  const contract = await hre.upgrades.deployProxy(factory, [], {
    kind: "uups",
  });
  await contract.deployed();
  console.log(`Test deployed - txHash: ${contract.deployTransaction.hash} - Proxy address: ${contract.address} \n\n`);


  const implementationAddress = await hre.upgrades.erc1967.getImplementationAddress(contract.address);
  console.log('Contract implementation is:', implementationAddress);

   // Verify implementation on etherscan
   if (implementationAddress) {
    console.log(`Attempting to verify implementation contract with etherscan`);
    try {
      await hre.run("verify:verify", {
        address: implementationAddress,
        constructorArguments: [],
      });
    } catch (e) {
      console.log(`Failed to verify contract: ${e}`);
    }
  }
}

deployContract()
  .then(() => process.exit(0))
  .catch((error: Error) => {
    console.error(error);
    process.exit(1);
  });


2 Likes

If you have not already solved your problem, this post helped me - https://ethereum.stackexchange.com/questions/121176/error-when-trying-to-verify-contract

1 Like