How to get parentname from parent node?

Hey guys,

I am building an app which allows users to buy subdomains to certain domains which I own. I have deployed my registrar on TheGraph, and when I query names, I get the parentNode back in hashform.

I’d like to map through all the data I receive from my subgraph and display it on my website accordingly and don’t want to manually hardcode every name. How can I get the parentName from the parentNode? If I can’t do this, it would be great if someone could suggest the best way to go about this.

This is the code I’m currently using and I get reverse resolution failed (which I assume is because I’m trying to resolve the namehash instead of an address).

import { ENS } from '@ensdomains/ensjs';

const App = () => {

    const ens = new ENS(provider, '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e');
    const parentNodeGoerli = '0x51c37eb0642df9b997e6d1e70e0a836348cec092cf1f1f81772e45dc169edcad'

    async function reverseLookup(namehash) {
        try {
          const address = await ens.getOwner(namehash);
          const reverseName = `${address.toLowerCase()}.addr.reverse`;
          const reverseNamehash = ens.namehash(reverseName);
          const resolver = await ens.getResolver(reverseNamehash);
          const reverseDomain = await;
          return reverseDomain;
        } catch (error) {
          console.error("Error in reverse lookup:", error);
          return null;

useEffect(() => {
        reverseLookup(parentNodeGoerli).then((domain) => {
            if (domain) {
              console.log("Reverse resolved domain:", domain);
            } else {
              console.log("Reverse resolution failed");
    }, [ ])


1 Like

What line is your code failing at, and what error are you getting?

Keccak-256 is a one way hash function so you can’t get a plaintext domain from its namehash. You’ll need to set up a rainbow table or use a service such as the graph.

1 Like

It’s failing here ^^.

What’s a rainbow table? Or how would I use TheGraph (I’m already using it but not getting the readable name)?

1 Like