Skip to main content

Check Claim Transaction Status

In this tutorial, you will learn how to check user's claim transaction status 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.

  2. Have the transaction ID of the claim transaction you want to check. You should have received this transaction ID when you initiated the claim transaction from this tutorial here.

Step 1: Add The API Query To Your Code

To check user's claim transaction status, you can use the following query:

query FarcasterUserClaimTransactionDetails(
$fid: Int!
$transactionId: String
) {
FarcasterUserClaimTransactionDetails(
input: { fid: $fid, transactionId: $transactionId }
) {
transactionId
transactionStatus
transactionHash
transactionAmount
transactionAmountInWei
rewardsLastEarnedTimestamp
}
}
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!
$transactionId: String
) {
FarcasterUserClaimTransactionDetails(
input: { fid: $fid, transactionId: $transactionId }
) {
transactionId
transactionStatus
transactionHash
transactionAmount
transactionAmountInWei
rewardsLastEarnedTimestamp
}
}
`;

const variable = {
fid: 3,
transactionId: "0d9b17b2-07e2-41cb-8cf6-f8351ec7f669",
}

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": {
"transactionId": "0d9b17b2-07e2-41cb-8cf6-f8351ec7f669",
"transactionHash": "0x30e12445cc1375f544f99486d36fd144038007488e36f83ed90a2b79950dd66e",
"transactionStatus": "SUCCESS", // If "SUCCESS", then the claim transaction was successful
"transactionAmount": 1206.299242863659,
"transactionAmountInWei": "1206299242863658974356",
"rewardsLastEarnedTimestamp": "2024-08-15T00:00:00.000Z"
}
}

Congrats! 🥳🎉 You've just fetched user's claim transaction status!

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.