HardhatError: HHE40000: No network with chain id "9876" found.
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
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);