Skip to content

project-hattrick/hatrick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

109 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Hatrick

Hatrick

One platform, two ways to live the 2026 World Cup — simulated fantasy duels and a live 2D match arena, both driven by the same real-time data source: the TxLINE feed on Solana.
View Design System · Report Bug · Request Feature

🌐 Live — hatrick.xyz » · Follow @playhatrick on X

CI License Solana Powered by TxLINE Hackathon

Important

Hackathon entry for the TxODDS World Cup 2026 → Consumer & Fan Experiences track. Devnet only, fictitious tokens — no real money moves. Not affiliated with FIFA; no official marks are used.

Hatrick live arena demo

104 matches · 1 TxLINE feed · 2 modes · 2 states per event (during / after)

Evaluation Snapshot

Hatrick is designed to read as more than a demo: it is a consumer product loop where real-time sports data becomes play, social viewing, and settlement. The judging shortcut is simple:

  • Unique concept: one TxLINE-powered engine drives both a live match arena and fantasy duels, instead of shipping another leaderboard, prediction widget, or chatbot.
  • Clear TxLINE dependency: scores, events, odds, snapshots, replay, settlement, and fantasy progression all flow from the same provider-shaped pipeline.
  • Consumer-first UX: email sign-in creates a Solana wallet invisibly, so a non-crypto fan can enter, get test funds, open packs, and place devnet bets without wallet setup friction.
  • Real-time credibility: every event has a fast during state for animation and a confirmed after state for settlement, making responsiveness and trust visible in the product.
  • Business path: Live betting margin, fantasy packs, market fees, and wallet retention form one economy instead of disconnected features.
Table of Contents
  1. Evaluation Snapshot
  2. About the Project
  3. Features
  4. Getting Started
  5. Data & Architecture — powered by TxLINE
  6. Track Fit — Consumer & Fan Experiences
  7. Apps
  8. Roadmap
  9. Compliance
  10. License
  11. Team & Contributors
  12. Contact

About the Project

Hatrick turns the World Cup feed into a consumer game loop. Fans normally split their attention across score apps, fantasy tools, odds screens, and social feeds; Hatrick puts the core actions in one place: watch the match, bet the live market, collect cards, and play a squad duel.

The Two Modes

  • 🎮 Fantasy — open player packs, build your XI, and enter simulated 1v1 arena duels. Base cards are collectibles; live form and squad strength are informed by real player and team performance.
  • 📺 Live — follow real matches as a 2D arena with play-by-play, odds, and in-match betting on one screen.

The defining mechanic: every event is emitted in two statesduring (optimistic, animates instantly) and after (confirmed by TxLINE, authoritative). See Architecture.

How TxLINE feeds the modes

TxLINE is the engine behind both modes, not just a logo in the footer.

Mode What TxLINE provides What Hatrick turns it into
Fantasy Player stats, lineups, goals, cards, shots, corners, final results, and confirmed after events Card form, squad strength, duel inputs, player context, and replayable fantasy moments
Live Real-time score events, match clock, play-by-play actions, odds updates, snapshots, and confirmed results 2D arena motion, event feed, odds board, bet slip, settlement, and late-join state recovery

The value is the same signed feed creating two products: Live makes the match watchable and bettable now; Fantasy keeps the fan economy active before, during, and after the match.

Built With

TypeScript NestJS Next.js React Tailwind Solana Docker

  • API: NestJS · @nestjs/event-emitter (event-driven) · Socket.IO · Axios
  • Front: Next.js (App Router) · shadcn/ui · Zustand · React Query · Solana Wallet Adapter · custom canvas game engine (framework-free TS)
  • Data: TxLINE (SSE scores + odds, REST snapshots, oracle-signed settlement inputs) — see Data & Architecture
  • Chain: Solana (devnet) · Anchor programs for betting, fantasy duels, packs, and provably-fair seeds
  • Infra: Docker (Postgres + Redis) · GitHub Actions CI

(Back to top)

Features

Opening a sticker pack

🃏 Sticker packs → your cards

Open packs to reveal player stickers with a base rating, country, and rarity. Each card is minted as a Metaplex Core NFT on Solana devnet — serial-numbered, capped supply, provably-fair pull — so your collection lives in your own wallet.

  • Base card identity stays fixed; live form can be recomputed from TxLINE player and match stats.
  • Cards feed the Fantasy 1v1, where real performance influences squad strength.
  • Country and rarity support future collection and marketplace mechanics.

⚔️ Fantasy 1v1 duels

Build your XI from the cards you own and stake in a simulated 1v1 arena duel rendered by the custom canvas engine. Card ratings and TxLINE-informed form seed the simulation.

  • Challenge a friend or get matched.
  • Wager settles to the winner; result is provable.
Fantasy 1v1 duels — arena
Live 2D arena with odds

📺 Live mode + in-match betting

Follow real matches as a 2D real-time arena shaped by the TxLINE feed, with live odds and in-match bets settled by the authoritative result.

  • Optimistic during animation, confirmed after settlement.
  • 1X2 / Over-Under markets from the real odds feed.

👥 Watch-together rooms

Invite-only rooms to watch a match with friends — shared chat, social picks, and a match backdrop driven by the same feed.

Watch-together room
Live events feed, chat, and HatBot

🗣️ Live feed, chat & HatBot

Every live match and Fantasy duel carries a social panel — Stats, a real-time Events feed (the full play-by-play, with player names), and Chat. HatBot jumps into the feed on the big beats — goals, reds, penalties, VAR — the instant they land, so the conversation keeps pace with the match. Crowd moments also surface as comic-style speech balloons over the stands. HatBot is a nicely-formatted feed of real events, by design not AI.

🛒 Team store & wallet

A themed store for packs and cards, and one wallet shared across both modes. Sign in with just an email — a Solana embedded wallet is created invisibly (Privy) — or connect Phantom.

  • Wager balance shown as a stablecoin ticker (devnet).
  • Betting gated to wallet accounts; compliance built in (18+, geo, self-exclusion).
Team store and wallet

(Back to top)

Getting Started

A polyglot monorepo of independent apps — nothing shared, no cross-app imports. Run each app on its own.

Prerequisites

  • Node.js 20+
  • Docker (for Postgres + Redis)
  • (optional) A Solana wallet such as Phantom — email sign-in works without one
  • Rust, Solana CLI 2.2.16, and Anchor 0.31.1 when building or deploying contracts/

Installation

# 1) API + infra (run from project/)
cd api
docker compose up -d                  # postgres :5432 + redis :6379
npm install                           # postinstall runs `prisma generate`
cp .env.example .env                   # set TXLINE_* to ingest live data
npm run prisma:deploy                  # apply migrations to a fresh DB
npm run start:dev                      # http://localhost:3001/health

# 2) Front (separate terminal)
cd front
npm install
cp .env.example .env.local
npm run dev                            # http://localhost:3000

# 3) Contracts (only when deploying or testing on-chain mode)
cd ../contracts
yarn install
anchor build --release
yarn test                              # local validator-backed Anchor tests

The API boots cleanly with TXLINE_ENABLED=false and SOLANA_ENABLED=false (no credentials needed). See api/README.md for TxLINE and chain setup, and contracts/README.md for Anchor build/deploy instructions.

(Back to top)

Data & Architecture — powered by TxLINE

Everything you see in Hatrick originates from TxLINE, TxODDS' real-time World Cup data product. There is no scraped or invented match data: one feed, one ingest path, many consumers.

Where the data comes from

Source What it carries How we use it
TxLINE SSE — scores Live match events (goals, cards, corners, possession…) with a confirmed flag The heartbeat of the whole app
TxLINE SSE — odds Real-time market prices Odds boards + in-match betting markets
TxLINE REST snapshots Fixtures, lineups, current state Fixture pages, initial state on connect
Solana devnet TxLINE token activation plus Hatrick Anchor programs for betting, fantasy duels, card packs, and provably-fair seeds Access to the feed is provisioned on-chain; app flows can run in play-money mode or chain-authoritative mode

One feed, two states, many consumers

TxLINE SSE (scores + odds)
        ▼
[api] ingest → normalizer ──emits──►  *.during (confirmed=false → optimistic, animate now)
        │   in-memory state           *.after  (confirmed=true  → authoritative, settle & recompute)
        ▼
   EventEmitter2 ─► listeners (fantasy attributes · live markets · settlement)
        ▼
[api] WebSocket gateway ──► [front] one WS → Zustand stores → surfaces

The core contract: every domain event fires twice. *.during is the optimistic read (TxLINE confirmed=false) — it drives instant animation. *.after is the authoritative read (confirmed=true) — it settles bets, recomputes fantasy attributes, and locks the score. The UI feels instant and trustworthy because those are two different events, not one guess.

What the feed drives on screen

  • Live: score events animate the arena; odds updates price the board; confirmed results settle bets.
  • Fantasy: player/team performance updates card form and squad strength after confirmed events.
  • Replay: finished matches run through the same pipeline, so demos show real TxLINE behavior without waiting for kickoff.

(Back to top)

Track Fit — Consumer & Fan Experiences

How Hatrick answers each judging criterion of the track:

Criterion How Hatrick answers it
Fan Accessibility & UX One platform instead of three tabs: watch, play, and bet share one profile, wallet, and design system. Two clear modes from a single home; built for a non-technical fan.
Real-Time Responsiveness The during/after contract makes latency a feature: the arena animates the instant an event arrives (*.during) and reconciles when TxLINE confirms it (*.after). One SSE ingest → WebSocket fan-out to every surface.
Originality & Value Creation Not another picks leaderboard or pundit bot — a playable match simulation driven by real data. Live matches become a 2D arena; fantasy cards get stronger from real performances; both are the same engine fed by the same feed.
Commercial & Monetization Path A closed economy with real monetization hooks: betting margin (Live), pack sales and market fees (Fantasy), and a wallet ledger connecting them. Responsible gaming built in (18+ gate, self-exclusion, stake limits) — table stakes for anything odds-adjacent.
Completeness & Execution Functional end-to-end today: on-chain TxLINE token activation, four Anchor programs, live ingest, betting with settlement, pack → XI → 1v1 duels, replay for demos. Devnet, no real money.

And the hard requirements: TxLINE as live input ✅ · Solana sign-up ✅ (wallet = Competitor account) · functional product, not a mockup ✅ · public repo + ≤5-min demo video with the submission.

🔗 Proof it's on-chain: program ids, deploy commands, and verification steps live in contracts/README.md — and every pack buy, bet, and settlement in the app links straight to Solscan (devnet).

(Back to top)

Apps

App Stack Port Status
api/ NestJS, event-driven (TxLINE → DURING/AFTER → WebSocket) 3001 active
front/ Next.js (App Router) + shadcn/ui + Zustand + React Query 3000 active
contracts/ Anchor / Solana (devnet): betting, fantasy, packs, provably-fair seeds active
project/
├─ api/        # NestJS — event-driven, TxLINE ingest, WS gateway (+ docker-compose)
├─ front/      # Next.js — shadcn, Zustand, React Query, services/
└─ contracts/  # Anchor / Solana — betting, fantasy duels, packs, provably-fair seeds

(Back to top)

Roadmap

  • Monorepo scaffold (api + front), governance docs, CI, Docker infra
  • Event-driven core with the during / after contract
  • TxLINE integration — on-chain token activation, SSE ingest, snapshots, match replay through the live pipeline
  • Live Mode — feed-driven 2D arena, live odds board, markets, in-match betting + settlement
  • Fantasy Mode — packs, XI builder, dynamic attributes, 1v1 arena duels
  • Responsible gaming — 18+ age gate, self-exclusion, stake limits
  • Geo-blocking on betting surfaces (proxy.ts, ?geo=demo bypass)
  • Contracts — Anchor programs for betting escrow, fantasy duel escrow, card packs, and provably-fair seeds
  • Public deploy — live at hatrick.xyz + demo video with the submission
  • On-chain proof — Solscan receipts for pack buys, bets, and settlements (devnet)
  • Live social feed — real-time Events play-by-play with player names, HatBot reactions on the big beats, and live viewer picks across Live and Fantasy
  • More matches & leagues — grow past the World Cup into TxODDS' wider catalog (350+ leagues, 30+ sports); ingest is league-agnostic, so activating a competition is config (POST /token/activate {leagues}), not a rewrite
  • Crowd at scale — multi-user chat with moderation & ranking, plus X-style social balloons

(Back to top)

Compliance

  • No FIFA IP — no official branding, logos, marks, or implied affiliation.
  • Devnet only — fictitious tokens; no real-money movement during the hackathon.
  • Geo-blocking — betting surfaces restrict regulated jurisdictions.
  • Natural-person authorship — AI used as a tool; a human team owns the submission.

(Back to top)

License

Distributed under the MIT License. See LICENSE.txt for details once the license file is added to the repository.

(Back to top)

Team & Contributors

Kauã Miguel
Kauã Miguel

Owner · @Kc1t
Deborah Pavanelli Colicchio
Deborah Pavanelli Colicchio

Member · @eudehh
Pedro Henrique
Pedro Henrique

Member · @opedrooz

(Back to top)

Contact

Team Hatrick · X: @playhatrick · Repository: https://github.com/project-hattrick/hat-trick

(Back to top)

About

One platform, two ways to live the 2026 World Cup - a 2.5D fantasy and a live 2D match view, both powered by the TxLINE real-time feed on Solana.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors