Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when switching network/account on metamask (example code) #127

Closed
LRUki opened this issue Oct 3, 2020 · 2 comments
Closed

Error when switching network/account on metamask (example code) #127

LRUki opened this issue Oct 3, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@LRUki
Copy link

LRUki commented Oct 3, 2020

Bug Description
I get "Error: underlying network changed" after switching account or network on the example code.

Reproduction
CodeSandbox reproduction

Steps to reproduce:

  1. press inject to connect to metamask
  2. switch network/account on metamsk

Expected Behavior
update the network/account info without throwing an error

Additional Context

@LRUki LRUki added the bug Something isn't working label Oct 3, 2020
@LRUki LRUki closed this as completed Oct 6, 2020
@LRUki LRUki reopened this Oct 10, 2020
@xiphiness
Copy link

also getting this, looking for a fix. error is happening in ethers BaseProvider.getTransactionCount, not sure where it's called, not the most useful stack trace

@TBouder
Copy link

TBouder commented Mar 30, 2021

I cannot access the CodeSandbox reproduction, but I had the same issue with ethersjs. This issue could help you.

The workaround with ethers.js is the following code, when using new ethers.providers.Web3Provider

const getLibrary = (provider, connector) => {
	return new ethers.providers.Web3Provider(provider, 'any')
};

instead of

const getLibrary = (provider, connector) => {
	return new ethers.providers.Web3Provider(provider)
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants