đŸŒŋLens

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

Learn how to use Airstack to universally resolve and reverse resolve Lens handles to other web3 identities (Farcaster, ENS, Ethereum address, Solana addresses). Airstack supports both Lens v1, and Lens v2 profile names in the API inputs, you can freely use stani.lens or lens/@stani.

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 Lens Profiles from a given user(s)

Try Demo

Code

query GetLens {
  Socials(
    input: {
      filter: {
        identity: {
          _in: [
            "0x4b70d04124c2996de29e0caa050a49822faec6cc"
            "betashop.eth"
            "fc_fname:vbuterin"
          ]
        }
        dappName: { _eq: lens }
      }
      blockchain: ethereum
    }
  ) {
    Social {
      dappName
      profileName
      userId
      profileImageContentValue {
        image {
          medium
        }
      }
    }
  }
}

Get the Ethereum address, Farcaster, and ENS from a given Lens profile(s)

Try Demo

Code

query GetAddressOfLens {
  Socials(
    input: {
      filter: {
        identity: {
          _in: ["lens/@prashantbagga", "betashop9.lens", "lens/@vitalik"]
        }
        dappName: { _eq: lens }
      }
      blockchain: ethereum
    }
  ) {
    Social {
      userAddress
      dappName
      profileName
      userAddressDetails {
        domains {
          name
          isPrimary
        }
      }
    }
  }
}

Get Lens Profiles of a given Solana address

You can fetch the Lens profiles of a given solana address by using the Socials API:

Try Demo

Code

query MyQuery {
  Socials(
    input: {
      filter: {
        identity: { _eq: "GJQUFnCu7ZJHxtxeaeskjnqyx8QFAN1PsiGuShDMPsqV" }
        dappName: { _eq: lens }
      }
      blockchain: ethereum
    }
  ) {
    Social {
      profileName
    }
  }
}

Get All Solana addresses of Lens profile

You can resolve a profile to their 0x addresses by using Socials API:

Try Demo

Code

query MyQuery {
  Wallet(input: { identity: "lens/@alexj", blockchain: ethereum }) {
    farcaster: socials(input: { filter: { dappName: { _eq: farcaster } } }) {
      connectedAddresses {
        address
        chainId
        blockchain
        timestamp
      }
    }
    domains {
      multiChainAddresses {
        address
        symbol
      }
    }
  }
}

Developer Support

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

More Resources

Last updated

Was this helpful?