1

I'm trying to deploy a contract and verify it on mubai test network. Even though I have the exact same parameters in deploy and in verification, I can't seem to be able to validate it. It seems to be a problem in the constructor arguments, but I'm not quite getting it right.

Here is how I'm deploying the timelocks:

import { ethers } from "hardhat";
import { timelockConfigs } from "../config/timelockConfig";
import { TokenMultiTimelock } from "../types";

const eq9Address = "0x63aEB1ECE758F64B24b9386b2ba4D15Ef045712B";
const getUnixTime = (date: Date): number => {
  return Math.floor(date.getTime() / 1000);
};

async function main() {
  const [owner] = await ethers.getSigners();
  const balance = await owner.getBalance();
  const timelocks: TokenMultiTimelock[] = [];
  console.log("balance", balance.toString());

  const Token = await ethers.getContractFactory("EQ9");
  const eq9 = Token.attach(eq9Address);

  for (let i = 0; i < 1; i++) {
    const [dates, monthlyRelease, totalLocked, name] = timelockConfigs[i];
    console.log("contract name:", name);

    const TokenTimeLock = await ethers.getContractFactory("TokenMultiTimelock");

    const releaseTimesUnix = (dates as Date[]).map((i) => getUnixTime(i));

    const releaseAmounts = releaseTimesUnix.map(() =>
      ethers.utils.parseUnits(String(monthlyRelease), "ether")
    );

    const timelock = await TokenTimeLock.deploy(
      eq9.address,
      owner.address,
      releaseTimesUnix,
      releaseAmounts,
      String(name)
    );

    await timelock.deployed();

    timelocks.push(timelock);
    console.log("timelock deployed", timelock.address);
    const res = await eq9
      .connect(owner)
      .transfer(
        timelock.address,
        ethers.utils.parseUnits(String(totalLocked), "ether")
      );
    const receipt = await res.wait();
    console.log(receipt);
  }
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

And here is how I'm trying to verify them:

import { ethers, run } from "hardhat";

import { timelockConfigs } from "../config/timelockConfig";

const getUnixTime = (date: Date): number => {
  return Math.floor(date.getTime() / 1000);
};

async function main() {
  const [owner] = await ethers.getSigners();
  const [dates, monthlyRelease, name] = timelockConfigs[0];

  const releaseTimesUnix = (dates as Date[]).map((i) => getUnixTime(i));

  const releaseAmounts = releaseTimesUnix.map(() =>
    ethers.utils.parseUnits(String(monthlyRelease), "ether")
  );

  const eq9Address = "0x63aEB1ECE758F64B24b9386b2ba4D15Ef045712B";
  await run("verify:verify", {
    address: "0x1b1a8E73333C246ff56f082D4fDE7F6499E84Ee5",
    constructorArguments: [
      eq9Address,
      owner.address,
      releaseTimesUnix,
      releaseAmounts,
      String(name),
    ],
  });
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

I use the exact same params both in deploy and in verification. But it still doesn't work. Why?

For reference, the github code: https://github.com/equals9-com/eq9-token-contracts

I was already able to verify an ERC20 contract with hardhat.

Maybe the constructor params are too complex for validation?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.