Onchain Data đˇ ENS Domainsđ Resolve ENS DomainsLearn 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
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 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 Farcaster accounts owned by ENS
You can resolve any ENS to their Farcaster accounts, which comprise of Farcaster:
Try Demo
Code
Query Response
Copy query GetWeb3SocialsOfLens {
Socials(
input: {
filter : {
identity : { _in : [ "vitalik.eth" ] }
dappName : { _eq : farcaster }
}
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"
]
}
]
}
}
}
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
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" : "yosephks.eth" ,
"dappName" : "farcaster"
}
]
}
}
]
}
}
}
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
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
Last updated 4 months ago