🆔Resolve Farcaster Users

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

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

  • Basic knowledge of GraphQL

Get Started

JavaScript/TypeScript/Python

If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:

React

npm install @airstack/airstack-react

Node

npm install @airstack/node

Then, add the following snippets to your code:

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>;
  }
};

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

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

Try Demo

Show 0x addresses of Farcaster user name dwr.eth and user ID 1

Code

query GetAddressesOfFarcasters {
  Socials(
    input: {
      filter: { identity: { _in: ["fc_fname:dwr.eth", "fc_fid:1"] } }
      blockchain: ethereum
    }
  ) {
    Social {
      userAssociatedAddresses
    }
  }
}

Get All Solana addresses of Farcaster user

You can resolve a Farcaster user to their Solana addresses by using Socials API:

Try Demo

Show me the Solana connected address of Farcaster user v

Code

query MyQuery {
  Socials(
    input: {
      filter: { dappName: { _eq: farcaster }, profileName: { _eq: "v" } }
      blockchain: ethereum
    }
  ) {
    Social {
      connectedAddresses {
        address
        blockchain
        chainId
        timestamp
      }
    }
  }
}

Get Farcaster profiles of a given Solana address

You can resolve Solana address to get all the Farcaster profiles owned by the given Solana address by using the Socials API:

Try Demo

Show me the Farcaster profile of solana address 9t92xZy9q5SyfKBH4rZwEDFXjaZKgzj5PgviPhKtBjyy

Code

query MyQuery {
  Socials(
    input: {
      filter: {
        identity: { _eq: "9t92xZy9q5SyfKBH4rZwEDFXjaZKgzj5PgviPhKtBjyy" }
        dappName: { _eq: farcaster }
      }
      blockchain: ethereum
    }
  ) {
    Social {
      profileName
      fid: userId
      userAssociatedAddresses
    }
  }
}

Get all ENS domains owned by Farcaster user(s)

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

Try Demo

Show all ENS domains owned by Farcaster user name dwr.eth and user id 1

Code

query GetENSOfFarcasters {
  Domains(
    input: {
      filter: { owner: { _in: ["fc_fname:dwr.eth", "fc_fid:1"] } }
      blockchain: ethereum
    }
  ) {
    Domain {
      name
    }
  }
}

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

Show web3 social accounts (Farcaster, Lens) owned by dwr.eth and 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045

Code

query GetWeb3SocialsOfFarcasters {
  Socials(
    input: {
      filter: {
        identity: {
          _in: ["dwr.eth", "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"]
        }
      }
      blockchain: ethereum
    }
  ) {
    Social {
      dappName
      profileName
    }
  }
}

Get Lens Profile of Farcaster user(s)

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

Try Demo

Show Lens profiles owned by Farcaster user name dwr.eth and user id 5650

Code

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

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

Code

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
        }
      }
    }
  }
}

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

Last updated

Was this helpful?