🪭Moxie Fan Tokens

Learn how to fetch data about Moxie Fan Tokens in the Moxie protocol.

Table Of Contents

Pre-requisites

  • An Airstack API key. To access this, you'll need to hold at least 1 /airstack Channel Fan Token.

  • 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 The Current Price Of A Fan Token

You can get the current price of a Fan Token by using the MoxieFanTokens API and inputting the Fan Token symbol in fanTokenSymbol input:

Alternatively, you can also use fanTokenAddress to specify the Fan Token input data.

Try Demo

Get The current price of Fan Token FID 3 (in Moxie)

Code

query MyQuery {
  MoxieFanTokens(
    input: {
      filter: {
        fanTokenSymbol: {
          # Fan Token to check, symbol will be based on types:
          # - User: fid:<FID>
          # - Channel: cid:<CHANNEL-ID>
          # - Network: id:farcaster
          _eq: "fid:3"
        }
      }
    }
  ) {
    MoxieFanToken {
      currentPrice
      currentPriceInWei
    }
  }
}

Get The Total Supply Of A Fan Token

You can get the total supply of a Fan Token by using the MoxieFanTokens API and inputting the Fan Token symbol in fanTokenSymbol input:

Alternatively, you can also use fanTokenAddress to specify the Fan Token input data.

Try Demo

Show me the total supply of Fan Token FID 3

Code

query MyQuery {
  MoxieFanTokens(
    input: {
      filter: {
        fanTokenSymbol: {
          # Fan Token to check, symbol will be based on types:
          # - User: fid:<FID>
          # - Channel: cid:<CHANNEL-ID>
          # - Network: id:farcaster
          _eq: "fid:3"
        }
      }
    }
  ) {
    MoxieFanToken {
      totalSupply
    }
  }
}

Get The Number Of Unique Holders Of A Certain Fan Token

You can get the number of unique holders of a Fan Token by using the MoxieFanTokens API and inputting the Fan Token symbol in fanTokenSymbol input:

Alternatively, you can also use fanTokenAddress to specify the Fan Token input data.

Try Demo

Show me the number of unique holders of FID 3

Code

query MyQuery {
  MoxieFanTokens(
    input: {
      filter: {
        fanTokenSymbol: {
          # Fan Token to check, symbol will be based on types:
          # - User: fid:<FID>
          # - Channel: cid:<CHANNEL-ID>
          # - Network: id:farcaster
          _eq: "fid:3"
        }
      }
    }
  ) {
    MoxieFanToken {
      uniqueHolders
    }
  }
}

Get The Current Total Locked Value Of A Certain Fan Token

You can get the current total locked value of a Fan Token by using the MoxieFanTokens API and inputting the Fan Token symbol in fanTokenSymbol input:

Alternatively, you can also use fanTokenAddress to specify the Fan Token input data.

Try Demo

Show me the current TVL of Fan Token FID 3

Code

query MyQuery {
  MoxieFanTokens(
    input: {
      filter: {
        fanTokenSymbol: {
          # Fan Token to check, symbol will be based on types:
          # - User: fid:<FID>
          # - Channel: cid:<CHANNEL-ID>
          # - Network: id:farcaster
          _eq: "fid:3"
        }
      }
    }
  ) {
    MoxieFanToken {
      tlv
    }
  }
}

Get All Fan Tokens With More Than X Holders

You can get all the Fan Tokens with more than certain number of holders by using the MoxieFanTokens API and inputting the amount filter criteria in the uniqueHolders input:

Try Demo

Show me all Fan Tokens with more than 100 holders

Code

query MyQuery {
  MoxieFanTokens(
    input: {
      filter: {
        uniqueHolders: {_gte: "100"}
      }
    }
  ) {
    MoxieFanToken {
      fanTokenName
      fanTokenSymbol
      uniqueHolders
    }
  }
}

You can get the trending Fan Tokens list as shown in the Airstack Explorer here by using the MoxieFanTokens API and sorting the data by uniqueHolders variable:

Try Demo

Show me trending Fan Tokens in the Moxie protocol

Code

query MyQuery {
  MoxieFanTokens(
    input: {
      order: {uniqueHolders: DESC},
      filter: {}
    }
  ) {
    MoxieFanToken {
      fanTokenName
      fanTokenSymbol
      uniqueHolders
    }
  }
}

Developer Support

If you have any questions or need help regarding fetching Farcaster user's Moxie Fan Token data, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?