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.

🚀 Astric Games — Telegram Mini App

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.

Open the app

Stack

  • Backend: Hono (main.ts + routes/*.ts), std/sqlite for storage
  • Frontend: React 18 + Tailwind (via Twind, no build step) + Framer Motion, served straight from .tsx files
  • Auth: Telegram WebApp initData, verified server-side with HMAC-SHA256 against BOT_TOKEN

Architecture

Rendering mermaid diagram...

Secrets

Reads from environment variables, with development fallback defaults baked in as requested:

  • BOT_TOKEN — Telegram bot token, used to validate initData and call the Bot API (invoices, webhook replies)
  • ADMIN_TELEGRAM_IDS — comma-separated Telegram user IDs granted the Admin tab
  • PROVIDER_TOKEN_STARS — payment provider token for Telegram Stars invoices ("XTR" for native Stars)
  • BOT_USERNAME (optional) — used to build the https://t.me/<bot>?start=<id> referral link
  • TON_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

Backend routes

RoutePurpose
POST /api/authValidates initData, auto-registers the user, applies referral bonus
GET /api/configReturns dynamic UI labels merged with defaults
POST /api/admin/configAdmin-only: update UI labels
POST /api/admin/promo/createAdmin-only: create/update a promo code
GET /api/admin/users/search / POST /api/admin/users/adjust-balanceAdmin-only: user lookup & balance management
POST /api/promo/claimRedeem a promo code
GET /api/referralsReferral link, invited users, total earnings
GET /api/transactionsWallet transaction history
POST /api/payments/create-invoiceStars invoice link or TON payment payload
POST /api/webhook/telegramHandles pre_checkout_query + successful_payment
POST /api/games/booster/launch / GET /api/games/booster/status / POST /api/games/booster/ejectCrash game — server-derived HMAC crash point
POST /api/games/wheel/spinRoulette — Alpha/Beta x2, Gamma x14
GET /api/games/matches / POST /api/games/matches/predictSports prediction

All game outcomes are computed server-side only — the client never sees secret values (like the crash point) until the round ends.

Notes

  • The 5-table spec is implemented exactly as described, plus one extra game_rounds table 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.