đŸ“ŦHas XMTP

Learn how to check if Farcaster name or ID has enabled XMTP and resolve Farcaster name or ID for XMTP messaging.

đŸ“Ŧ Has XMTP

Airstack provides easy-to-use APIs for enriching Farcaster applications and integrating on-chain and off-chain data with Farcaster.

XMTP is an Ethereum-based messaging protocol.

Developers building with XMTP can use Airstack to enable Farcaster users to seamlessly message Ethereum, ENS, Lens, and Farcaster users with XMTP-enabled addresses.

Airstack is utilized to:

  1. check if users have XMTP enabled (required in order to receive XMTP messages)

  2. resolve Farcaster usernames to 0x Ethereum addresses and vice versa.

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.

Check Farcaster Has XMTP Enabled

You can check if a Farcaster has XMTP enabled or not by providing either the Farcaster name or ID:

Try Demo

Code

query MyQuery {
  XMTPs(
    input: {
      blockchain: ALL
      filter: { owner: { _eq: "fc_fname:vitalik.eth" } }
    }
  ) {
    XMTP {
      isXMTPEnabled
    }
  }
}

Bulk Check Farcasters Have XMTP Enabled

You can bulk check a list of Farcasters have XMTP enabled or not:

Try Demo

Code

query MyQuery {
  XMTPs(
    input: {
      blockchain: ALL
      filter: { owner: { _in: ["fc_fname:betashop.eth", "fc_fid:5650"] } }
    }
  ) {
    XMTP {
      isXMTPEnabled
      owner {
        socials {
          dappName
          profileName
        }
      }
    }
  }
}

Get all 0x addresses of Farcaster user(s)

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

Try Demo

Code

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

Get all Farcasters owned by 0x address

You can resolve any 0x address to their Farcaster accounts:

Try Demo

Code

query GetFarcastersOfEthereumAddress {
  Socials(
    input: {
      filter: {
        identity: { _in: ["0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"] }
        dappName: { _eq: farcaster }
      }
      blockchain: ethereum
    }
  ) {
    Social {
      profileName
      userId
      userAssociatedAddresses
    }
  }
}

Get Farcaster Followers of Farcaster User(s) that has XMTP Enabled

You can get the list of Farcaster followers of Farcaster user(s) and check if each followers have XMTP enabled or not by inputting , ENS domain, , or Farcaster ID:

Try Demo

Code

query MyQuery {
  SocialFollowers(
    input: {
      filter: {
        dappName: { _eq: farcaster }
        identity: {
          _in: [
            "fc_fname:dwr.eth"
            "fc_fid:602"
            "varunsrin.eth"
            "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
          ]
        }
      }
      blockchain: ALL
      limit: 200
    }
  ) {
    Follower {
      followerAddress {
        addresses
        socials(input: { filter: { dappName: { _eq: farcaster } } }) {
          profileName
          userId
          userAssociatedAddresses
        }
        xmtp {
          isXMTPEnabled
        }
      }
      followerProfileId
      followerTokenId
      followingAddress {
        addresses
        domains {
          name
        }
        socials(input: { filter: { dappName: { _eq: farcaster } } }) {
          profileName
          userId
          userAssociatedAddresses
        }
      }
      followingProfileId
    }
  }
}

Get Farcaster Followings of Farcaster User(s) that has XMTP Enabled

You can get the list of Farcaster following of Farcaster user(s) and check if each following have XMTP enabled or not by inputting , ENS domain, , or Farcaster ID:

Try Demo

Code

query MyQuery {
  SocialFollowings(
    input: {
      filter: {
        dappName: { _eq: farcaster }
        identity: {
          _in: [
            "fc_fname:dwr.eth"
            "fc_fid:602"
            "varunsrin.eth"
            "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
          ]
        }
      }
      blockchain: ALL
      limit: 200
    }
  ) {
    Following {
      followingAddress {
        addresses
        socials(input: { filter: { dappName: { _eq: farcaster } } }) {
          profileName
          userId
          userAssociatedAddresses
        }
        xmtp {
          isXMTPEnabled
        }
      }
      followerProfileId
      followerAddress {
        addresses
        domains {
          name
        }
        socials(input: { filter: { dappName: { _eq: farcaster } } }) {
          profileName
          userId
          userAssociatedAddresses
        }
      }
      followerProfileId
    }
  }
}

Developer Support

If you have any questions or need help regarding checking if Farcaster(s) have XMTP enabled, please join our Airstack's Telegram group.

More Resources

  1. e.g. varunsrin.eth

  2. e.g. fc_fid:602

Last updated

Was this helpful?