question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid ENS name error when a signer is used instead of an address

See original GitHub issue

Hey @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.stringifyd 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:closed
  • Created 3 years ago
  • Reactions:10
  • Comments:26 (7 by maintainers)

github_iconTop GitHub Comments

51reactions
Legogriscommented, Feb 12, 2021

Example problematic code:

const C = await ethers.getContractFactory("Contract");
const [owner, addr1, ...addrs] = await ethers.getSigners();
const c = await Contract.deploy(owner);

Yields confusing error:

 Error: invalid ENS name (argument="name", value="<SignerWithAddress 0x10957970C51812dc3A010C7d01b70e0d17dc79A8>", code=INVALID_ARGUMENT, version=providers/5.0.22)

Fix:

const c = await Contract.deploy(owner.address);

I guess extra confusing for typescript users, as the types are happy with it, only breaks at runtime.

4reactions
ricmoocommented, Mar 18, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found