0

[Fixed] hardhat-tools change deployment's functions. For hardhat-tools 3.0.0:

deploy() is now deployContract() deployed() is now awaitForDeployment()

We can downgrade hardhat-tools or use the new ones.


When I use Hardhat to deploy the contract in Sepolia, I keep getting the following error:

enter image description here

My deploy script:

const { ethers } = require("hardhat");

async function main() {
  const whitelistContract = await ethers.getContractFactory("Whitelist");
  const deployedWhitelistContract = await whitelistContract.deploy(10);
  await deployedWhitelistContract.deployed();
  console.log("Whitelist Contract Address:", deployedWhitelistContract.address);
}

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

My hardhat-config file:

require("@nomicfoundation/hardhat-toolbox");
require("dotenv").config({ path: ".env" });

const QUICKNODE_HTTP_URL = process.env.QUICKNODE_HTTP_URL;
const PRIVATE_KEY = process.env.PRIVATE_KEY;

module.exports = {
  solidity: "0.8.10",
  networks: {
    hardhat: {},
    sepolia: {
      url: QUICKNODE_HTTP_URL,
      accounts: [`0x${PRIVATE_KEY}`],
   },
  },
};

2 Answers 2

0

Remove 0x from the private key. Just pass the private key like this

accounts: [process.env.PRIVATE_KEY]
1
  • I deployed without 0x and happened the same error: "TypeError: no matching function"
    – Duccini
    Jun 10 at 16:33
0

The error message shows, .deployed() does not exist. so use waitForDeployment() instead .deployed().

and also use .target or await deployedWhitelistContract.getAddress() instead of .address

RIGHT CODE:

const { ethers } = require("hardhat");

async function main() {
  const whitelistContract = await ethers.getContractFactory("Whitelist");
  const deployedWhitelistContract = await whitelistContract.deploy(10);
  await deployedWhitelistContract.waitForDeployment();
  console.log("Whitelist Contract Address:", await deployedWhitelistContract.getAddress());
}

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.