Initializing EthereumProvider throws an error #3130
-
Hello, I am currently trying to utilize walletconnect with an ethersJS project. I created a walletconnect account to use the project id instead of the infura id like in previous versions of walletconnect. I have found while trying to use the V2 version of Web3Modal that it's not possible and EthereumProvider should instead be used with ethers. I am currently unable to initialize the provider without throwing an error:
This gives me the error: |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 41 replies
-
Could you help us out with which version of EthereumProvider and ethers you're using? |
Beta Was this translation helpful? Give feedback.
-
We also had similar problems with those versions and had to revert to earlier versions. |
Beta Was this translation helpful? Give feedback.
-
@Slula @grahac could you take a look at this codesandbox and see if the implementation differs in any way? We tried to use the same versions and are not facing this issue |
Beta Was this translation helpful? Give feedback.
-
We switched to Wagmi and everything is much much better. |
Beta Was this translation helpful? Give feedback.
-
Hi - just adding to this. We found that the latest (2.9.0/ 2.6.0) of EthereumProvider produces this error. When we go back to 2.8.4 it works. |
Beta Was this translation helpful? Give feedback.
-
Oh and I think I found the solution (forgot!) You now NEED events parameter (and I think optionalChains field too)
apologies about formatting. Github interface is acting funky for me rn. |
Beta Was this translation helpful? Give feedback.
-
Could you provide a minimal reproducible example of the issue? |
Beta Was this translation helpful? Give feedback.
-
<script src="https://cdn.ethers.io/lib/ethers-5.4.umd.min.js"></script>
<title>Document</title>
Connect Wallet
|
Beta Was this translation helpful? Give feedback.
-
More info on this: For some reason our local storage got corrupted and a bunch of values were set to null. I blew away the local storage and it worked. Not sure how to reproduce but the next time I do I will post here. My best guess is log in first with 2.8.4 and then with 2.90 but I have not tried it yet. |
Beta Was this translation helpful? Give feedback.
-
Note: I was able to reproduce the null error. I was toggling between the 2.8.3 and 2.9 versions of WC Ethereum Provider and logging in with each. I may or may not have done npm install in between but I did get into a state where my local storage showed the following.
Hopefully this helps the team! Dunno if this is a big issue or not. |
Beta Was this translation helpful? Give feedback.
-
I have confirmed if I call client.disconnect on our system it will get into a null universal_provider state where you need to delete your local storage. |
Beta Was this translation helpful? Give feedback.
thanks @Slula, you need to move the init function inside the useEffect hook, this worked for me: