πŸ†”Resolve ENS Domains

Learn how to resolve ENS and Offchain Domains (Namestone & cb.id) to 0x address, Lens, Farcaster, and XMTP 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.

πŸ€– AI Natural Language​

Airstack provides an AI solution for you to build GraphQL queries to fulfill your use case easily. You can find the AI prompt of each query in the demo's caption or title for yourself to try.

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

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

Code

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

Get All Web3 Social Accounts (Lens, Farcaster) owned by ENS

You can resolve any ENS to their web3 socials, which comprise of Lens and Farcaster:

Try Demo

Code

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

Check If XMTP is Enabled for ENS Domain(s)

You can check if an array of ENS domain(s) have their XMTP enabled or not:

Try Demo

Code

query GetLensOfFarcasters {
  XMTPs(
    input: { blockchain: ALL, filter: { owner: { _in: ["vitalik.eth"] } } }
  ) {
    XMTP {
      isXMTPEnabled
      owner {
        domains {
          name
        }
      }
    }
  }
}

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

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

Try Demo

Code

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

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

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

Try Demo

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?