🪭 Moxie Fan TokensLearn 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:
npm yarn pnpm pip
React
Copy npm install @airstack/airstack-react
Node
Copy npm install @airstack/node
React
Copy yarn add @airstack/airstack-react
Node
Copy yarn add @airstack/node
React
Copy pnpm install @airstack/airstack-react
Node
Copy pnpm install @airstack/node
Then, add the following snippets to your code:
React Node Python
Copy 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 >;
}
};
Copy import { init , fetchQuery } from "@airstack/node" ;
init ( "YOUR_AIRSTACK_API_KEY" );
const query = `YOUR_QUERY` ; // Replace with GraphQL Query
const { data , error } = await fetchQuery (query);
console .log ( "data:" , data);
console .log ( "error:" , error);
Copy import asyncio
from airstack . execute_query import AirstackClient
api_client = AirstackClient (api_key = "YOUR_AIRSTACK_API_KEY" )
query = """YOUR_QUERY""" # Replace with GraphQL Query
async def main ():
execute_query_client = api_client . create_execute_query_object (
query = query)
query_response = await execute_query_client . execute_query ()
print (query_response.data)
asyncio . run ( main ())
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 Response
Copy 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
}
}
}
Copy {
"data" : {
"MoxieFanTokens" : {
"MoxieFanToken" : [
{
"currentPrice" : 333.2940312828 ,
"currentPriceInWei" : 333294031282823600000
}
]
}
}
}
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 Response
Copy 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
}
}
}
Copy {
"data" : {
"MoxieFanTokens" : {
"MoxieFanToken" : [
{
"totalSupply" : 2.9452860156560017e+22
}
]
}
}
}
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 Response
Copy 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
}
}
}
Copy {
"data" : {
"MoxieFanTokens" : {
"MoxieFanToken" : [
{
"uniqueHolders" : 516
}
]
}
}
}
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 Response
Copy 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
}
}
}
Copy {
"data" : {
"MoxieFanTokens" : {
"MoxieFanToken" : [
{
"tlv" : 7.863170089196643e+24
}
]
}
}
}
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 Response
Copy query MyQuery {
MoxieFanTokens(
input: {
filter : {
uniqueHolders : { _gte : "100" }
}
}
) {
MoxieFanToken {
fanTokenName
fanTokenSymbol
uniqueHolders
}
}
}
Copy {
"data" : {
"MoxieFanTokens" : {
"MoxieFanToken" : [
{
"fanTokenName" : "vlady" ,
"fanTokenSymbol" : "fid:239748" ,
"uniqueHolders" : 140
} ,
// Other Fan Tokens w/ > 100 holders
]
}
}
}
Get Trending Fan Tokens
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 Response
Copy query MyQuery {
MoxieFanTokens(
input: {
order : { uniqueHolders : DESC},
filter : {}
}
) {
MoxieFanToken {
fanTokenName
fanTokenSymbol
uniqueHolders
}
}
}
Copy {
"data" : {
"MoxieFanTokens" : {
"MoxieFanToken" : [
{
"fanTokenName" : "network:farcaster" ,
"fanTokenSymbol" : "id:farcaster" ,
"uniqueHolders" : 2097
} ,
{
"fanTokenName" : "betashop.eth" ,
"fanTokenSymbol" : "fid:602" ,
"uniqueHolders" : 1142
} ,
{
"fanTokenName" : "/airstack" ,
"fanTokenSymbol" : "cid:airstack" ,
"uniqueHolders" : 776
} ,
// Other trending Fan Tokens
]
}
}
}
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