🤝Tokens In Common

Learn how to fetch ERC20, NFTs, or POAPs in common from multiple Lens profiles.

🤝 Tokens In Common

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 (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.

ERC20 Tokens In Common Owned By Lens Profile(s)

You can fetch common ERC20 tokens of multiple Lens profiles:

Try Demo

Code

query MyQuery {
  TokenBalances(
    input: {
      filter: {
        owner: { _eq: "lens/@bradorbradley" }
        tokenType: { _eq: ERC20 }
      }
      blockchain: polygon
    }
  ) {
    TokenBalance {
      token {
        tokenBalances(
          input: {
            filter: {
              owner: { _eq: "lens/@christina" }
              tokenType: { _eq: ERC20 }
            }
          }
        ) {
          id
          token {
            address
            symbol
            name
          }
        }
      }
    }
  }
}

NFTs In Common Owned By Lens Profile(s)

You can fetch common NFTs of multiple Lens profile(s):

Try Demo

Code

query MyQuery {
  TokenBalances(
    input: {
      filter: {
        owner: { _eq: "lens/@bradorbradley" }
        tokenType: { _in: [ERC721, ERC1155] }
      }
      blockchain: polygon
    }
  ) {
    TokenBalance {
      token {
        tokenBalances(
          input: {
            filter: {
              owner: { _eq: "lens/@christina" }
              tokenType: { _in: [ERC721, ERC1155] }
            }
          }
        ) {
          id
          token {
            address
            symbol
            name
          }
        }
      }
    }
  }
}

POAPs In Common Owned Lens Profile(s)

You can fetch common POAPs of multiple Lens profile(s):

Try Demo

Code

query MyQuery {
  Poaps(
    input: {
      filter: { owner: { _eq: "lens/@bradorbradley" } }
      blockchain: ALL
      order: { createdAtBlockNumber: DESC }
    }
  ) {
    Poap {
      poapEvent {
        poaps(input: { filter: { owner: { _eq: "lens/@christina" } } }) {
          poapEvent {
            eventName
            eventId
            endDate
            country
            city
          }
        }
      }
    }
  }
}

Developer Support

If you have any questions or need help regarding fetching common ERC20 tokens, NFTs, or POAPs of multiple Lens profiles, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?