Tenderly / hardhat-tenderly

Tenderly plugin for HardHat
https://www.npmjs.com/package/@tenderly/hardhat-tenderly
Other
154 stars 40 forks source link

TypeError: contractName.getAddress is not a function #166

Open davidperk opened 9 months ago

davidperk commented 9 months ago

I'm getting this error from @tenderly/hardhat-tenderly when I run my deploy script. When I comment out tdly.setup(); from hardhat.config.ts, the deploy script runs successfully.

2023-12-11 21:30:25.181 ERROR Service =>There has been an error while verifying contracts, no verified contracts nor bytecode mismatch errors are returned.
TypeError: verifier.getAddress is not a function
    at main (/Users/davidperkins/Desktop/node-sol/scripts/deploy.ts:10:54)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

My deploy script:

import { ethers, tenderly } from "hardhat";

async function main() {
  const signers = await ethers.getSigners();
  const deployerAddress = await signers[0].getAddress();

  const verifier = await ethers.deployContract("Verifier", ["0x", deployerAddress]);
  await verifier.waitForDeployment();
  console.log(`Verifier deployed at ${await verifier.getAddress()}`);

  await tenderly.persistArtifacts({
    name: "Verifier",
    address: await verifier.getAddress()
  });
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

My Hardhat config:

import { HardhatUserConfig } from "hardhat/config";
...
import * as tdly from "@tenderly/hardhat-tenderly";
tdly.setup();

const config: HardhatUserConfig = {
  networks: {
    localhost: {
      chainId: 31337
    },
    sepolia: {
      chainId: 11155111,
      url: `https://sepolia.infura.io/v3/${process.env.INFURA_KEY}`,
      accounts: {
        mnemonic: process.env.MNEMONIC || ""
      }
    }
  },
  solidity: {
    settings: {
      optimizer: {
        enabled: true,
        runs: 200
      }
    },
    version: "0.8.20"
  },
  tenderly: {
    username: process.env.TENDERLY_USERNAME,
    project: process.env.TENDERLY_PROJECT,
    privateVerification: true
  }
};

export default config;

My devDependencies:

  "devDependencies": {
    "@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
    "@nomicfoundation/hardhat-ethers": "^3.0.5",
    "@nomicfoundation/hardhat-network-helpers": "^1.0.10",
    "@nomicfoundation/hardhat-toolbox": "^4.0.0",
    "@nomicfoundation/hardhat-verify": "^2.0.2",
    "@nomiclabs/hardhat-ethers": "^2.2.3",
    "@tenderly/hardhat-tenderly": "^2.0.1",
    "@typechain/ethers-v6": "^0.5.0",
    "@typechain/hardhat": "^9.1.0",
    "@types/chai": "^4.2.0",
    "@types/mocha": "^10.0.6",
    "@types/node": "^20.10.4",
    "chai": "^4.2.0",
    "env-cmd": "^10.1.0",
    "ethers": "^6.9.0",
    "hardhat": "^2.19.2",
    "hardhat-abi-exporter": "^2.10.1",
    "hardhat-deploy": "^0.11.44",
    "hardhat-gas-reporter": "^1.0.8",
    "prettier": "^3.0.2",
    "solidity-coverage": "^0.8.0",
    "ts-node": "^10.9.2",
    "typechain": "^8.3.2",
    "typescript": "^5.3.3"
  },
Beardev118 commented 4 months ago

Please use this pattern to get the contract address using getAddress() function

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

async function main() { console.log( "🖖🏽[ethers] Deploying TransparentUpgradeableProxy with VotingLogic as implementation on Tenderly.", );

const VotingLogic = await ethers.getContractFactory("VotingLogic");
let proxyContract = await upgrades.deployProxy(VotingLogic);
proxyContract = await proxyContract.waitForDeployment();

const proxyAddress = await proxyContract.getAddress();

console.log("VotingLogic proxy deployed to:", proxyAddress);
console.log(
    "VotingLogic impl deployed to:",
    await getImplementationAddress(ethers.provider, proxyAddress),
);

}

main().catch((error) => { console.error(error); process.exitCode = 1; }); `

ibrahimkhled commented 3 months ago

const VotingLogic = await ethers.getContractFactory("VotingLogic"); let proxyContract = await upgrades.deployProxy(VotingLogic); proxyContract = await proxyContract.waitForDeployment();

const proxyAddress = await proxyContract.getAddress();

console.log("VotingLogic proxy deployed to:", proxyAddress); console.log( "VotingLogic impl deployed to:", await getImplementationAddress(ethers.provider, proxyAddress), );