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
- Install dependencies
graphql
andgraphql-request
to your project :
- npm
- yarn
- pnpm
- bun
npm install graphql graphql-request
yarn add graphql graphql-request
pnpm add graphql graphql-request
bun install graphql graphql graphql-request
- 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
- Variable
- Response
query FarcasterUserClaimTransactionDetails($fid: Int!) {
FarcasterUserClaimTransactionDetails(input: { fid: $fid }) {
fid
availableClaimAmount
minimumClaimableAmountInWei
availableClaimAmountInWei
claimedAmount
claimedAmountInWei
processingAmount
processingAmountInWei
}
}
{
fid: 3
}
{
"FarcasterUserClaimTransactionDetails": {
"fid": "3",
"availableClaimAmount": 1348749.451359723,
"minimumClaimableAmountInWei": "1000000000000000000",
"availableClaimAmountInWei": "1348749451359723040759142",
"claimedAmount": 0,
"claimedAmountInWei": "0",
"processingAmount": 0,
"processingAmountInWei": "0"
}
}
graphql-request
library:- TypeScript
- JavaScript
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);
}
index.js
const { gql, GraphQLClient } = require("graphql-request");
const { config } = require("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:
- TypeScript
- JavaScript
ts-node index.ts
node index.js
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.