@winsznx/flapwire
v0.1.0
Published
Stake-to-play SDK for Flap on Celo (cUSD) + Stacks. Play lifecycle, score-threshold math, daily bounty roll, streak + podium badges.
Maintainers
Readme
flapwire
TypeScript SDK for Flap — stake-to-play arcade on Celo (cUSD) + Stacks. Play lifecycle, score-threshold payout math, daily bounty roll, daily-hop streak counter.
pnpm add @winsznx/flapwire viemviem is a peer dependency. The Stacks subpath is dependency-free.
What's in the box
payoutWei(stake, score, threshold)— mirrors the contract's 2x-on-win rulebountyContributionWei— what the day's bounty pool earns from a losing playtodayId(),timeUntilNextRoll(),formatRollover()— UTC-midnight day boundary helpershopReward(run)— daily-hop tier (default / every 7 / every 30)streakBadgeReward,podiumLabel— badge label helpersSTAKE_PRESETS,DIFFICULTY_LABELS— start-play form defaults- Celo bindings —
readTodayId,readScoreThreshold,writeStartPlay,writeSettlePlay,writeCancelPlay,writeDailyHop - Stacks call shapes —
startPlayCall,submitScoreCall,dailyHopCall,claimPodiumBadgeCall,claimStreakBadgeCall,claimStxCall
Layout
@winsznx/flapwire chain-neutral utilities
@winsznx/flapwire/celo viem reads/writes for Flap.sol
@winsznx/flapwire/stacks hiro v2 + Clarity call-shape buildersQuick start — Celo
import { makePublicClient, readTodayId, readScoreThreshold } from "@winsznx/flapwire/celo";
import { payoutWei, formatCusd, parseCusd } from "@winsznx/flapwire";
const client = makePublicClient({ selector: "mainnet" });
const today = await readTodayId(client);
const threshold = await readScoreThreshold(client);
console.log(`Day ${today}, threshold ${threshold}`);
const stake = parseCusd("0.10");
const myScore = 72;
const payout = payoutWei(stake, myScore, threshold);
console.log(`Score ${myScore} pays ${formatCusd(payout)} cUSD`);Bounty rollover countdown
import { formatRollover, timeUntilNextRoll } from "@winsznx/flapwire";
setInterval(() => {
console.log("Next roll in", formatRollover(timeUntilNextRoll()));
}, 1_000);Stacks — open a play
import { startPlayCall, dailyHopCall } from "@winsznx/flapwire/stacks";
const shape = startPlayCall(100_000n, "mainnet");
// Hand `shape` to @stacks/connect's request("stx_callContract", shape).Addresses
- Flap —
0xf4bff097f8f86e147edcb0167e7c49a1ee6f1c70 - cUSD —
0x765DE816845861e75A25fCA122bb6898B8B1282a - Stacks deployer —
SP31DP8F8CF2GXSZBHHHK5J6Y061744E1TNFGYWYV
Develop
pnpm install
pnpm typecheck
pnpm test
pnpm buildLicense
MIT — see LICENSE.
