đ Resolve ENS DomainsLearn 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
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.
đ¤ 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 Response
Copy query GetENSNameStoneCBID {
Domains(
input: {
filter : {
resolvedAddress : {
_in : [
"0xc7486219881C780B676499868716B27095317416"
"lens/@yosephks"
"fc_fname:yosephks.eth"
]
}
}
blockchain : ethereum
}
) {
Domain {
name
}
}
}
Copy {
"data" : {
"Domains" : {
"Domain" : [
{
"name" : "yosephks.eth"
} ,
{
"name" : "yosephks.cb.id"
}
]
}
}
}
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 Response
Copy query MyQuery {
Domains(
input: {
filter : { name : { _in : [ "vitalik.eth" , "naderdabit.eth" ] } }
blockchain : ethereum
}
) {
Domain {
resolvedAddress
name
}
}
}
Copy {
"data" : {
"Domains" : {
"Domain" : [
{
"resolvedAddress" : "0xd8da6bf26964af9d7eed9e03e53415d37aa96045" ,
"name" : "vitalik.eth"
} ,
{
"resolvedAddress" : "0xb2ebc9b3a788afb1e942ed65b59e9e49a1ee500d" ,
"name" : "naderdabit.eth"
}
]
}
}
}
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 Response
Copy query GetWeb3SocialsOfLens {
Socials(
input: {
filter : { identity : { _in : [ "vitalik.eth" ] } }
blockchain : ethereum
}
) {
Social {
dappName
profileName
profileTokenId
profileTokenIdHex
userId
userAssociatedAddresses
}
}
}
Copy {
"data" : {
"Socials" : {
"Social" : [
{
"dappName" : "farcaster" ,
"profileName" : "vitalik.eth" ,
"profileTokenId" : "53546877787533711135172528420529478392632952428887988304966222706809455509504" ,
"profileTokenIdHex" : "0x0766275746572696e000000000000000000000000000000000000000000000000" ,
"userId" : "5650" ,
"userAssociatedAddresses" : [
"0xadd746be46ff36f10c81d6e3ba282537f4c68077" ,
"0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
]
} ,
{
"dappName" : "lens" ,
"profileName" : "lens/@vitalik" ,
"profileTokenId" : "100275" ,
"profileTokenIdHex" : "0x0187b3" ,
"userId" : "0xd8da6bf26964af9d7eed9e03e53415d37aa96045" ,
"userAssociatedAddresses" : [
"0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
]
}
]
}
}
}
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 Response
Copy query GetLensOfFarcasters {
XMTPs(
input: { blockchain : ALL, filter : { owner : { _in : [ "vitalik.eth" ] } } }
) {
XMTP {
isXMTPEnabled
owner {
domains {
name
}
}
}
}
}
Copy {
"data" : {
"XMTPs" : {
"XMTP" : [
{
"isXMTPEnabled" : true , // XMTP is enabled for vitalik.eth
"owner" : {
"domains" : [
{
"name" : "vitalik.eth"
} ,
// Other ENS domain
]
}
}
]
}
}
}
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"
}
]
}
}
]
}
}
}
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