@winsznx/snakboard
v0.1.0
Published
Arena escrow SDK for Snak on Celo (cUSD) + Stacks. Match creation, score digest, prize-split math, strike streak counter, rank badge tiers.
Downloads
94,711
Maintainers
Readme
snakboard
TypeScript SDK for Snak — staked snake battle royale on Celo (cUSD) + Stacks. Match lifecycle, replay-safe score digest, prize-split math, daily-strike streak counter.
pnpm add @winsznx/snakboard viemviem is a peer dependency. The Stacks subpath is dependency-free.
What's in the box
buildScoreDigest— replay-safekeccak(matchId|player|score)for scorer signaturespreviewSplit(poolWei, bps)— winner-take + treasury-cut math that mirrors the contractstrikeReward(run)— daily-strike reward by run count (1/4/12/30 tiers)badgeTier(rank)— Bronze / Silver / Gold / Diamond ladder for the rank NFTSTAKE_PRESETS,PLAYER_CAP_PRESETS,DEADLINE_PRESETS— host-arena form defaults- Celo bindings —
readMatch,writeCreateMatch,writeJoinMatch,writeDailyStrike - Stacks call shapes —
createMatchCall,joinMatchCall,dailyStrikeCall,claimRankBadgeCall,claimStxCall
Layout
@winsznx/snakboard chain-neutral utilities
@winsznx/snakboard/celo viem reads/writes for Snak.sol
@winsznx/snakboard/stacks hiro v2 + Clarity call-shape buildersQuick start — Celo
import { makePublicClient, readMatch, writeCreateMatch } from "@winsznx/snakboard/celo";
import { parseCusd, previewSplit, formatCusd } from "@winsznx/snakboard";
const client = makePublicClient({ selector: "mainnet" });
const m = await readMatch(client, 0n);
console.log(`Match 0 status: ${m.status}, ${m.currentPlayers}/${m.maxPlayers} players`);
const split = previewSplit(m.prizePool, 500); // 5% treasury cut
console.log(`Winner takes ${formatCusd(split.winnerWei)} cUSD`);Build a score digest
import { buildScoreDigest } from "@winsznx/snakboard";
const digest = buildScoreDigest({
matchId: 0n,
player: "0xabc...",
score: 1234n,
});
// digest is now ready for the scorer key to sign + submit on chain.Stacks — host a match
import { createMatchCall } from "@winsznx/snakboard/stacks";
const shape = createMatchCall(
{
stake: 1_000_000n, // microSTX
maxPlayers: 6,
deadline: 100_000n, // burn-block height
},
"mainnet",
);
// Hand `shape` to @stacks/connect's request("stx_callContract", shape) in your app.Addresses
- Snak —
0x5f134731bd668071a0bcebfd9ddfd243f63ce424 - cUSD —
0x765DE816845861e75A25fCA122bb6898B8B1282a - Stacks deployer —
SP31DP8F8CF2GXSZBHHHK5J6Y061744E1TNFGYWYV
Develop
pnpm install
pnpm typecheck
pnpm test
pnpm buildLicense
MIT — see LICENSE.
