A decentralized sports and casino betting platform built on Base network using Solidity smart contracts and React frontend.
- README.md โ High-level overview, architecture, and usage.
- QUICK_START.md โ Fastest path to running everything locally.
- TESTNET_DEPLOYMENT_GUIDE.md โ Step-by-step Base Goerli deployment.
- GAS_OPTIMIZATION_GUIDE.md โ Gas patterns, reporter usage, and analysis.
- CHAINLINK_VRF_INTEGRATION_PLAN.md โ Technical design for future randomness upgrade.
- PAUSE_MECHANISM_SUMMARY.md โ Detailed explanation of pause/unpause controls.
- PREDICTION_MARKETS_SUMMARY.md โ Design and flows for prediction markets.
- LOCAL_DEPLOYMENT_SUCCESS.md โ Reference for a known-good local setup.
- TEST_RESULTS_SUMMARY.md & VERIFICATION_COMPLETE.md โ Testing and readiness snapshots.
- RUNBOOK.md โ Operational checklist and emergency procedures.
- Decentralized sports betting with custom oracle integration
- Support for multiple bet types and game outcomes
- Transparent and immutable bet resolution
- Dice Roll: Guess numbers 1-6 for 5x payout
- Coin Flip: Heads or tails for 1.95x payout
- Roulette: Red/Black/Number betting with varying payouts
- Baccarat: Player/Banker/Tie betting
- Blackjack: Classic card game with 2x payout
- Slots: Symbol matching with variable payouts
- On-chain prediction markets with market creation, betting, resolution, and claims
- Market analytics dashboard with volume over time, category distribution, and key insights
- Full multi-language support (English & Kiswahili)
- Modern / Enhanced layouts for sports and casino play
- Accessible tooltips, responsible gambling limits, and glassmorphism UI
- TZS Token: Tanzanian Shilling Stablecoin for betting
- ERC20 compliant with mint/burn functionality
- 1 billion token max supply
contracts/
โโโ TanzanianStablecoin.sol # ERC20 betting token
โโโ SportsBetting.sol # Sports betting logic
โโโ PredictionMarkets.sol # On-chain prediction markets
โโโ DiceRoll.sol # Dice game
โโโ CoinFlip.sol # Coin flip game
โโโ Roulette.sol # Roulette game
โโโ Baccarat.sol # Baccarat game
โโโ Blackjack.sol # Blackjack game
โโโ Slots.sol # Slots game
frontend/src/
โโโ App.js # Main React application
โโโ contractConfig.js # Contract addresses & ABIs
โโโ App.css # Global styling
โโโ components/ # Feature components (AdminPanel, History, Prediction, etc.)
โโโ index.js # Entry point
User Wallet (MetaMask)
โ
React Frontend (Play / History / Admin / Prediction)
โ via ethers.js
Solidity Contracts on Base (TZS, SportsBetting, Casino Games, PredictionMarkets)
โ
Base Network (Local / Goerli / Mainnet)
- Node.js >= 14.0.0
- MetaMask wallet extension
- Git
-
Clone the repository
git clone <repository-url> cd daubet
-
Install contract dependencies
cd contracts npm install -
Install frontend dependencies
cd ../frontend npm installOr, from the repo root, you can run the provided helper script:
# Unix ./setup-dev.sh # Windows setup-dev.bat
-
Start local Hardhat network
cd contracts npx hardhat nodeKeep this terminal open - it will show deployed contract addresses.
-
Deploy contracts and create config
# In a new terminal cd contracts npx hardhat deploy-with-config --network localhost
This will:
- Deploy all contracts to local network
- Mint 1M TZS tokens to deployer
- Create
frontend/src/contractConfig.jswith addresses
-
Start frontend
cd frontend npm startOpens http://localhost:3000
-
Configure MetaMask
- Add localhost network: RPC URL
http://127.0.0.1:8545, Chain ID31337 - Import the private key from Hardhat node output (Account #0)
- Add localhost network: RPC URL
cd contracts
# Compile contracts
npx hardhat compile
# Run tests
npx hardhat test
# Deploy to localhost with config generation
npx hardhat deploy-with-config --network localhost
# Deploy to testnet (requires PRIVATE_KEY in .env)
npx hardhat deploy-with-config --network baseGoerlicd frontend
# Start development server
npm start
# Build for production
npm run build
# Run tests
npm test- Network: Hardhat Local
- RPC URL: http://127.0.0.1:8545
- Chain ID: 31337
- Network: Base Goerli
- RPC URL: https://goerli.base.org
- Chain ID: 84531
- Network: Base Mainnet
- RPC URL: https://mainnet.base.org
- Chain ID: 8453
Create .env file in contracts/ directory:
# Required for testnet/mainnet deployment
PRIVATE_KEY=your_wallet_private_key_here
# Optional: Contract verification
BASESCAN_API_KEY=your_basescan_api_keyRun the test suite:
cd contracts
npx hardhat testCurrent test coverage:
- โ TanzanianStablecoin
- โ SportsBetting
- โ Baccarat
- โ Slots
- โ DiceRoll
- โ CoinFlip
- โ Roulette
- โ Blackjack
- โ PredictionMarkets
Overall: 200+ tests and ~85% coverage across all core contracts. See VERIFICATION_COMPLETE.md and TEST_RESULTS_SUMMARY.md for details.
- Connect Wallet: Click "Connect MetaMask"
- Get TZS Tokens: Deploy contracts (includes 1M TZS mint)
- Approve Spending: First game interaction will prompt token approval
- Start Betting & Markets:
- Use the Play / History / Admin tabs to navigate
- Within Play, switch between Sports, Casino, and Prediction Markets and choose Enhanced or Modern layout
- Set optional responsible gambling limits, enter bet amounts/parameters, and confirm transactions in MetaMask
- Access Control: Owner-only functions protected
- Reentrancy Protection: SafeMath and proper state management
- Token Approvals: Explicit approval required for spending
- Custom Errors: Gas-efficient error handling
- Input Validation: Comprehensive parameter checking
After deployment, addresses will be automatically saved to:
frontend/src/contractConfig.js(JavaScript imports)frontend/src/contractAddresses.json(JSON format)
- Fork the repository
- Create feature branch:
git checkout -b feature-name - Commit changes:
git commit -am 'Add feature' - Push to branch:
git push origin feature-name - Submit a Pull Request
cd contracts
# Set environment variables
echo "PRIVATE_KEY=your_private_key_here" > .env
echo "BASESCAN_API_KEY=your_basescan_api_key" >> .env
# Deploy contracts
npm run deploy:testnet
# Verify contracts (optional)
npm run verify:testnet <CONTRACT_ADDRESS>cd contracts
# Ensure you have mainnet funds and API keys
npm run deploy:mainnet
# Verify contracts
npm run verify:mainnet <CONTRACT_ADDRESS>cd frontend
# Install dependencies
npm install
# Build for production
npm run build
# Deploy to your hosting service (Vercel, Netlify, etc.)
# The build/ folder contains the static assetsRun the complete test suite:
cd contracts
npm test
# Run with coverage
npm run test:coverage
# Test specific contract
npx hardhat test test/DiceRoll.test.jsConsider adding a few screenshots under a docs/screenshots/ folder, for example:
- Play โ Sports (Modern layout): Main betting view with responsible gambling controls.
- Play โ Casino (Enhanced layout): Glassmorphism cards for casino games.
- Prediction Markets: Market list and analytics.
- History & Admin: Glass headers, stats, and admin controls.
Once available, you can embed them here with standard Markdown image tags.
- Complete smart contract suite (9 contracts, including prediction markets)
- Comprehensive test coverage across core contracts (~85%+)
- Modern React frontend with Web3 integration
- Token approval system for seamless UX
- Responsive glassmorphism UI design
- Transaction history and analytics dashboards
- Admin panel for platform risk and liquidity management
- Multi-language support (English & Kiswahili)
- Proper error handling and loading states
- Contract deployment automation
- Contract verification setup
- Comprehensive documentation
- Implement Chainlink VRF for true randomness (see
CHAINLINK_VRF_INTEGRATION_PLAN.md) - Add production-grade sports data oracle integration
- Add liquidity pool mechanics
- Implement referral / rewards system
- Add mobile app with React Native
- Explore additional game types and market categories
This project is licensed under the MIT License.
- The frontend includes optional responsible gambling controls:
- Max bet per wager (soft cap per bet).
- Max total stake per session (soft cap per session).
- When these limits are set, the app will block or warn on bets that exceed them.
- Limits are user-configurable and can be changed or reset at any time.
- You are responsible for how you use the platform and for staying within your own limits.
Gambling and crypto use may be restricted or illegal in some jurisdictions.
Always verify local laws and consider this project a technical demonstration, not production advice.
- Localization:
- Full English and Kiswahili support for core flows (Play, History, Admin, Prediction Markets).
- All new UI copy and tooltips are wired through the i18n layer.
- UX & accessibility touches:
- Clear navigation hierarchy (Play / History / Admin, and Sports / Casino / Prediction within Play).
- Layout toggle with descriptive tooltips for Enhanced vs Modern views.
- Responsible gambling inputs with labels, helper text, and hints.
- Status messages for loading, errors, and approvals.
- Known limitations:
- Not yet fully audited against WCAG; some components may need additional ARIA roles and keyboard testing.
- Screen reader experience is improving but not guaranteed to be perfect across all browsers.
Contributions that improve accessibility, copy, or localization coverage are very welcome.
This is a demonstration project. Do not use with real funds without proper security audits. Gambling may be illegal in your jurisdiction.