💜Farcaster Moxie Rewards Earnings

Learn how to fetch Farcaster Moxie Rewards earned by Farcaster users, channels, and the Farcaster network. In addition, learn how to sort by the earnings to get the top earners of Moxie.

Introduction

The Moxie Protocol enables Farcaster Members to earn Everyday Rewards based on who engages with their casts. Developers can also earn rewards for each unique FID who interacts with their frames.

Learn more about Moxie Everyday Rewards

Table Of Contents

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.

Get Moxie Earning For Certain User

You can fetch the Moxie earnings for a certain user by specifying entityType as USER and add the FID of the user in entityId:

Try Demo

Code

query MyQuery {
  FarcasterMoxieEarningStats(
    input: {
      timeframe: LIFETIME,
      blockchain: ALL,
      filter: {
        # specify entity as USER
        entityType: {_eq: USER},
        # specify the FID of the user
        entityId: {_eq: "3"}
      }
    }
  ) {
    FarcasterMoxieEarningStat {
      allEarningsAmount
      allEarningsAmountInWei
      castEarningsAmount
      castEarningsAmountInWei
      entityId
      entityType
      frameDevEarningsAmount
      frameDevEarningsAmountInWei
      otherEarningsAmount
      otherEarningsAmountInWei
      timeframe
    }
  }
}

Get Moxie Earning For Certain Channel

You can fetch the Moxie earnings for a certain channel by specifying entityType as CHANNEL and add the channel ID in entityId:

Try Demo

Code

query MyQuery {
  FarcasterMoxieEarningStats(
    input: {
      timeframe: LIFETIME,
      blockchain: ALL,
      filter: {
        # Specify entity as CHANNEL
        entityType: {_eq: CHANNEL},
        # Specify the channel ID of the Farcaster channel
        entityId: {_eq: "airstack"}
      }
    }
  ) {
    FarcasterMoxieEarningStat {
      allEarningsAmount
      allEarningsAmountInWei
      castEarningsAmount
      castEarningsAmountInWei
      entityId
      entityType
      frameDevEarningsAmount
      frameDevEarningsAmountInWei
      otherEarningsAmount
      otherEarningsAmountInWei
      timeframe
    }
  }
}

Get Moxie Earning For Farcaster Network

You can fetch the Moxie earnings for the Farcaster network by specifying entityType as NETWORK and add the channel ID in entityId:

Try Demo

Code

query MyQuery {
  FarcasterMoxieEarningStats(
    input: {
      timeframe: LIFETIME,
      blockchain: ALL,
      filter: {
        # Specify entity as NETWORK
        entityType: {_eq: NETWORK}
      }
    }
  ) {
    FarcasterMoxieEarningStat {
      allEarningsAmount
      allEarningsAmountInWei
      castEarningsAmount
      castEarningsAmountInWei
      entityId
      entityType
      frameDevEarningsAmount
      frameDevEarningsAmountInWei
      otherEarningsAmount
      otherEarningsAmountInWei
      timeframe
    }
  }
}

Top Moxie Earning Entities Based On Highest Moxie Earnings

You can fetch the top entities w/ highest Moxie earnings by specifying order.allEarnings to DESC:

Try Demo

Code

query MyQuery {
  FarcasterMoxieEarningStats(
    input: {
      timeframe: LIFETIME,
      blockchain: ALL,
      filter: {
        entityType: {_eq: USER} # alternatively can be CHANNEL
      },
      # Order by All earning for sorting by total earnings in 
      # descending order
      order: {allEarnings: DESC}
    }
  ) {
    FarcasterMoxieEarningStat {
      allEarningsAmount
      allEarningsAmountInWei
      castEarningsAmount
      castEarningsAmountInWei
      entityId
      entityType
      frameDevEarningsAmount
      frameDevEarningsAmountInWei
      otherEarningsAmount
      otherEarningsAmountInWei
      timeframe
    }
  }
}

Developer Support

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

More Resources

Last updated

Was this helpful?

#946:

Change request updated