Error: could not detect network chain '0x1'
See original GitHub issueEthers 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.
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:
- Created a year ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I take that back. It does. Sorry, I misspoke. One sec. 😃
I did it!
the package
"@walletconnect/web3-provider"
used for web3modal must have a bug in version ^1.7.9. I downgraded it to1.7.8
and it worked fine. I’ll see if I can notify the team over thereEdit: version 1.7.9 does not exist, I’m so annoyed at NPM for not telling me