Skip to content

feat requrest: custom ethereum chain with hardhat-viem plugin #5928

@y0sher

Description

@y0sher

Describe the feature

Description

My project is using hardhat-viem

When setting up a local Ethereum development network ( not hardhat/foundry, a whole ethereum network ), in hardhat.config.ts, e.g:

  config.networks = {
    devnet: {
      chainId: 3113031,
      url: `localhost:mygeth`,
      accounts: [
        "myaccount"
      ],
      gasPrice: '',
      gas: '',
    }
}

I'm getting this error:

Error in plugin @nomicfoundation/hardhat-viem: No network with chain id 3113031 found. You can override the chain by passing it as a parameter to the client getter:

import { someChain } from "viem/chains";
const client = await hre.viem.getPublicClient({
  chain: someChain,
  ...
});

You can find a list of supported networks here: https://github.com/wevm/viem/blob/main/src/chains/index.ts

For more info run Hardhat with --show-stack-traces

Feature request

I want to be able to direct hardhat-viem to my defined chainId and node url, should probably use defineChain from viem, somewhere around this codepath I guess. I tried to sketch up some code, but it seems not as trivial since EthereumProvider doesn't exposes the json url.

Search terms

No response

Metadata

Metadata

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions