Builder Points SDK
Installation
Getting Started
Intialize the library for AppRegistry.
Intialize the library for B3PointService (BPS).
Setting Up an Account for Write Functions
Contract write call requires wallet account which can be initiated in two ways.
Step 1: Register your app
The register function allows you to register an application to the AppRegistry. This function returns the app ID.
There are 2 identifiers needed to register your app:
appName
This is your b3.fun ENS name registered on your profile on basement.fun
To get this, connect your wallet on basement.fun and register a username for your app, which used here.
operator
Operator wallet will be responsible for distributing points for each session (it can be different from the wallet used to register the ENS appName).
Choose an operator address where you are comfortable with executing the write functions to the contract with.
Example
Step 2: Distribute Points
The transferPoints function allows app operator to distribute granted points to users only for the current ongoing session. Once the season is finalized, the previously granted points cannot be updated anymore.
Example
Distribute Points With CSV file
In addition to using transferPoints, developers can leverage distributePointsCsv to distribute points on a larger scale by providing a CSV file. This function will break the entries into batch of 100, prepare the on-chain transactions, and send out with rate limiting to ensure the transaction can confirm on-chain.
We have built in dedup logic into this flow. Therefore it is safe to trigger the function multiple times with the same file until you see all the points are delivered.
Code examples are available here.
Example
Then from root run
Cancel Transfer (optional)
The app operator can optionally call cancelTransfer to cancel a pending transfer (that is in the current season) if needed to undo a transfer.
Example
Public Read Functions
The following examples are functions that apps can use to read data from the points contract. These read functions do not need to be called with a wallet provider, and are publicly accessible.
You can use these functions to retrieve the total number of points a given user has on your app, or fetch the BP points a user has across the ecosystem.
List Apps
The listApps function returns all the registered apps. It accepts rankings and pagination arguments.
Example
Get App Total Points
Returns the total point by the appId. Optionally you can provide session to get total points for the app for that session only.
Example
Get App Available Points
Returns the total point by the appId after distributing it to the user. Optionally you can provide session to get total points for the app for that session only.
Example
Aggregate App Points
Returns a list of total points grouped by the appId. Optionally you can provide session to get total points for each app for that session only. You can also provide rankings and pagination arguments.
Example
Get User Total Points
Returns the points of a user. Provide session to get total points for a session.
Example
Aggregate User Points
Returns a list of total points grouped by the user address. Optionally you can provide session to get total points for each user for that session only. You can also provide rankings and pagination arguments.
Example
List Points Transfers
Returns a list of point transfers. Optionally you can provide appId, session, user, status, rankings, and pagination arguments.