Links
Comment on page
🔷

ENS

Learn how to use Airstack to universally resolve and reverse resolve ENS to other web3 identities (Farcaster, Lens, 0x address).
Airstack provides easy-to-use APIs for enriching ENS applications and for integrating on-chain and off-chain data from ENS.

Table Of Contents

In this guide you will learn how to use Airstack to:

Pre-requisites

  • An Airstack account (free)
  • 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
npm install @airstack/airstack-react
Node
npm install @airstack/node
React
yarn add @airstack/airstack-react
Node
yarn add @airstack/node
React
pnpm install @airstack/airstack-react
Node
pnpm install @airstack/node
pip install airstack
Then, add the following snippets to your code:
React
Node
Python
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>;
}
};
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);
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.
Airstack AI (Demo)

Get ENS from a given user(s)

You can get all the ENS names of a given user, both primary and non-primary names, by providing either 0x addresses, Lens profile, or Farcaster:

Try Demo

https://app.airstack.xyz/query/SkTlH3Lh3I
Show me the ENS of 0x4b70d04124c2996de29e0caa050a49822faec6cc, lens/@stani, fc_fname:vbuterin

Code

Query
Response
query GetENS {
Domains(
input: {
filter: {
owner: {
_in: [
"0x4b70d04124c2996de29e0caa050a49822faec6cc"
"lens/@stani"
"fc_fname:vbuterin"
]
}
}
blockchain: ethereum
}
) {
Domain {
dappName
name
}
}
}
{
"data": {
"Domains": {
"Domain": [
{
"dappName": "ens",
"name": "skynft.eth"
},
{
"dappName": "ens",
"name": "quantumexchange.eth"
},
{
"dappName": "ens",
"name": "vitalik.daohall.eth"
},
{
"dappName": "ens",
"name": "brianshaw.eth"
},
{
"dappName": "ens",
"name": "vbuterin.eth"
},
{
"dappName": "ens",
"name": "klock.eth"
},
{
"dappName": "ens",
"name": "quantumsmartcontracts.eth"
},
{
"dappName": "ens",
"name": "legendgames.eth"
},
{
"dappName": "ens",
"name": "vitalik.ethid.eth"
},
{
"dappName": "ens",
"name": "elddem.eth"
}
]
}
}
}

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

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

Try Demo

https://app.airstack.xyz/query/dHXYUnz0Uo
Show me the 0x address, Lens, Farcaster of vitalik.eth

Code

Query
Response
query GetUserDetailsFromENS {
Socials(
input: {
filter: { identity: { _in: ["vitalik.eth"] } }
blockchain: ethereum
}
) {
Social {
userAddress
dappName
profileName
}
}
}
{
"data": {
"Socials": {
"Social": [
{
"userAddress": "0xadd746be46ff36f10c81d6e3ba282537f4c68077",
"dappName": "farcaster",
"profileName": "vitalik.eth"
},
{
"userAddress": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
"dappName": "lens",
"profileName": "lens/@vitalik"
}
]
}
}
}

Developer Support

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

More Resources