đŸŸĒFarcaster

Learn how to use Airstack to universally resolve and reverse resolve Farcaster name or ID to other web3 identities (ENS, Ethereum address, Solana address).

Airstack provides easy-to-use APIs for enriching Farcaster applications and for integrating on-chain (Optimism) and off-chain (Farcaster hubs) data from 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.

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 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 Accounts Of ENS Domain(s)

You can resolve ENS domain(s) to their Farcaster accounts by using Socials API:

Try Demo

Show Farcaster name of prxshant.eth

Code

query GetFarcaster {
  Socials(
    input: {
      filter: {
        identity: { _in: ["prxshant.eth"] }
        dappName: { _eq: farcaster }
      }
      blockchain: ethereum
    }
  ) {
    Social {
      profileName
      userId
      profileImage
    }
  }
}

Get the Ethereum addresses and ENS from a given Farcaster username(s)

Try Demo

Show the 0x addresses and ENS of fc_fname:vitalik.eth

Code

query GetFarcaster {
  Socials(
    input: {
      filter: {
        dappName: { _eq: farcaster }
        profileName: { _in: ["betashop.eth", "dwr.eth"] }
      }
      blockchain: ethereum
    }
  ) {
    Social {
      profileName
      userId
      profileImage
      userAssociatedAddresses
      userAssociatedAddressDetails {
        domains {
          name
          isPrimary
          resolvedAddress
        }
      }
    }
  }
}

Developer Support

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

More Resources

Last updated

Was this helpful?