đˇ ENSLearn how to use Airstack to universally resolve and reverse resolve ENS, Namestone, and cb.id to other web3 identities (Farcaster 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
Basic knowledge of GraphQL
Get Started
JavaScript/TypeScript/Python
If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:
npm yarn pnpm pip
React
Copy npm install @airstack/airstack-react
Node
Copy npm install @airstack/node
React
Copy yarn add @airstack/airstack-react
Node
Copy yarn add @airstack/node
React
Copy pnpm install @airstack/airstack-react
Node
Copy pnpm install @airstack/node
Then, add the following snippets to your code:
React Node Python
Copy 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 >;
}
};
Copy import { init , fetchQuery } from "@airstack/node" ;
init ( "YOUR_AIRSTACK_API_KEY" );
const query = `YOUR_QUERY` ; // Replace with GraphQL Query
const { data , error } = await fetchQuery (query);
console .log ( "data:" , data);
console .log ( "error:" , error);
Copy import asyncio
from airstack . execute_query import AirstackClient
api_client = AirstackClient (api_key = "YOUR_AIRSTACK_API_KEY" )
query = """YOUR_QUERY""" # Replace with GraphQL Query
async def main ():
execute_query_client = api_client . create_execute_query_object (
query = query)
query_response = await execute_query_client . execute_query ()
print (query_response.data)
asyncio . run ( main ())
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 Response
Copy query GetENS {
Domains(
input: {
filter : {
owner : {
_in : [
"0x4b70d04124c2996de29e0caa050a49822faec6cc"
"GJQUFnCu7ZJHxtxeaeskjnqyx8QFAN1PsiGuShDMPsqV"
"lens/@stani"
"fc_fname:vbuterin"
]
}
}
blockchain : ethereum
}
) {
Domain {
name
isPrimary
resolvedAddress
}
}
}
Copy {
"data" : {
"Domains" : {
"Domain" : [
{
"name" : "skynft.eth" ,
"isPrimary" : false ,
"resolvedAddress" : ""
} ,
{
"name" : "quantumexchange.eth" ,
"isPrimary" : false ,
"resolvedAddress" : "0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
} ,
{
"name" : "vitalik.daohall.eth" ,
"isPrimary" : false ,
"resolvedAddress" : ""
} ,
// Other ENS domains
}
]
}
}
}
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 Response
Copy query GetUserDetailsFromENS {
Domains(
input: { filter : { name : { _in : [ "vitalik.eth" ] } }, blockchain : ethereum }
) {
Domain {
resolvedAddress
resolvedAddressDetails {
socials {
profileName
dappName
}
}
}
}
}
Copy {
"data" : {
"Domains" : {
"Domain" : [
{
"resolvedAddress" : "0xd8da6bf26964af9d7eed9e03e53415d37aa96045" ,
"resolvedAddressDetails" : {
"socials" : [
{
"profileName" : "vitalik.eth" ,
"dappName" : "farcaster"
} ,
{
"profileName" : "lens/@vitalik" ,
"dappName" : "lens"
}
]
}
}
]
}
}
}
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 Response
Copy query GetCbDotID {
Domains(
input: {
filter : { name : { _in : [ "yosephks.cb.id" ] } }
blockchain : ethereum
}
) {
Domain {
resolvedAddress
resolvedAddressDetails {
socials {
profileName
dappName
}
}
}
}
}
Copy {
"data" : {
"Domains" : {
"Domain" : [
{
"resolvedAddress" : "0xc7486219881c780b676499868716b27095317416" ,
"resolvedAddressDetails" : {
"socials" : [
{
"profileName" : "lens/@yosephks" ,
"dappName" : "lens"
} ,
{
"profileName" : "yosephks.eth" ,
"dappName" : "farcaster"
}
]
}
}
]
}
}
}
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 Response
Copy query GetNamestone {
Domains(
input: {
filter : { name : { _in : [ "namestone.testbrand.eth" ] } }
blockchain : ethereum
}
) {
Domain {
resolvedAddress
resolvedAddressDetails {
socials {
profileName
dappName
}
}
}
}
}
Copy {
"data" : {
"Domains" : {
"Domain" : [
{
"resolvedAddress" : "0x57632ba9a844af0ab7d5cdf98b0056c8d87e3a85" ,
"resolvedAddressDetails" : {
"socials" : [
{
"profileName" : "heeroyuy" ,
"dappName" : "farcaster"
}
]
}
}
]
}
}
}
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 Response
Copy query GetUserDetailsFromENS {
Domains(
input: {
filter : { name : { _eq : "alexjcomeau.eth" } }
blockchain : ethereum
}
) {
Domain {
multiChainAddresses {
address
symbol
}
}
}
}
Copy {
"data" : {
"Domains" : {
"Domain" : [
{
"multiChainAddresses" : [
{
"address" : "0xe0235804378c31948E81441f656D826eE5998Bc6" ,
"symbol" : "ETH"
} ,
{
// This is the SOL address registered by user in ENS
"address" : "GJQUFnCu7ZJHxtxeaeskjnqyx8QFAN1PsiGuShDMPsqV" ,
"symbol" : "SOL"
}
]
}
]
}
}
}
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 Response
Copy query MyQuery {
Domains(
input: { filter : { name : { _eq : "yosephks.cb.id" } }, blockchain : ethereum }
) {
Domain {
multiChainAddresses {
address
symbol
}
}
}
}
Copy {
"data" : {
"Domains" : {
"Domain" : [
{
"multiChainAddresses" : [
{
"address" : "bc1qetgl5rx3uuhxek7erfc3wh97m3xkshx8pkdpr5" ,
"symbol" : "BTC"
} ,
{
"address" : "DETcngVSTXVbetWmRo9kdQe7xD9F19uqWk" ,
"symbol" : "DOGE"
} ,
{
"address" : "0xc7486219881C780B676499868716B27095317416" ,
"symbol" : "ETH"
} ,
{
"address" : "ltc1qwsqc8y09w59yqvlwy9c4fkqxu5md33vsr2uak6" ,
"symbol" : "LTC"
} ,
{
// This is the SOL address connected to yosephks.cb.id (offchain)
"address" : "HyrNmmmce9W3rDdTQcZHyYvhuxPN6AaY3mVJcS9f4AZw" ,
"symbol" : "SOL"
}
]
}
]
}
}
}
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 7 months ago