đŸ“ŦHas XMTP

Learn how to check if Lens profiles have XMTP enabled on their account or not.

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

XMTP is an Ethereum-based messaging protocol.

Developers building with XMTP can use Airstack to enable Lens 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 Lens profile names or IDs to 0x Ethereum addresses and vice versa.

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:

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 (loading) {
    return <p>Loading...</p>;
  }

  if (error) {
    return <p>Error: {error.message}</p>;
  }

  // Render your component using the data returned by the query
};

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 Lens Profile Has XMTP Enabled

You can check if a Lens profile has XMTP enabled or not:

Try Demo

Code

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

Bulk Check Lens Profiles Have XMTP Enabled

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

Try Demo

Code

query BulkFetchLensProfilesHaveXMTP {
  XMTPs(input: {blockchain: ALL, filter: {owner: {_in: ["hoobastank.lens", "22776.lens", "barisadiguzel.lens"]}}, limit: 100}) {
    XMTP {
      isXMTPEnabled
      owner {
        socials {
          dappName
          profileName
        }
      }
    }
  }
}

Get All 0x addresses of Lens profile(s)

You can resolve an array of Lens profile(s) to their 0x addresses:

Try Demo

Code

query GetAddressesOfLens {
  Socials(
    input: {filter: {identity: {_in: ["nader.lens", "lens_id:100275"]}, dappName: {_eq: lens}}, blockchain: ethereum}
  ) {
    Social {
      profileName
      profileTokenId
      profileTokenIdHex
      userAssociatedAddresses
    }
  }
}

Get All Lens Profiles Owned by 0x address

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

Try Demo

Code

query GetLensOfEthereumAddress {
  Socials(
    input: {filter: {identity: {_in: ["0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"]}, dappName: {_eq: lens}}, blockchain: ethereum}
  ) {
    Social {
      profileName
      profileTokenId
      profileTokenIdHex
      userAssociatedAddresses
    }
  }
}

Developer Support

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

More Resources

Last updated

#300: add-user-details

Change request updated