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
- 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.
-
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
- Variable
- Response
query FarcasterUserClaimTransactionDetails(
$fid: Int!
$transactionId: String
) {
FarcasterUserClaimTransactionDetails(
input: { fid: $fid, transactionId: $transactionId }
) {
transactionId
transactionStatus
transactionHash
transactionAmount
transactionAmountInWei
rewardsLastEarnedTimestamp
}
}
{
fid: 3,
transactionId: "0d9b17b2-07e2-41cb-8cf6-f8351ec7f669",
}
{
"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"
}
}
graphql-request
library:- TypeScript
- JavaScript
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);
}
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!
$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:
- TypeScript
- JavaScript
ts-node index.ts
node index.js
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.