hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

HardhatError: HHE40000: No network with chain id "9876" found.

Open wisehalvdan opened this issue 2 weeks ago • 1 comments

Version of Hardhat

3.0.17

What happened?

When using ignitions, there is no way to use chains not supported by viem.

Even if we override the network passed in to network.connect() I think ignition still has some dependency to viem and tries to look for chainid in viem network lists.

It can work by monkey patching the viem but since it is pulled in compiled, patching typescript and adding the new chain is not enough and resulting js files also needs to be monkey patched which defeats the purpose.

Also just passing the custom object in a network.connect() breaks the hardhat usual --network <definedNetworkName> flow and makes scripts / ignitions only work on set chain.

Minimal reproduction steps


const gccnet = {
    id: 9876,
    name: "GCCNET",
    network: "gccnet",
    nativeCurrency: {
        name: "GCC",
        symbol: "GCC",
        decimals: 18,
    },
    rpcUrls: {
        default: {
            http: ["https://gccnet.com"],
        },
    },
    blockExplorers: {
        default: {
            name: "explorer",
            url: "https://gccscanner.com",
        },
    },
};

const gccnetChain = defineChain(gccnet)
const { viem, networkName, ignition } = await network.connect(gccnetChain);
const wallets = await viem.getWalletClients(
    {
        chain: gccnetChain,
    }
);


const wallet = wallets[0];

async function main() {
    console.log(`Deploying to ${networkName}... on wallet ${wallet.account!.address}`);

    const { airdropper } = await ignition.deploy(AirdropperModule);
}

Search terms

No response

wisehalvdan avatar Dec 08 '25 13:12 wisehalvdan

Hey, I think the issue here is that network.connect("my-network-in-hardhat-config") expects the name of the network in the hardhat.config.ts or a parameters object. You are passing in a viem chain descriptor, which network.connect is interpreting as network params but ignoring the unexpected properties. If you update the networks config in hardhat.config.ts: https://hardhat.org/docs/reference/configuration#network-configuration, then you can use the name of the network config in connect:

const { ignition } = await network.connect("mynetwork");

const { airdropper } = await ignition.deploy(AirdropperModule);

kanej avatar Dec 09 '25 10:12 kanej