Przegląd projektu
SleepFi is a mobile app built for the Spark hackathon (Solana Seeker). The concept is simple: you stake SOL betting that you will sleep at least 7 hours every night for a week. Sleep data is pulled automatically from Android Health Connect (e.g. Sleep as Android) - there is no way to fake it manually. If you complete the challenge, you get your stake back plus a proportional share of the failed stakes pool. The entire mechanism runs through an Anchor smart contract on Solana - even the app creator cannot withdraw funds from the escrow.
Wyzwanie
Building a sleep-to-earn app that is truly trustless - not just with a wallet login, but with real on-chain escrow - required solving several problems simultaneously.
Trustless escrow
SOL must be locked in a PDA controlled by the program, not in the creator's wallet. Users need a guarantee that nobody can run away with their money. Anchor program with 6 instructions and 3 PDA types (Pool, ChallengeEscrow, UserState).
Oracle pattern
Sleep data comes from Health Connect on Android, but must be recorded on-chain. The backend acts as an oracle - signing submit_sleep and complete/fail_challenge transactions with the treasury key, but has no access to escrow funds.
Mobile Wallet Adapter
On mobile there are no browser extension wallets. Integration with Phantom/Solflare via MWA (solana-mobile/mobile-wallet-adapter-protocol) requires manually building instructions with discriminators from the IDL - the Anchor.Program class is not compatible with MWA.
Health Connect integration
Reading sleep data from Android Health Connect (react-native-health-connect). Filtering sessions <30min and >12h, time window 6PM-2PM, server-side validation. No manual entry possible - only automatic import from sleep tracking apps.
Nasze rozwiązanie
Full-stack MVP: Anchor smart contract on Solana, backend API on Vercel, React Native mobile app with Expo.
Anchor program - 6 instructions, 3 PDAs
Solana program handling: initialize_pool, start_challenge (lock SOL in escrow PDA), submit_sleep (oracle), complete_challenge (return stake + reward), fail_challenge (transfer to Pool PDA), claim_reward. Deployed on devnet: Gq6HZCUkXhznL8BBfEVXwnB4BCyzfvhpu4CwYe86wUuD.
Backend API (oracle + database)
Vercel serverless functions: /api/sleep (log sleep + oracle submit_sleep), /api/challenge (create/fetch challenges), /api/leaderboard, /api/treasury (real-time balance from Solana RPC). Neon Postgres as database. Backend signs oracle transactions with treasury key.
React Native mobile app
Expo + React Native with 3 tabs: Home (sleep dashboard, weekly chart, challenge status), Leaderboard (top sleepers with wallet addresses), Treasury (real-time SOL balance from devnet, explorer link). MWA for transaction signing via Phantom/Solflare.
Health Connect + sleep validation
Automatic sleep data import from Android Health Connect. Filtering invalid sessions (24h bug, short naps). Time window 6PM-2PM next day. Miss detection - days without entries shown as losses.
Schedule free consultation about your project
During 30-minute call we'll analyze your business requirements and propose fastest path to implementation. We think business-first - goal first, then technology.
Proces realizacji
Day 1-2
Architecture + Anchor program: PDA design, smart contract development and devnet deployment, instruction testing
1Day 3-4
Backend API + database: REST endpoints, oracle signing, Neon Postgres schema, Solana RPC integration
2Day 5-6
Mobile app: UI (3 tabs), MWA integration, Health Connect, manual instruction building with IDL discriminators
3Day 7
Bug fixing: 24h sleep bug, wrong day labels, HC permission flow, treasury real-time balance, APK build + deploy
4Czas realizacji
1 week
Zakres usługi
Mobile App + Smart Contract (Anchor)
Technologie
Galeria projektu
Chcesz podobnych wyników?
Umów się na bezpłatną konsultację i sprawdź, jak AI może pomóc Twojemu biznesowi.
Umów bezpłatną konsultację