question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: could not detect network chain '0x1'

See original GitHub issue

Ethers Version

5.6.0

Search Terms

metamask, ethers chain id

Describe the Problem

So this is the first time that’s ever happened to me and I’m not sure why. I’d love some insights for this.

Obtaining the chainId crashes with the error “could not detect network chain” using metamask.

image

Using: Ethers 5.6.0 Metamask 10.18.4

I doubt it’s something to do with Ethers to be honest. Maybe metamask changed something due to the merge coming up?

Code Snippet

let p = new ethers.providers.Web3Provider(window.ethereum)
let signer = p.getSigner()

let chain = await signer.getChainId()

Contract ABI

No response

Errors

Error: could not detect network (chainId="0x1", event="invalidNetwork", serverError={}, code=NETWORK_ERROR, version=providers/5.6.0)

Environment

Ethereum (mainnet/ropsten/rinkeby/goerli), Browser (Chrome, Safari, etc)

Environment (Other)

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ricmoocommented, Sep 15, 2022

I take that back. It does. Sorry, I misspoke. One sec. 😃

0reactions
Benjythebeecommented, Sep 15, 2022

I did it!

the package "@walletconnect/web3-provider" used for web3modal must have a bug in version ^1.7.9. I downgraded it to 1.7.8 and it worked fine. I’ll see if I can notify the team over there

Edit: version 1.7.9 does not exist, I’m so annoyed at NPM for not telling me

Read more comments on GitHub >

github_iconTop Results From Across the Web

could not detect network (event="noNetwork", code ... - GitHub
It works in a small node program but will not work in React Native. ... Hey @daihovey, the error could not detect network...
Read more >
Error: could not detect network (event="noNetwork", code ...
So, Ganache is not connected to different environment. Go to the Ganache and click on Settings, then go the server and choose WSL...
Read more >
Documentation - ethers
Returns a new Provider, backed by multiple services, connected to network. If no network is provided, homestead (i.e. mainnet) is used. The network...
Read more >
Ethereum Provider API - MetaMask Docs
Detect the Ethereum provider ( window.ethereum ); Detect which Ethereum network the user is connected to; Get the user's Ethereum account(s).
Read more >
Issues and Workarounds | Aptos Docs
Go to account 0x1 page on the Aptos Explorer by clicking here. Make sure the correct network (mainnet or testnet or devnet) is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found