Skip to main content

Stats

The SDK offers a set of endpoints to retrieve various statistics, providing developers with the ability to access historical data and metrics relevant to their projects. This SDK simplifies the integration of these data points into your application, enabling you to leverage valuable insights.

Interval

For startDate and endDate, a maximum interval of 12 months is accepted.

getStakeWalletCount()

Use this function to obtain the count of unique wallets used to create new stakes within a specific date range.

import { anvil } from "@ada-anvil/sdk-server";

try {
await anvil.stats.getStakeWalletCount({
stakeCollectionId: YOUR_STAKE_COLLECTION_ID,
start: "ISO_START_DATE",
end: "ISO_END_DATE",
});
// Ouput: 790
} catch {
console.log("YOUR ERROR HANDLING");
}

getStakeCountByStatus()

This function returns a count of each action that occurred within a specified time range.

CLAIMING represents the number of stakes that have ended.

HARVESTING indicates the number of stakes where rewards were collected without ending the stake.

STAKING refers to the newly created stakes.

import { anvil } from "@ada-anvil/sdk-server";

try {
await anvil.stats.getStakeCountByStatus({
stakeCollectionId: YOUR_STAKE_COLLECTION_ID,
start: "ISO_START_DATE",
end: "ISO_END_DATE",
});
// Ouput: {"CLAIMING":864, "HARVESTING":297, "STAKING":1256}
} catch {
console.log("YOUR ERROR HANDLING");
}

getDistributedRewardsByUnit()

Call this function to retrieve the total sum of all distributed rewards for a specific date range. The returned JSON provides a key-value mapping, where the key represents the token unit and the value indicates the amount of tokens.

import { anvil } from "@ada-anvil/sdk-server";

try {
await anvil.stats.getDistributedRewardsByUnit({
stakeCollectionId: YOUR_STAKE_COLLECTION_ID,
start: "ISO_START_DATE",
end: "ISO_END_DATE",
});
// Ouput: {"lovelace":5000000, "A_TOKEN_UNIT":20000}
} catch {
console.log("YOUR ERROR HANDLING");
}

getStakeCount()

This function returns the total size of the collection, along with the number of staked NFTs, based on the optional filters provided in the parameters.

policyId can be a string or an array of strings. If this filter isn't needed, it can be left undefined.

metadata is an object containing the values you'd like to filter by. If you want to accept multiple values for a single attribute, you can provide them as an array. The metadata format should match the on-chain metadata.

Caution

This call can be resource-intensive, so we highly recommend caching the results and adapting your code accordingly.

import { anvil } from "@ada-anvil/sdk-server";

try {
await anvil.stats.getStakeCount({
filters: {
policyId: "A_POLICY_ID", // Optional: If your stake collection includes multiple policies, you can filter them
metadata: { Type: ["Human", "Alien"] }, // Optional: If you want to retrieve the stake count specific traits only
},
stakeCollectionId: YOUR_STAKE_COLLECTION_ID,
});
// Ouput: {"total": 10000,"staked": 3324}
} catch {
console.log("YOUR ERROR HANDLING");
}

getMintSalesCountByStatus()

Use this function to retrieve basic statistics about your mint collection.

sold represents the number of NFTs sold and confirmed on the chain.

pending indicates the number of pending transactions that have not yet been confirmed on the chain.

unsold refers to the remaining NFTs in this collection.

import { anvil } from "@ada-anvil/sdk-server";

try {
await anvil.stats.getMintSalesCountByStatus({
mintCollectionId: YOUR_MINT_COLLECTION_ID,
});
// Output: {"sold": 131,"pending": 0,"unsold": 1894}
} catch {
console.log("YOUR ERROR HANDLING");
}