🔷ENS

Learn how to use Airstack to universally resolve and reverse resolve ENS, Namestone, and cb.id to other web3 identities (Farcaster, Lens, 0x address, Solana address).

Airstack provides easy-to-use APIs for enriching ENS applications and for integrating on-chain ENS data and off-chain data from Namestone and cb.id.

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 from a given user(s)

You can get all the ENS names and offchain domains (Namestone & cb.id) of a given user, both primary and non-primary names, by providing either 0x addresses, Solana addresses, Farcaster or Lens profile:

Try Demo

Code

query GetENS {
  Domains(
    input: {
      filter: {
        owner: {
          _in: [
            "0x4b70d04124c2996de29e0caa050a49822faec6cc"
            "GJQUFnCu7ZJHxtxeaeskjnqyx8QFAN1PsiGuShDMPsqV"
            "lens/@stani"
            "fc_fname:vbuterin"
          ]
        }
      }
      blockchain: ethereum
    }
  ) {
    Domain {
      name
      isPrimary
      resolvedAddress
    }
  }
}

Get the 0x address, Lens, and Farcaster from a given ENS name(s)

You can get the 0x address, Lens, and Farcaster of ENS names:

Try Demo

Code

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

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
        }
      }
    }
  }
}

Get All The Solana addresses from a given ENS name

You can get the Solana addresses of ENS names by using the Domains API and checking through the registered multichainAddresses field that has symbol equal to SOL:

Try Demo

Code

query GetUserDetailsFromENS {
  Domains(
    input: {
      filter: { name: { _eq: "alexjcomeau.eth" } }
      blockchain: ethereum
    }
  ) {
    Domain {
      multiChainAddresses {
        address
        symbol
      }
    }
  }
}

Get All The Solana addresses from a given Namestone Subdomain or cb.id (Offchain)

You can get the 0x addresses of offchain domains (Namestone/cb.id) by using the Domains API:

Try Demo

Code

query MyQuery {
  Domains(
    input: { filter: { name: { _eq: "yosephks.cb.id" } }, blockchain: ethereum }
  ) {
    Domain {
      multiChainAddresses {
        address
        symbol
      }
    }
  }
}

Developer Support

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

More Resources

Last updated

Was this helpful?