Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

TypeError: customChains is not iterable #122

Open
shawnesquivel opened this issue Dec 15, 2022 · 2 comments
Open

TypeError: customChains is not iterable #122

shawnesquivel opened this issue Dec 15, 2022 · 2 comments

Comments

@shawnesquivel
Copy link
Contributor

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
Copy link
Contributor Author

shawnesquivel commented Dec 15, 2022

as per this recommendation, smartcontractkit/hardhat-starter-kit#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

shawnesquivel added a commit to shawnesquivel/hardhat-fund-me-fcc that referenced this issue Dec 15, 2022
As per this issue PatrickAlphaC#122 and referencing this solution used from hardhat repo smartcontractkit/hardhat-starter-kit#140
@Nikhil8400
Copy link

Nikhil8400 commented Sep 4, 2023

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants