Lesson 6: TypeError: (0 , ethers_1.getAddress) is not a function #5745
-
I am following along the code as it is being done in the video and getting the error as shown in the title (Timestamp 9:20:00). I was using ethers v6 but then I rolled back to v5.4.0 as v6 was giving me many errors as well. My deploy.js looks like this //import
const { ethers, run, network } = require("hardhat");
// async main
async function main() {
const SimpleStorageFactory = await ethers.getContractFactory(
"SimpleStorage"
);
console.log("Deploying contract...");
const simpleStorage = await SimpleStorageFactory.deploy();
await simpleStorage.deployed();
console.log(`Deployed contract to: ${simpleStorage.address}`);
// We cannot verify a contract that we have deployed on Hardhat since it is a local network
console.log(network.config);
if (network.config.chainId === 11155111 && process.env.ETHERSCAN_API_KEY) {
await simpleStorage.deployTransaction.wait(6);
await verify(simpleStorage.address, []);
}
//get current value from the smart contract
const currentValue = await simpleStorage.retrieve();
console.log(`Current value is ${currentValue}`);
//update the current value
const transactionResponse = await simpleStorage.store(7);
await transactionResponse.wait(1);
const updateValue = await simpleStorage.retrieve();
console.log(`Updated value is ${updateValue}`);
}
// async function verify(contractAddress, args) {
const verify = async (contractAddress, args) => {
console.log("Verifying contract...");
try {
await run("verify:verify", {
address: contractAddress,
constructorArguments: args,
});
} catch (e) {
if (e.message.toLowerCase().includes("already verified")) {
console.log("Already Verified");
} else {
console.log(e);
}
}
};
// main
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
}); And my require("@nomicfoundation/hardhat-toolbox");
//const task = require("hardhat/config");
task("block-number", "Prints the current block number").setAction(
async (taskArgs, hre) => {
const blockNumber = await hre.ethers.provider.getBlockNumber();
console.log(`Current block number is ${blockNumber}`);
}
);
module.exports = {}; After running
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
see here #5735 let me know if it works with you |
Beta Was this translation helpful? Give feedback.
-
you need to add |
Beta Was this translation helpful? Give feedback.
you need to update
"hardhat": "^2.14.1",
package to"hardhat": "^2.16.0",
then import them into
hardhat.config.js
file, like thisand modify
block-number.js
like this: