@stackso/js-core
v0.5.5
Published
NodeJS SDK for the Stack Point System
Downloads
4,366
Readme
Stack's Onchain Points SDK
Bring loyaty points onchain.
Get Started
Sign up at stack.so to get your API key and create a point system.
Install
npm install @stackso/js-core
Usage
For complete docs on usage: https://docs.stack.so/
Initialize the client
import {StackClient} from "@stackso/js-core";
// Initialize the client
const stack = new StackClient({
// Get your API key and point system id from the Stack dashboard (stack.so)
apiKey: "YOUR_API_KEY",
pointSystemId: "YOUR_POINT_SYSTEM_ID",
});
Add points and tag the event type
await stack.track("signup", {
points: 10,
account: "0x627306090abaB3A6e1400e9345bC60c78a8BEf57"
});
await stack.track("signup", {
points: 15,
account: "0x2eeb301387D6BDa23E02fa0c7463507c68b597B5",
});
Get points for an account
await stack.getPoints("0x627306090abaB3A6e1400e9345bC60c78a8BEf57");
// => 10
Get leaderboard
await stack.getLeaderboard();
// => [
// {account: "0x2eeb301387D6BDa23E02fa0c7463507c68b597B5", points: 15},
// {account: "0x627306090abaB3A6e1400e9345bC60c78a8BEf57", points: 10}
// ]
// Pagination
await stack.getLeaderboard({limit: 10, offset: 20});