Invalid ENS name error when a signer is used instead of an address
See original GitHub issueHey @ricmoo
I’m creating this issue cause I’ve seen lots of people confused about an ENS related error being thrown when a signer is used instead of an address. To make things worse, the signer gets JSON.stringify
d so the error is HUGE sometimes.
Have you consider treating this as a special case and throwing something like “hey, you should use an address instead of a signer”? Or maybe add a toJSON
to the abstract signer to at least avoid those huge errors?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:26 (7 by maintainers)
Top Results From Across the Web
Invalid address or ENS name - ethereum - Stack Overflow
The error means the address you are passing is not in the right format hence presenting as an INVALID_ARGUMENT. It needs to be...
Read more >Invalid ENS name when running hardhat test
So you most likely need to use that address field. Furthermore, the connect function requires the signer, not the address.
Read more >Ethers.js approve 'invalid address or ENS name' - Reddit
Hi Everyone, Trying to swap exact tokens for tokens using ethers.js - for some reason, I can't get it to work past the...
Read more >Resolving Names - ENS Documentation
Resolving a name to an Ethereum address using a library is simple: ... prevent users from setting wrong token address, the library has...
Read more >ethers-io/Lobby - Gitter
getAddress() but it just throws an error if address is invalid (eg wrong ... I'm trying to use my local geth IPC node,...
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
Example problematic code:
Yields confusing error:
Fix:
I guess extra confusing for typescript users, as the types are happy with it, only breaks at runtime.
This has already been added to my local v6. You should actually generally call
.getAddress()
instead of.address
, since.address
is not part of the Signer API (most signers do not have synchronous access to their address).For v5, I can add a condition like that to the JavaScript side, but cannot change the signature to allow Signer and Contract since that would break any existing sub-classes.