Where does the information in the ENS subgraph come from?

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.

  1. 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?

  2. 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.

1 Like

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.

1 Like

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!

1 Like

The best way to understand how it’s index is to look into ENS subgraph repo


It’s done in three different ways.

  1. If the name is .eth name, it constructs from label of ControllerNameRegisteredEvent, ControllerNameRenewedEvent
  2. For subdomains and DNS names, decode from rainbow table. More info about the rainbow table is here
  3. If names are wrapped (most newly registered .eth names and their subnames since April 2023 are wrapped), then decode from NameWrapped event

Additionally I think app.ens.domains caches user’s search result locally on your browser.


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.

The resolvers also log events, which are picked up by the subgraph.

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.

My #1 and #2 are same as what Nick described. #3 was not mentioned by him, probably because it was added relatively recently.

It’s indexed using TextChangedEvent ens-subgraph/src/resolver.ts at master · ensdomains/ens-subgraph · GitHub

1 Like