Public
Full-stack Telegram Mini App for Astric Games
gameshonomini-appreacttelegram
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
A full-stack, dark-glossy arcade Mini App for Telegram: Crash, Roulette, and Sports Prediction, plus promo codes, referrals, a Stars/TON wallet, and a live-editable admin dashboard.
- Backend: Hono (
main.ts+routes/*.ts),std/sqlitefor storage - Frontend: React 18 + Tailwind (via Twind, no build step) + Framer Motion, served straight from
.tsxfiles - Auth: Telegram WebApp
initData, verified server-side with HMAC-SHA256 againstBOT_TOKEN
Rendering mermaid diagram...
Reads from environment variables, with development fallback defaults baked in as requested:
BOT_TOKEN— Telegram bot token, used to validateinitDataand call the Bot API (invoices, webhook replies)ADMIN_TELEGRAM_IDS— comma-separated Telegram user IDs granted the Admin tabPROVIDER_TOKEN_STARS— payment provider token for Telegram Stars invoices ("XTR"for native Stars)BOT_USERNAME(optional) — used to build thehttps://t.me/<bot>?start=<id>referral linkTON_WALLET_ADDRESS(optional) — wallet address shown for manual TON top-ups
👉 Set real values here: https://www.val.town/x/ar6o8bt35n/astric-games-tma/environment-variables?key=BOT_TOKEN
| Route | Purpose |
|---|---|
POST /api/auth | Validates initData, auto-registers the user, applies referral bonus |
GET /api/config | Returns dynamic UI labels merged with defaults |
POST /api/admin/config | Admin-only: update UI labels |
POST /api/admin/promo/create | Admin-only: create/update a promo code |
GET /api/admin/users/search / POST /api/admin/users/adjust-balance | Admin-only: user lookup & balance management |
POST /api/promo/claim | Redeem a promo code |
GET /api/referrals | Referral link, invited users, total earnings |
GET /api/transactions | Wallet transaction history |
POST /api/payments/create-invoice | Stars invoice link or TON payment payload |
POST /api/webhook/telegram | Handles pre_checkout_query + successful_payment |
POST /api/games/booster/launch / GET /api/games/booster/status / POST /api/games/booster/eject | Crash game — server-derived HMAC crash point |
POST /api/games/wheel/spin | Roulette — Alpha/Beta x2, Gamma x14 |
GET /api/games/matches / POST /api/games/matches/predict | Sports prediction |
All game outcomes are computed server-side only — the client never sees secret values (like the crash point) until the round ends.
- The 5-table spec is implemented exactly as described, plus one extra
game_roundstable to hold in-flight Crash rounds server-side (required so the multiplier can't be tampered with client-side). - Sports predictions resolve instantly (weighted by the fixture's odds) for a snappy demo experience — swap in real results if you wire up a live sports-data feed.