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.
What do you mean send a valid address from your provider?
Can you provide a code snippet of what you are doing?
I put a public address as parameter to the function lookupAddress, it's suppose to return me a promise or null
imagine a async function...
const toAddress = 'a valide address';
let response = await this.provider.lookupAddress(toAddress);
The address comes from a valid wallet from a testnet so when i say a valid address from my provider it's a valid address from the testnet.
Can you possibly send me the address you are using privately to [email protected]?
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.
Oh! Or are on a network that does not have ENS deployed? Like Rinkeby or Kovan?
Yes using Rinkeby and yes i can send you the address privately
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?
Alright thanks a lot for this quick support! i will test this and give you a feedback soon enough! Would be great to handle the error if it's not too much to ask haha! 馃憤
Thanks! Yes, if you find a canonical deployment of ENS. Last I asked, there wasn't one.
I Tried the fixes but got this error.
TypeError: Cannot read property 'substring' of null
at /{PROJECT_PATH}/node_modules/ethers-providers/provider.js:874:20
i am using typescript by the way but i don't think it matter for this case.
What fixes did you try? Deploying ENS?
i did this.
let network = ethers.providers.networks.rinkeby
network.ensAddress = 'my ens address'
then after in an object
provider : new ethers.providers.JsonRpcProvider('ipadress blabla', network)
other stuff that need the provider works, just the lookupAddress is failing.
if you do provider.getCode(yourEnsAddress).then(function(code) { console.log(code); }) does the ENS code show up? Maybe it failed to deploy? Were you able to register your name against it?
will try this right now.
Receiving Hexadecimal value: 0x , which means 0... weird stuff
Yeah, so your attempt to deploy ENS failed. ENS is actually quite a bit of work to set up... You will likely want to set up a test registrar too, and configure it as the .eth registrar. You will also want to deploy the reverse registrar, which lookupAddress also requires.
It is a lot of work to set up. Maybe poke around and hope someone else already has?
Alright thanks will try to figure this out, but it do not explain the substring of null, it means somewhere in the lib a null possibility is not managed in ethers-providers/provider.js:874:20
here is what i tried by the way.
this.provider.getCode('0xe7410170f87102df0055eb195163a03b7f2bff4a').then(function (code) { console.log('here is the code:', code) })
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.
Sorry just added the line of code haha, and all good man you already making good work i really appreciate your help :)
Better error messages will help though. :)
Yeah i totally agree but i only have this output.
TypeError: Cannot read property 'substring' of null
at /{Project_Folder}/node_modules/ethers-providers/provider.js:874:20
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
It would also be a good idea for the lookupAddress and resolveName to throw an error on networks with no ENS deployed.
Yeah i totally agree would be great for people that are or will be in my situation :)
Added in https://github.com/ethers-io/ethers.js/commit/d6cf970ae9a52990cc7774605a1358b8ad4940c6.
Once Travis CI has completed the regression tests I will publish to npm.
nice! :)
This should be available in the latest version on npm. Thanks! :)