A decentralized sports betting platform built on Solana that seamlessly integrates live football fixtures from the Fantasy Premier League API with on-chain transactions. Sportshub utilizes Prisma for persistent database storage of events, bets, and claims while ensuring owner-only functionalities for event management.
You can find the Smart Contract code and address below:
🔗 Repository: Sports Hub Smart Contract
📝 Smart Contract Address: DxbcyaGtfDoVJwYEu6XTRScs66EJwZ9QgaBrviycGSfV
✅ On‑Chain Sports Betting:
Create, resolve, delete, and claim rewards for sports events on the Solana blockchain.
✅ External Fixture Integration:
Fetch live fixtures from the Fantasy Premier League API and display upcoming matches.
✅ Database Persistence:
Store on‑chain events, bets, and claims using Prisma and a PostgreSQL database.
✅ Protected Owner Functionalities:
Certain features (creating events on-chain, resolving, deleting, and claiming rewards) are restricted to the owner (controlled via an environment variable).
- ⚡ Next.js – Server-side rendering & static site generation.
- ⚛️ React – Interactive UI development.
- 🎨 Tailwind CSS & DaisyUI – Utility-first styling & prebuilt components.
- 🔄 TanStack React Query – Optimized data fetching & caching.
- 🔔 React Hot Toast – Real-time notifications.
- 🎨 @tabler/icons-react – High-quality SVG icons.
- 🔗 @solana/web3.js – Solana blockchain interaction.
- 👛 @solana/wallet-adapter-react – Solana wallet integration.
- 🎰 @solana/spl-token – SPL token management.
- 🔧 @coral-xyz/anchor – Simplified smart contract development on Solana.
- 🏦 Prisma – Type-safe ORM for database interactions.
- 🌐 Axios – HTTP client for API requests.
- 🗄 PostgreSQL – Database storage.
- ⚡ Jotai – State management.
- 🔍 Zod – TypeScript-first schema validation.
- ✅ ESLint & Jest – Code linting & testing.
- 🔐 Environment Management – Handled via
@t3-oss/env-nextjs.
- 📦 Node.js: v18.18.0 or higher
- 💰 Solana CLI: Installed & configured
- 🏦 Database: PostgreSQL (or Prisma-supported provider)
git clone https://github.com/solana-developers/sportshub.git
cd sportshub pnpm installCreate a .env file in the root directory with the following variables:
NODE_ENV=development
DATABASE_URL=postgresql://USER:PASSWORD@HOST:PORT/DATABASE
NEXT_PUBLIC_OWNER_PUBLIC_KEY=YourOwnerWalletPublicKeyHereReplace placeholders with actual values.
npx prisma migrate dev --name init pnpm devOpen http://localhost:3000 in your browser.
pnpm build pnpm start- External Fixtures:
/api/fplFixtures→ Fetch live fixtures. - Database Events:
/api/dbFplEvents→ Manage on‑chain events. - Bets:
/api/bets→ Log bet placements. - Claims:
/api/claims→ Log reward claims.
useFplFixtures→ Fetches external fixture data.useDatabaseEvents→ Retrieves on‑chain event data.useCreateEvent,usePlaceBet,useResolveEvent,useClaimReward,useDeleteEvent→ Wrap on‑chain transactions & persist data via API.
The dashboard consists of: 1️⃣ FPL Fixtures (External) – Displays upcoming matches with admin-only on-chain event creation. 2️⃣ Database Events – Displays on-chain events with options to place bets, resolve, delete, and claim rewards.
🔐 Owner-Only Protection:
The app checks the wallet's public key against NEXT_PUBLIC_OWNER_PUBLIC_KEY to grant access to restricted functionalities.