Greetings again. In preparing a backgrounder for ENS, I realized that the information I’ve gotten from the ENS subgraph is a bit confounding. Full admission: I could be missing something obvious that was just left out of the documentation.
Where does the “name” information come from? If only the namehash and labelhash are kept in Ethereum, how do the pre-hash names appear in the subgraph?
Probably unrelated: where does the list of text records for a name come from? The API only lets you ask for a given text record name.
Only the namehash and labelhash are stored on-chain, the original, human-readable ENS names are reconstructed in user interfaces by reverse-resolving the namehash or by storing a mapping of namehashes to their corresponding names off-chain.
The Graph ingests events emitted by the ENS smart contracts. These events may include the original ENS names when domains are registered or transferred, and the subgraph can index these names along with their respective hashes. This way, the subgraph can provide the pre-hash names when queried, even though these names are not directly stored on the Ethereum blockchain.
We have a large database of preimages accessible in the subgraph. Aside from that, registration and renewal events for .eth 2LDs log the plaintext name, which the subgraph picks up.
To get the values, you should query the resolver; resolvers can be dynamic, so you should never rely on the subgraph to resolve values. This applies to address records too!
For “name”, that makes sense. I didn’t realize that the logs were recorded into the subgraph. For “texts”, I know not to rely on the subgraph, but I still wonder where that data comes from, given that it is information in the resolvers.
Thanks for the pointers into the ENS subgraph code! I think your #1 is different than Nick’s above, but both make sense. Your #2 seems is fascinating, given the incredible variety of DNS names that people want, including those that don’t actually exist in the DNS (like the names with emojis in .art). Your #3 makes sense as well, and I now need to learn about wrapped names.
I’m still interested in my second question, the source of the text keys associated with a name.