πŸͺ†Tokenbound ERC6551 Accounts

Learn how to get ERC6551 Accounts owned By Farcaster user(s). Get Farcaster users who own NFTs owned by ERC6551 accounts.

πŸͺ† Tokenbound ERC6551 Accounts

Airstack provides easy-to-use APIs for enriching Farcaster applications and for integrating onchain and offchain data with Farcaster.

Table Of Contents

In this guide you will learn how to use Airstack to:

Pre-requisites

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 ERC6551 Account Addresses of Farcaster user(s)

Try Demo

Show all ERC6551 accounts owned by Farcaster user name jayden

Code

query MyQuery {
  TokenBalances(
    input: {
      filter: { owner: { _in: ["fc_fname:jayden"] } }
      blockchain: ethereum
      limit: 200
    }
  ) {
    TokenBalance {
      tokenNfts {
        erc6551Accounts {
          address {
            addresses
          }
        }
      }
    }
  }
}

Get Assets Owned by ERC6551 Accounts of Farcaster user(s)

Try Demo

Code

query MyQuery {
  TokenBalances(
    input: {
      filter: { owner: { _in: ["fc_fname:jayden"] } }
      blockchain: ethereum
      limit: 200
    }
  ) {
    TokenBalance {
      tokenNfts {
        erc6551Accounts {
          address {
            addresses
            tokenBalances {
              tokenAddress
              tokenId
              amount
              token {
                name
                symbol
                tokenNfts {
                  contentValue {
                    image {
                      extraSmall
                      large
                      medium
                      original
                      small
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Get Farcaster of Owner that Owns NFT that Owns ERC6551 Accounts

You can know whether an NFT is owned by an ERC6551 accounts and the NFT that own the account:

Try Demo

Show owner of NFT that owns ERC6551 account with address 0x5416e5dc14caa0950b2a24ede1eb0e97c360bcf5

Code

query MyQuery {
  Accounts(
    input: {
      filter: { address: { _in: "0x5416e5dc14caa0950b2a24ede1eb0e97c360bcf5" } }
      blockchain: ethereum
    }
  ) {
    Account {
      nft {
        tokenBalances {
          owner {
            addresses
            socials(input: { filter: { dappName: { _eq: farcaster } } }) {
              profileName
              userId
            }
          }
        }
      }
    }
  }
}

Developer Support

If you have any questions or need help regarding fetching token bound ERC6551 accounts, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?