Replies: 3 comments
-
Using |
Beta Was this translation helpful? Give feedback.
-
Gotcha', but the issue is with using |
Beta Was this translation helpful? Give feedback.
-
I think the error may be somewhere else in your code? I just tried this example and it works fine. Keep in mind your code above won't do anything; connect does not change the current provider, as a Signer is immutable. It returns a new instance of the Wallet, so you likely want |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Ethers Version
5.6
Search Terms
No response
Describe the Problem
Hello! When a wallet is constructed with a private key, 'connect' throws an error.
This is likely due to hasMnemonic returning true even though the mnemonic is not explicitly set when the wallet is constructed from a private key (appears to default to "not set"). My workaround changes the connect method body to:
This should work, as the wallet private key is always available (we only need to validate it). However, there may be some properties from the wallet object that you want to retain when connecting to a provider.
If you have any questions, please let me know.
Code Snippet
Contract ABI
No response
Errors
Environment
node.js (v12 or newer)
Environment (Other)
No response
Beta Was this translation helpful? Give feedback.
All reactions