Skip to main content

Check User's Everyday Rewards Amount

In this tutorial, you will learn how to check user's everyday rewards amount by calling the Moxie Everyday Rewards Claim API API.

Pre-requisites

  1. Install dependencies graphqlandgraphql-request to your project :
npm install graphql graphql-request
  1. Your Airstack API key will need to be allow listed to have access to the Moxie Everyday Rewards Claim API. To request access, please fill in this form here.

Step 1: Add The API Query To Your Code

To check user's everyday rewards amount, you can use the following query:

query FarcasterUserClaimTransactionDetails($fid: Int!) {
FarcasterUserClaimTransactionDetails(input: { fid: $fid }) {
fid
availableClaimAmount
minimumClaimableAmountInWei
availableClaimAmountInWei
claimedAmount
claimedAmountInWei
processingAmount
processingAmountInWei
}
}
With this GraphQL query, you can add it to your source code and call the API with the graphql-request library:
index.ts
import { gql, GraphQLClient } from "graphql-request";
import { config } from "dotenv";

config();

const graphQLClient = new GraphQLClient(
"https://claims.airstack.xyz/moxie"
);

const query = gql`
query FarcasterUserClaimTransactionDetails($fid: Int!) {
FarcasterUserClaimTransactionDetails(input: { fid: $fid }) {
fid
availableClaimAmount
minimumClaimableAmountInWei
availableClaimAmountInWei
claimedAmount
claimedAmountInWei
processingAmount
processingAmountInWei
}
}
`;

const variable = {
fid: 3
}

const headers = {
// Add Airstack API key here
"x-airstack-claims": process.env.AIRSTACK_API_KEY as string,
}

try {
const data = await graphQLClient.request(query, variable, headers);
console.log(data);
} catch (e) {
throw new Error(e);
}

Step 2: Execute Your Code

Once you have your code ready, you can execute it by running the following command:

ts-node index.ts

If it runs successfully, you should see the data returned in the terminal:

{
"FarcasterUserClaimTransactionDetails": {
"fid": "3",
"availableClaimAmount": 1348749.451359723,
"minimumClaimableAmountInWei": "1000000000000000000",
"availableClaimAmountInWei": "1348749451359723040759142",
"claimedAmount": 0,
"claimedAmountInWei": "0",
"processingAmount": 0,
"processingAmountInWei": "0"
}
}

Congrats! 🥳🎉 You've just fetched user's everyday rewards amount!

Developer Support

If you have any questions or need help with other use cases, feel free to join the /airstack Warpcast channel and ask your questions there.

Our team is always ready to help you with any questions you may have.