ethers.js: Discussion: Throw errors when using ENS on networks without ENS.

The promise return me this when i send a valid address from my provider.

TypeError: Cannot read property 'toLowerCase' of null
    at Object.namehash ({PROJECT_PATH}/node_modules/ethers-utils/namehash.js:12:16)

From the error it seems to be from your ethers-utils.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 25 (13 by maintainers)

Most upvoted comments

Added in https://github.com/ethers-io/ethers.js/commit/d6cf970ae9a52990cc7774605a1358b8ad4940c6.

Once Travis CI has completed the regression tests I will publish to npm.

Better error messages will help though. 😃

Well, substring is used quite a bit in that function. I have a task to add more detailed errors, but my guess is the code not being deployed means that the result of the call to lookup the reverse registrar returns null, which is expected to be a string. I plan to also make call reject an error if the result is ‘0x’, since that means the call insipidity performed throw of some sort.

Oh, that is your problem. There is no ENS deployed to Rinkeby (at least not a canonical one I know of).

So, you cannot lookup address names on this network. The problem is that lookupAddress queries ENS to lookup the address’ name; if there is no ENS, it can’t query it. 😃

If you have deployed your own instance of ENS to Rinkeby, you can specify it when creating your provider:

var network = providers.networks.rinkeby;
network.ensAddress = 'YOUR ENS DEPLOYMENT ADDRESS HERE';
var provider = providers.getDefaultProvider(network);

Make sense?

Can you possibly send me the address you are using privately to support@ethers.io?

I’ve just tried the following:

> provider.lookupAddress('0x18C6045651826824FEBBD39d8560584078d1b247').then(function(name) { console.log(name); });
null

> provider.lookupAddress('0x6fC21092DA55B392b045eD78F4732bff3C580e2c').then(function(name) { console.log(name); });
registrar.firefly.eth

Which seems to work fine for both address which do and do not have reverse records. I would like to try debugging the address you are using, since it should not be passing any valid address to the name hash function. It may be the result from the lookup having high-order bits set.