Skip to content

Using mainnet hard fork gives Error: Missing required chain parameter: networkId #29

@sagefarrenholz

Description

@sagefarrenholz

Issue:

Attempting to use mainnet hard fork of hardhat produces the error in title.

Reproduction:

  1. Set hardhat.config.ts FORK_MAINNET to true
  2. Run a script using hardhat run --network hardhat <script>
  3. Call ethers.getSigners()

Error emitting line of script:

const Signer = (await ethers.getSigners())[0];

Hack solution

I was able to get rid of the error by deleting / commenting out:

 //chainId: !forkingData ? 43112 : undefined, //Only specify a chainId if we are not forking

in hardhat.config.ts

Output:

$ npx hardhat run --network hardhat scripts/<script>
Error: Missing required chain parameter: networkId
    at Common.setChain (<base_path>/node_modules/@ethereumjs/common/src/index.ts:318:17)
    at new Common (<base_path>/node_modules/@ethereumjs/common/src/index.ts:286:30)
    at Function.forCustomChain (<base_path>/node_modules/@ethereumjs/common/src/index.ts:237:12)
    at Object.makeForkCommon (<base_path>/node_modules/hardhat/src/internal/hardhat-network/provider/utils/makeForkCommon.ts:6:17)
    at Function.create (<base_path>/node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:157:22)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at HardhatNetworkProvider._init (<base_path>/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:232:28)
    at HardhatNetworkProvider._send (<base_path>/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:180:5)
    at HardhatNetworkProvider.request (<base_path>/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:106:18)
    at EthersProviderWrapper.send (<base_path>/node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions