@stackso/js-core
TypeScript icon, indicating that this package has built-in type declarations

0.5.10 • Public • Published

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});

Readme

Keywords

none

Package Sidebar

Install

npm i @stackso/js-core

Weekly Downloads

1,673

Version

0.5.10

License

ISC

Unpacked Size

119 kB

Total Files

86

Last publish

Collaborators

  • graemecode
  • marystackso
  • volt99