🆔Resolve ENS Domains

Learn how to resolve ENS and Offchain Domains (Namestone & cb.id) to 0x address, Farcaster, and Reverse Resolution.

Table Of Contents

In this guide, you will learn how to use Airstack to:

Pre-requisites

  • An Airstack account

  • Basic knowledge of GraphQL

Get Started

JavaScript/TypeScript/Python

If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:

React

npm install @airstack/airstack-react

Node

npm install @airstack/node

Then, add the following snippets to your code:

import { init, useQuery } from "@airstack/airstack-react";

init("YOUR_AIRSTACK_API_KEY");

const query = `YOUR_QUERY`; // Replace with GraphQL Query

const Component = () => {
  const { data, loading, error } = useQuery(query);

  if (data) {
    return <p>Data: {JSON.stringify(data)}</p>;
  }

  if (loading) {
    return <p>Loading...</p>;
  }

  if (error) {
    return <p>Error: {error.message}</p>;
  }
};

Other Programming Languages

To access the Airstack APIs in other languages, you can use https://api.airstack.xyz/gql as your GraphQL endpoint.

Get ENS and Offchain Domains (Namestone & cb.id) of user(s)

You can fetch the ENS and offchain domains (Namestone & cb.id) of user(s) by using the Domains API and providing either the 0x address, Lens, or Farcaster to resolvedAddress:

Try Demo

Show me the ENS and offchain domains (Namestone & cb.id) of users

Code

query GetENSNameStoneCBID {
  Domains(
    input: {
      filter: {
        resolvedAddress: {
          _in: [
            "0xc7486219881C780B676499868716B27095317416"
            "lens/@yosephks"
            "fc_fname:yosephks.eth"
          ]
        }
      }
      blockchain: ethereum
    }
  ) {
    Domain {
      name
    }
  }
}

Get All 0x addresses of ENS Domain(s)

You can resolve an array of ENS domain(s) to their 0x addresses:

Try Demo

Show 0x addresses of vitalik.eth and naderdabit.eth

Code

query MyQuery {
  Domains(
    input: {
      filter: { name: { _in: ["vitalik.eth", "naderdabit.eth"] } }
      blockchain: ethereum
    }
  ) {
    Domain {
      resolvedAddress
      name
    }
  }
}

Get All Farcaster accounts owned by ENS

You can resolve any ENS to their Farcaster accounts, which comprise of Farcaster:

Try Demo

Show Farcaster accounts owned by vitalik.eth

Code

query GetWeb3SocialsOfLens {
  Socials(
    input: {
      filter: {
        identity: { _in: ["vitalik.eth"] }
        dappName: { _eq: farcaster }
      }
      blockchain: ethereum
    }
  ) {
    Social {
      dappName
      profileName
      profileTokenId
      profileTokenIdHex
      userId
      userAssociatedAddresses
    }
  }
}

Get the 0x address and Farcaster from a given cb.id (Offchain)

You can get the 0x address and Farcaster of cb.ids:

Try Demo

Show me the 0x address, Lens, and Farcaster of yosephks.cb.id

Code

query GetCbDotID {
  Domains(
    input: {
      filter: { name: { _in: ["yosephks.cb.id"] } }
      blockchain: ethereum
    }
  ) {
    Domain {
      resolvedAddress
      resolvedAddressDetails {
        socials {
          profileName
          dappName
        }
      }
    }
  }
}

Get the 0x address and Farcaster from a given Namestone Subdomain (Offchain)

You can get the 0x address and Farcaster of Namestone subdomains:

Try Demo

Show me the 0x address, Lens, and Farcaster of namestone.testbrand.eth

Code

query GetNamestone {
  Domains(
    input: {
      filter: { name: { _in: ["namestone.testbrand.eth"] } }
      blockchain: ethereum
    }
  ) {
    Domain {
      resolvedAddress
      resolvedAddressDetails {
        socials {
          profileName
          dappName
        }
      }
    }
  }
}

Developer Support

If you have any questions or need help regarding resolving identities for ENS domain(s), please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?