🆔Resolve Lens Profiles

Learn how to resolve Lens profiles to 0x address, ENS, Farcaster, and XMTP and Reverse Resolution.

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

In this tutorial, you will learn how to resolve a Lens profile name or ID to other 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.

Get All 0x addresses of Lens profile(s)

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

Try Demo

Show 0x addresses of nader.lens and Lens profile id 0x0187b3

Code

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

Get all ENS domains owned by Lens profile(s)

You can resolve an array of Lens profile(s) to their ENS domains:

Try Demo

Code

query GetENSOfLens {
  Domains(input: {filter: {owner: {_in: ["bradorbradley.lens", "lens_id:0x0187b3"]}}, blockchain: ethereum}) {
    Domain {
      name
    }
  }
}

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

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

Try Demo

Show web3 socials (Lens, Farcaster) owned by bradorbradley.eth and 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045

Code

query GetWeb3SocialsOfLens {
  Socials(input: {filter: {identity: {_in: ["bradorbradley.eth", "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"]}}, blockchain: ethereum}) {
    Social {
      dappName
      profileName
      profileTokenId
      profileTokenIdHex
      userId
      userAssociatedAddresses
    }
  }
}

Get Farcaster of Lens profile(s)

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

Try Demo

Show Farcasters owned by betashop9.lens and lens profile id 0x0187b3

Code

query GetFarcastersOfLens {
  Socials(
    input: {filter: {identity: {_in: ["betashop9.lens", "lens_id:0x0187b3"]}, dappName: {_eq: farcaster}}, blockchain: ethereum}
  ) {
    Social {
      profileName
      userId
      userAssociatedAddresses
    }
  }
}

Check If XMTP is Enabled for Lens profile(s)

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

Try Demo

Show if XMTP is enabled for stani.lens and Lens profile id 0x0187b3

Code

query GetLensOfFarcasters {
  XMTPs(
    input: {blockchain: ALL, filter: {owner: {_in: ["stani.lens", "lens_id:0x0187b3"]}}}
  ) {
    XMTP {
      isXMTPEnabled
      owner {
        socials(input: {filter: {dappName: {_eq: lens}}}) {
          profileName
          profileTokenId
          profileTokenIdHex
          userAssociatedAddresses
        }
      }
    }
  }
}

Developer Support

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

More Resources

Last updated

#300: add-user-details

Change request updated