Balances
Documentation Link: Here -> Balances
Tutorial: Using the TypeScript SDK for Balance Operations
1. Define the Balance
Here's how you create a balance using the provided Balance
interface:
Note: The UintRange
type is assumed to be an object with start
and end
properties of type bigint
. Adjust as necessary based on the actual definition.
2. Add Balance
To add a balance to an array of existing balances:
This will add balanceToAdd
to the list of existing balances.
3. Subtract Balance
To subtract a balance from an array of existing balances:
Conclusion
This SDK provides a clear and structured way to manage and operate on badge balances. With the addBalance
and subtractBalance
functions, you can effortlessly update and maintain badge balances in your application.
Given the new functions you've shared, I'll provide a tutorial snippet for each of them.
Tutorial: Retrieving Balances Based on Badge ID and Time
1. Get Balance for a Specific ID and Time
If you need to retrieve the balance for a specific badge ID and a specific ownership time, you can use the getBalanceForIdAndTime
function:
2. Get Balances for a Specific Badge ID
To get all balances associated with a specific badge ID:
3. Get Balances for a Specific Time
If you need to retrieve all badge balances for a specific ownership time:
Alright, given the new function getBalancesForIds
which retrieves balances for a range of badge IDs and a range of times, let's create a tutorial snippet for it:
Get Balances for Specific Ranges of Badge IDs and Times
If you need to retrieve balances for a range of badge IDs and a range of ownership times, you can utilize the getBalancesForIds
function:
Conclusion
The provided functions in this SDK make it easy to retrieve specific badge balances based on different criteria, such as badge ID and ownership time. Utilize these functions to access and display relevant data as per your application's requirements.
Last updated