0

I would like to determine all of the active ENS domains and their subdomains, from ".eth" on down.

I've read over the ENS spec and searched the web, but I haven't found a way to do it.

So I suspect that either it's not possible, or else really hard?

Also, so far I've been using go-ethereum and github.com/wealdtech/go-ens in trying to do this work.

Thanks for any ideas. Robert

0

Well I'm super late to this, but since no one ever responded I'll give it a shot! (FYI, the answer is "really hard")

The thing to realize about ENS is that domains aren't actually stored in plaintext but as hashes (the function they use is namehash). Read this: https://www.npmjs.com/package/eth-ens-namehash

So in order to do this, you would need to:

  1. Look at the ENS smart contract to determine all the addresses that have a domain.
  2. Retrieve the hash that these addresses have registered
  3. Determine what possible human-readable name could have resulted in this hash

3 is the part that will surely mess you up, because you basically have no other way to do it other than pre-computing hashes of known values and looking for a hit among all known eth addresses. (brute force)

However, this is SOMEWHAT doable because of a couple of contraints:

  1. The number of registered domains IS PUBLIC at all times (thanks blockchain!), so you will always know both the number of addresses and how many of them you have decoded into human-readable.
  2. The number of registered domains is still relatively small (40kish), so brute force isn't completely out of the realm of possibility
  3. It isn't practical to register an .eth longer than the address that registered it... so at least you can set an upper bound on your dictionary that should cover 99% of registration cases.
0

Assuming that every new domain is created with the setSubnodeRecord() function of the ENSRegistry contract (which I believe is the case) then one approach is to use the NewOwner(bytes32 indexed node, bytes32 indexed label, address owner) logs. By querying all the NewOwner logs which have a given node parameter, you can obtain all of the sub-nodes of that node. By repeatedly applying this approach, you can obtain the entire tree of nodes from some root node (e.g. .eth)

ENS contract code source: https://github.com/ensdomains/ens/blob/ff0f41747c05f1598973b0fe7ad0d9e09565dfcd/contracts/ENSRegistry.sol#L53

New contributor
John Henderson is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.