Socials Combinations

Learn how to fetch the list of common token holders across ERC20, NFTs, and POAPS, that also have XMTP, Lens, or Farcaster.

Topics

Pre-requisites

XMTP

Fetching

To check if XMTP is enabled, simply add xmtp.isXMTPEnabled under the owner field:

query GetCommonHoldersWithXMTP {
  TokenBalances(
    input: {filter: {tokenAddress: {_eq: "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D"}}, blockchain: ethereum, limit: 200}
  ) {
    TokenBalance {
      owner {
        tokenBalances(input: {filter: {tokenAddress: {_eq: "0x23581767a106ae21c074b2276D25e5C3e136a68b"}}, limit: 200}) {
          owner {
            addresses
            xmtp {
              isXMTPEnabled
            }
          }
        }
      }
    }
  }
}

Formatting

To get the list of all holders in a flat array, use the following format function:

const formatFunction = (data) =>
  data?.TokenBalances?.TokenBalance?.map(({ owner }) =>
    owner?.tokenBalances?.map(({ owner }) =>
      owner?.xmtp?.isXMTPEnabled ? owner?.addresses : null
    )
  )
    .filter(Boolean)
    .flat(2)
    .filter((address, index, array) => array.indexOf(address) === index) ?? [];

The final result will the the list of all common holders in an array:

[
  "0xc77d249809ae5a118eef66227d1a01a3d62c82d4",
  "0x3291e96b3bff7ed56e3ca8364273c5b4654b2b37",
  "0xe348c7959e47646031cea7ed30266a6702d011cc",
  // ...other token holders
  "0xa69babef1ca67a37ffaf7a485dfff3382056e78c",
  "0x46340b20830761efd32832a74d7169b29feb9758",
  "0x2008b6c3d07b061a84f790c035c2f6dc11a0be70"
]

Lens

Fetching

To show Lens profile in the responses, add socials with lens added to the dappName filter under the owner field:

query GetCommonHoldersWithLens {
  TokenBalances(
    input: {filter: {tokenAddress: {_eq: "0xb93ee8cdab36199c6debf5bbec53e5908fd8e4e1"}}, blockchain: ethereum, limit: 200}
  ) {
    TokenBalance {
      owner {
        tokenBalances(input: {filter: {tokenAddress: {_eq: "0x0a1bbd57033f57e7b6743621b79fcb9eb2ce3676"}}, limit: 200}) {
          owner {
            addresses
            socials(input: {filter: {dappName: {_eq: lens}}}) {
              profileName
              dappName
            }
          }
        }
      }
    }
  }
}

Formatting

To get the list of all holders in a flat array, use the following format function:

const formatFunction = (data) =>
  data?.TokenBalances?.TokenBalance?.map(({ owner }) =>
    owner?.tokenBalances?.map(({ owner }) =>
      owner?.socials.length > 0 ? owner?.addresses : null
    )
  )
    .filter(Boolean)
    .flat(2)
    .filter((address, index, array) => array.indexOf(address) === index) ?? [];

The final result will the the list of all common holders in an array:

[
  "0xc77d249809ae5a118eef66227d1a01a3d62c82d4",
  "0x3291e96b3bff7ed56e3ca8364273c5b4654b2b37",
  "0xe348c7959e47646031cea7ed30266a6702d011cc",
  // ...other token holders
  "0xa69babef1ca67a37ffaf7a485dfff3382056e78c",
  "0x46340b20830761efd32832a74d7169b29feb9758",
  "0x2008b6c3d07b061a84f790c035c2f6dc11a0be70"
]

Farcaster

Fetching

To show Farcaster in the responses, add socials with farcaster added to the dappName filter under the owner field:

query GetCommonHoldersWithFarcaster {
  TokenBalances(
    input: {filter: {tokenAddress: {_eq: "0xb93ee8cdab36199c6debf5bbec53e5908fd8e4e1"}}, blockchain: ethereum, limit: 200}
  ) {
    TokenBalance {
      owner {
        tokenBalances(input: {filter: {tokenAddress: {_eq: "0x0a1bbd57033f57e7b6743621b79fcb9eb2ce3676"}}, limit: 200}) {
          owner {
            addresses
            socials(input: {filter: {dappName: {_eq: farcaster}}}) {
              profileName
              dappName
            }
          }
        }
      }
    }
  }
}

Formatting

To get the list of all holders in a flat array, use the following format function:

const formatFunction = (data) =>
  data?.TokenBalances?.TokenBalance?.map(({ owner }) =>
    owner?.tokenBalances?.map(({ owner }) =>
      owner?.socials.length > 0 ? owner?.addresses : null
    )
  )
    .filter(Boolean)
    .flat(2)
    .filter((address, index, array) => array.indexOf(address) === index) ?? [];

The final result will the the list of all common holders in an array:

[
  "0xc77d249809ae5a118eef66227d1a01a3d62c82d4",
  "0x3291e96b3bff7ed56e3ca8364273c5b4654b2b37",
  "0xe348c7959e47646031cea7ed30266a6702d011cc",
  // ...other token holders
  "0xa69babef1ca67a37ffaf7a485dfff3382056e78c",
  "0x46340b20830761efd32832a74d7169b29feb9758",
  "0x2008b6c3d07b061a84f790c035c2f6dc11a0be70"
]

Developer Support

If you have any questions or need help regarding fetching holders or attendees of multiple POAPs, please join our Airstack's Telegram group.

More Resources

Last updated

#300: add-user-details

Change request updated