PatrickAlphaC / hardhat-fund-me-fcc

82 stars 183 forks source link

TypeError: customChains is not iterable #122

Open shawnesquivel opened 1 year ago

shawnesquivel commented 1 year ago

I have an issue when deploying my 01-deploy-fund-me.js script. When I type into command line:

yarn hardhat deploy --network goerli

I get the following error. Following the stack trace, it looks like in prober.ts, there is a destructuring of customChains which should be an array. I'm not sure where customChains comes from though.

Error Message

Verifying contract...
<contractId> [ '0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e' ]
TypeError: customChains is not iterable
    at getEtherscanEndpoints (/home/shawnesquivel/hh-fcc/hardhat-fund-me-fcc/node_modules/@nomiclabs/hardhat-etherscan/src/network/prober.ts:33:37)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Environment._runTaskDefinition (/home/shawnesquivel/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:308:14)
    at Environment.run (/home/shawnesquivel/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:156:14)
    at SimpleTaskDefinition.verifySubtask [as action] (/home/shawnesquivel/hh-fcc/hardhat-fund-me-fcc/node_modules/@nomiclabs/hardhat-etherscan/src/index.ts:220:30)
    at Environment._runTaskDefinition (/home/shawnesquivel/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:308:14)
    at Environment.run (/home/shawnesquivel/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:156:14)
    at verify (/home/shawnesquivel/hh-fcc/hardhat-fund-me-fcc/utils/verify.js:7:9)
    at Object.module.exports [as func] (/home/shawnesquivel/hh-fcc/hardhat-fund-me-fcc/deploy/01-deploy-fund-me.js:38:9)
    at DeploymentsManager.executeDeployScripts (/home/shawnesquivel/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1220:22)

01-deploy-fund-me.js


module.exports = async ({ getNamedAccounts, deployments }) => {
    ...

    const args = [ethUsdPriceFeedAddress]

    // To change chains, use a mock
    const fundMe = await deploy("FundMe", {
        from: deployer,
        args: args, // put price feed address
        log: true,
        waitConfirmations: network.config.blockConfirmations || 1,
    })

    // not a local network - verification needed
    if (
        !developmentChains.includes(
            network.name && process.env.ETHERSCAN_API_KEY
        )
    ) {
        log(fundMe.address, args)
        await verify(fundMe.address, args)
    }

    log("---------------------------------------")
}

verify.js

const { run } = require("hardhat")
async function verify(contractAddress, args) {
    console.log("Verifying contract...")

    try {
        console.log(contractAddress, args)
        await run("verify:verify", {
            address: contractAddress,
            constructorArguments: args,
        })
    } catch (err) {
        if (err.message.toLowerCase().includes("already verified")) {
            console.log("Already Verified!")
        } else {
            console.error(err)
        }
    }
}

module.exports = { verify }
shawnesquivel commented 1 year ago

as per this recommendation, https://github.com/smartcontractkit/hardhat-starter-kit/issues/140 I changed my hardhat.config.js etherscan property to include the following. I'm not sure why it works, all I know is that it works - my contract was successfully verified after doing this.

module.exports = {
    etherscan: {
        apiKey: ETHERSCAN_API_KEY,
        customChains: [],
    },
}

then re-deploying

yarn hardhat deploy --network goerli
Nikhil8400 commented 10 months ago

in your config file add custom chains in etherscan . etherscan: { apiKey: ETHERSCAN_API_KEY, customChains: [], },