TypeError: Cannot destructure property 'verify' of 'require(...).default' as it is undefined. #2223
Answered
by
othaime-en
decentralized-86
asked this question in
Q&A
-
PS E:\Block Chain Projects\FUND_ME_FULLSTACK> yarn hardhat deploy --network goerli --tags fund
yarn run v1.22.15
warning ..\package.json: No license field
$ "E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\.bin\hardhat" deploy --network goerli --tags
fund
Nothing to compile
An unexpected error occurred:
Error: ERROR processing skip func of E:\Block Chain Projects\FUND_ME_FULLSTACK\deploy\01_fudme_deploy.js:
TypeError: Cannot destructure property 'verify' of 'require(...).default' as it is undefined.
at Object.<anonymous> (E:\Block Chain Projects\FUND_ME_FULLSTACK\deploy\01_fudme_deploy.js:3:8)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at DeploymentsManager.executeDeployScripts (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat-deploy\src\DeploymentsManager.ts:1093:22)
at DeploymentsManager.runDeploy (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat-deploy\src\DeploymentsManager.ts:1052:16)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at DeploymentsManager.executeDeployScripts (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat-deploy\src\DeploymentsManager.ts:1100:15)
at DeploymentsManager.runDeploy (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat-deploy\src\DeploymentsManager.ts:1052:16)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at SimpleTaskDefinition.action (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat-deploy\src\index.ts:438:5)
at Environment._runTaskDefinition (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat\src\internal\core\runtime-environment.ts:219:14)
at Environment.run (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat\src\internal\core\runtime-environment.ts:131:14)
at SimpleTaskDefinition.action (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat-deploy\src\index.ts:584:32)
at Environment._runTaskDefinition (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat\src\internal\core\runtime-environment.ts:219:14)
at Environment.run (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat\src\internal\core\runtime-environment.ts:131:14)
at SimpleTaskDefinition.action (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat-deploy\src\index.ts:669:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. MY verify.js const { run } = require("hardhat")
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)
}
}
}
module.exports = { verify } MY 00_deploy_fundme.js Where i used the verify to verify on etherscan const {networkConfig,developmentChains} = require("../helper-hardhat-config")
const {getNamedAccounts,deployments,network} = require("hardhat");
const {verify} = require("../utils/verify.js").default;
require("dotenv").config();
module.exports = async ({getNamedAccounts,deployments}) =>{
const {deploy,log} = deployments;
const {deployer}= await getNamedAccounts();
const chainID = network.config.chainId.toString();
console.log(typeof(chainID));
//IF chain ID is A then use address B
// IF CHAINID IS Z THEN USE C
let ethUsdPriceFeedAddress
if (chainID == "31337") {
const ethUsdAggregator = await deployments.get("MockV3Aggregator")
ethUsdPriceFeedAddress = ethUsdAggregator.address
} else {
ethUsdPriceFeedAddress = networkConfig[chainID]["ethUsdPriceFeed"]
}
// if the Price feed contract doesnt't exists then we deploy a
//minimal version of our testing
console.log("ethUsdPriceFeedAddress",ethUsdPriceFeedAddress)
// deploy on the another network
const fundme = await deploy("FundMe",{
from:deployer,
args: [ethUsdPriceFeedAddress],
log:true,
waitconfirmations:network.config.blockConfirmations || 1,
})
console.log(fundme.address)
if(!developmentChains.includes(network.name) && process.env.ETHERSCAN_API_KEY){
await verify(fundme.address, [ethUsdPriceFeedAddress])
}
log("------------------------------------------");
}
module.exports.tags = ["fund","all"]; |
Beta Was this translation helpful? Give feedback.
Answered by
othaime-en
Aug 31, 2022
Replies: 1 comment 2 replies
-
@decentralized-86 Remove Also, remove the extension |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
alymurtazamemon
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@decentralized-86 Remove
.default
in this lineconst {verify} = require("../utils/verify.js").default;
in your deploy-fundme fileAlso, remove the extension
.js
. Rewrite the line like this:const {verify} = require("../utils/verify");
The extension is probably what is causing the error in this case. And make sure that you indeed have the file in the specified location
../utils/verify