Links
Comment on page
🆔

Resolve Farcaster Users

Learn how to resolve Farcaster(s) fname/username/FID to 0x address, ENS, Lens, and XMTP and Reverse Resolution.

🆔 Resolve Farcaster Users

Airstack provides easy-to-use APIs for enriching Farcaster applications and for integrating onchain and offchain data with Farcaster.

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 } = 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 All 0x addresses of Farcaster user(s)

You can resolve an array of Farcaster user(s) to their 0x addresses:

Try Demo

https://app.airstack.xyz/query/rQQVTG8laa
Show 0x addresses of Farcaster user name dwr.eth and user ID 1

Code

Query
Response
query GetAddressesOfFarcasters {
Socials(
input: {
filter: { identity: { _in: ["fc_fname:dwr.eth", "fc_fid:1"] } }
blockchain: ethereum
}
) {
Social {
userAssociatedAddresses
}
}
}
{
"data": {
"Socials": {
"Social": [
{
"userAssociatedAddresses": [
"0x8773442740c17c9d0f0b87022c722f9a136206ed",
"0x86924c37a93734e8611eb081238928a9d18a63c0"
]
},
{
"userAssociatedAddresses": [
"0xd7029bdea1c17493893aafe29aad69ef892b8ff2"
]
},
{
"userAssociatedAddresses": [
"0xb877f7bb52d28f06e60f557c00a56225124b357f",
"0xa14b4c95b5247199d74c5578531b4887ca5e4909",
"0xd7029bdea1c17493893aafe29aad69ef892b8ff2",
"0x74232bf61e994655592747e20bdf6fa9b9476f79"
]
}
]
}
}
}

Get all ENS domains owned by Farcaster user(s)

You can resolve an array of Farcaster user(s) to their ENS domains:

Try Demo

https://app.airstack.xyz/query/6TtsANTcnd
Show all ENS domains owned by Farcaster user name dwr.eth and user id 1

Code

Query
Response
query GetENSOfFarcasters {
Domains(
input: {
filter: { owner: { _in: ["fc_fname:dwr.eth", "fc_fid:1"] } }
blockchain: ethereum
}
) {
Domain {
name
}
}
}
{
"data": {
"Domains": {
"Domain": [
{
"name": "noun124.eth"
},
{
"name": "dwr.mirror.xyz"
},
{
"name": "warpcast.eth"
},
{
"name": "danromero.eth"
}
]
}
}
}

Get All Web3 Social Accounts (Farcaster, Lens) owned by 0x address or ENS

You can resolve any 0x address or ENS to their web3 socials, which comprise of Farcaster and Lens:

Try Demo

https://app.airstack.xyz/query/FHYr4PHYwu
Show web3 social accounts (Farcaster, Lens) owned by dwr.eth and 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045

Code

Query
Response
query GetWeb3SocialsOfFarcasters {
Socials(
input: {
filter: {
identity: {
_in: ["dwr.eth", "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"]
}
}
blockchain: ethereum
}
) {
Social {
dappName
profileName
}
}
}
{
"data": {
"Socials": {
"Social": [
{
"dappName": "farcaster",
"profileName": "vbuterin"
},
{
"dappName": "lens",
"profileName": "lens/@vitalik"
},
{
"dappName": "lens",
"profileName": "lens/@danromero"
},
{
"dappName": "farcaster",
"profileName": "dwr.eth"
}
]
}
}
}

Get Lens Profile of Farcaster user(s)

You can resolve an array of Farcaster user(s) to their Lens profile, if any:

Try Demo

https://app.airstack.xyz/query/7IYVTJBsZi
Show Lens profiles owned by Farcaster user name dwr.eth and user id 5650

Code

Query
Response
query GetLensOfFarcasters {
Socials(
input: {
filter: {
identity: { _in: ["fc_fname:dwr.eth", "fc_fid:5650"] }
dappName: { _eq: lens }
}
blockchain: ethereum
}
) {
Social {
dappName
profileName
}
}
}
{
"data": {
"Socials": {
"Social": [
{
"dappName": "lens",
"profileName": "lens/@vitalik"
},
{
"dappName": "lens",
"profileName": "lens/@danromero"
}
]
}
}
}

Check If XMTP is Enabled for Farcaster user(s)

You can check if an array of Farcaster user(s) have their XMTP enabled or not:

Try Demo

https://app.airstack.xyz/query/KHPF47JvdY
Show if XMTP is enabled for Farcaster user name varunsrin.eth and user id 5650

Code

Query
Response
query GetXMTPOfFarcasters {
XMTPs(
input: {
blockchain: ALL
filter: { owner: { _in: ["fc_fname:varunsrin.eth", "fc_fid:5650"] } }
}
) {
XMTP {
isXMTPEnabled
owner {
socials(input: { filter: { dappName: { _eq: farcaster } } }) {
profileName
}
}
}
}
}
{
"data": {
"XMTPs": {
"XMTP": [
{
"isXMTPEnabled": true,
"owner": {
"socials": [
{
"profileName": "vbuterin"
}
]
}
},
{
"isXMTPEnabled": true,
"owner": {
"socials": [
{
"profileName": "varunsrin.eth"
}
]
}
}
]
}
}
}

Developer Support

If you have any questions or need help regarding resolving identities for Farcaster user(s), please join our Airstack's Telegram group.

More Resources