leaderboard-ts-sdk
v0.0.6
Published
SDK to interact with leaderboards smart contract
Downloads
147
Maintainers
Readme
NPC Labs is a core contributor to B3 - the gaming ecosystem L3 Onchain Leaderboards with B3
Overview
The On-Chain Leaderboard Smart Contract allows game developers to integrate on-chain leaderboards for tracking and displaying player scores securely on the blockchain. The leaderboard is managed by game admins, who can create, set, update, increment, and decrement player scores using player wallet addresses. Additionally, a TypeScript SDK will be provided to facilitate interaction with the contract.
- Purpose: Provide an on-chain solution for managing game leaderboards where scores are stored and updated transparently and securely.
- Primary User: Game admins (authorized by the contract).
- Secondary User: Players whose scores are tracked.
Typescript SDK
- Fetch Leaderboard Data: Allow easy retrieval of leaderboard standings and individual player scores from the contract.
- Update Scores: Provide functionality for admins to interact with the contract methods for setting, updating, incrementing, or decrementing scores.
Example Methods in the SDK:
- createLeaderboard(label: string): Promise
- setScore(label: string, player: string, score: number): Promise
- updateScore(label: string, player: string, score: number): Promise
- incrementScore(label: string, player: string, increment: number): Promise
- decrementScore(label: string, player: string, decrement: number): Promise
- getLeaderboard(label: string): Promise
- getScore(label: string, player: string): Promise
- getPlayerCount(label: string): Promise<number | undefined> // New method
- getLeaderboardSize(label: string): Promise<number | undefined> // New method
- getTopPercentage(label: string, percentage: number): Promise<[string[], number[]]> // New method
- getLeaderboardStartTime(label: string): Promise<number | undefined> // New method
- getLeaderboardEndTime(label: string): Promise<number | undefined> // New method
- isLeaderboardActive(label: string): Promise // New method