Ethers.js: Strange error with ENS names

Created on 3 May 2019  路  6Comments  路  Source: ethers-io/ethers.js

Hi ! I just noticed a strange behaviour when querying with ENS names :

  • that doesn't exist
  • exist but have not any resolver
  • exist & have a resolver but doesn't have any address set

Ethers v4.0.27 on node
This will trigger the following error :

UnhandledPromiseRejectionWarning: Error: invalid argument 0: json: cannot unmarshal non-string into Go value of type common.Address
    at getResult (C:\Users\Campalo\CASCADE8\blockframes\node_modules\ethers\providers\json-rpc-provider.js:40:21)
    at exports.XMLHttpRequest.request.onreadystatechange (C:\Users\Campalo\CASCADE8\blockframes\node_modules\ethers\utils\web.js:111:30)
    at exports.XMLHttpRequest.dispatchEvent (C:\Users\Campalo\CASCADE8\blockframes\node_modules\xmlhttprequest\lib\XMLHttpRequest.js:591:25)
    at setState (C:\Users\Campalo\CASCADE8\blockframes\node_modules\xmlhttprequest\lib\XMLHttpRequest.js:610:14)
    at IncomingMessage.<anonymous> (C:\Users\Campalo\CASCADE8\blockframes\node_modules\xmlhttprequest\lib\XMLHttpRequest.js:447:13)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)

Expected behaviour :
return a more meaningful error, or in case of getBalance() simply 0x0

Minimal step to reproduce (on goerli) :

  • doesntexist.test doesn't exist
  • vitalik.test exist without any resolver
  • blockframes.test exist with a resolver but no address
ethers.getDefaultProvider('goerli').getBalance('vitalik.test');
bug fixed

All 6 comments

That鈥檚 odd. That looks more like the error when the internet is down (obviously since you can get the balance, that is not the case).

I鈥檒l look into this once I get to Starbucks.

yes ! for exemple the domain tokyo.blockframes.test is linked to an address that have some eth and ethers.getDefaultProvider('goerli').getBalance('tokyo.blockframes.test').then(console.log) works perfectly

I have verified this is a bug and will get it fixed soon.

This should be fixed in 4.0.28. Let me know if you still have any problems.

Thanks! :)

(oh, also getBalance still throws an error, just a more meaningful error, since getting the balance of a non-existent ENS name should still be an error. :))

Thanks for your work @ricmoo !!!

Was this page helpful?
0 / 5 - 0 ratings