What it is
FitStake is a web app for fitness competitions with money on the line. One person creates a room for an exercise, a stake, and a time limit. Others join by doing the workout on camera and paying the same stake. When the room ends, the contract pays the whole pot to the best performer.
A camera and a pose model replace self-reported results. The browser counts repetitions (reps) and scores form.
The problem
Online fitness challenges depend on trust. Participants report their own numbers, and someone has to hold and distribute the prize money. The project tries to remove both weak points. A pose model measures the workout, and a smart contract holds the stakes.
The repo is open about the gap that remains: the measurement happens on the user's device. The design therefore adds a cheat-detection step and an audit trail, covered below.
How it works
The repository is a pnpm workspace with two packages: blockchain/ (Hardhat 3 and Solidity) and web/ (Next.js 15).
A competition runs in five steps:
- The creator calls
RoomFactory.createRoomwith the exercise type, stake, duration, and a JSON exercise config. The factory deploys a newRoomcontract and forwards the creator's stake to it. - A participant opens the room page and starts the workout.
MediaPipeWorkout.tsxruns MediaPipe's pose landmarker on the webcam stream and counts reps from joint angles. lib/mediapipe-utils.tsscores each rep from 0 to 100 using range of motion (40 points), tempo (35 points), and consistency (25 points).- The participant signs the result with their wallet and calls
Room.submitWorkout, paying the stake. The result includes rep count, form score, signature, and a JSON session summary. - After the deadline, the creator calls
finalizeRoom. The contract picks the submission with the highestrepCount * formScoreand sends it the full balance. With no submissions, the creator gets the stake back.
AI services
The server routes under web/src/app/api/0g/ call the 0G network, a decentralized compute and storage service.
| Route | Purpose |
|---|---|
generate-config | Asks a Llama 3 70B model on 0G Compute for an exercise config: which joints to track and target angles. |
cheat-detection | Sends recent pose landmarks to a DeepSeek R1 model on 0G Compute and returns whether the movement looks suspicious. |
storage | Writes the session (poses and flagged violations) to 0G Storage. |
During a workout, the client checks for anomalies every 10 frames and sends the last 20 poses. Each route has a fallback. Without an OG_PRIVATE_KEY, cheat detection uses a heuristic and storage uses server memory.
Chains and identity
lib/wagmi.ts configures Ethereum mainnet, Sepolia, a local Hardhat chain, and Flow testnet (chain ID 545). The use-ens.ts hook resolves ENS (Ethereum Name Service) names so the UI can show names instead of addresses. The room creation page also checks whether a proposed ENS name for a room is available.
What I built
I built the competition contracts, the room creation and play flow, the pose scoring, and the 0G storage and cheat-detection integration. Two teammates (humannx2 and ombhojane) built the landing page, theme, ENS and client utilities, and the wallet dialog and room sidebar.
Design decisions
Pose detection runs in the browser. MediaPipe runs client-side. The API routes receive landmark coordinates, not video frames, so the camera stream stays on the device. The cost is that the client produces the result, which is why the app adds cheat detection.
A cap of 10 frames per second. The detection loop runs every 100 ms. The code comments say this prevents browser crashes. MediaPipe also requires strictly increasing timestamps, so the loop keeps a monotonic counter.
One contract per room. The factory deploys a separate Room for each competition, so each pot is isolated. The trade-off is a deployment cost for every room. The factory also keeps a registry of rooms by ID and by creator.
Winner takes the pot. Ranking by repCount * formScore rewards both volume and quality, and the contract can compute it from stored values. The trade-off is that one winner takes everything, and ties go to the earliest submission.
Off-chain verification. Room.sol stores the wallet signature and the session JSON but does not verify either. It trusts the submitted rep count and score. Cheat flags live in 0G Storage, and the contract does not read them. Closing that gap is future work in the repo's own status list, which names anti-cheat and an agent verification layer.
0G instead of a hosted model API. The commit history shows the first AI integration used Cloudflare AI through the Vercel AI SDK. A later commit (late on 27 September 2025, UTC) moved to 0G. The repo's PRIZE_TRACK_ALIGNMENT.md maps the 0G, ENS, and Flow integrations to hackathon sponsor tracks.
Run it locally
You need Node.js, pnpm, a browser wallet, and a webcam.
-
Clone the repository and install dependencies.
git clone https://github.com/humannx2/eth-global cd eth-global pnpm install -
Optional: create
web/.env.localwithOG_PRIVATE_KEYto use the 0G network. Without it, the app uses the fallbacks described above. -
Start the frontend.
pnpm -F web dev -
Optional: deploy your own factory and regenerate the typed contract bindings.
pnpm -F blockchain hardhat ignition deploy ignition/modules/RoomFactory.ts --network sepolia pnpm -F web wagmi generate -
Connect a wallet on Sepolia or Flow testnet, create a room, and start the camera.
Reference
| Area | Choice | Used for |
|---|---|---|
| Frontend | Next.js 15 (Turbopack), React 19, TypeScript | App Router UI |
| UI | Tailwind CSS 4, shadcn/ui | Styling and components |
| Pose tracking | MediaPipe Tasks Vision | In-browser landmark detection |
| Contracts | Solidity 0.8.28, Hardhat 3, Ignition | RoomFactory, Room, deployment |
| Web3 client | wagmi 2, viem, ethers | Wallet, contract calls, 0G SDKs |
| AI and storage | 0G Compute and 0G Storage SDKs | Config generation, cheat detection, session storage |
| Identity | ENSjs | Name resolution |
Deployed RoomFactory contracts, from the Ignition deployment records:
| Network | Address |
|---|---|
| Sepolia | 0x9839385033B11C2678BE017fA774BC05970775bA |
| Flow testnet | 0x9dd8fbDDEE26E7DdFE19D0cc8BDf01A1144c8340 |
Outcome
A team of three built FitStake at ETHGlobal New Delhi, a 36-hour hackathon that began on 26 September 2025. The hackathon page records no placement. The commits run from 26 September to 28 September 2025 from several contributor accounts. A hosted build runs at the project's live link, and the contracts are on testnets only.