πŸ†”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.

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 Lens profile(s)

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

Try Demo

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

Code

query GetAddressesOfLens {
  Socials(
    input: {
      filter: {
        identity: { _in: ["lens/@nader", "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

Show all ENS domains owned by lens/@bradorbradley and lens profile id 0x0187b3

Code

query GetENSOfLens {
  Domains(
    input: {
      filter: { owner: { _in: ["lens/@bradorbradley", "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 lens/@betashop9 and lens profile id 0x0187b3

Code

query GetFarcastersOfLens {
  Socials(
    input: {
      filter: {
        identity: { _in: ["lens/@betashop9", "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

Code

query GetLensOfFarcasters {
  XMTPs(
    input: {
      blockchain: ALL
      filter: { owner: { _in: ["lens/@stani", "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

Was this helpful?