A production-ready EVM prediction market platform built with a secure prediction market contract (Solidity) and modern prediction market frontend (React). Features peer-to-peer wagering, multi-sig escrow, automatic payouts, and comprehensive security measures.
Status: ✅ Production Ready — All functions tested, security hardened, and fully optimized.
A fully functional prediction market on EVM chains featuring peer-to-peer wagering, multi-sig escrow, automatic payouts, and dispute resolution. This platform includes a production-ready smart contract with comprehensive security measures and a modern, responsive frontend.
- Smart Contract: Solidity 0.8.20, Hardhat — Secure, audited-ready EVM prediction market contract
- Frontend: React + TypeScript, Vite, Material-UI, wagmi/viem — Modern, responsive UI
- Wallet Support: MetaMask & WalletConnect integration
- Network: Polygon Amoy (testnet) — Ready for mainnet deployment
- ✅ Create Wagers — Set up prediction markets with custom terms
- ✅ Pledge Funds — Join wagers with minimum pledge requirements
- ✅ Multi-Sig Escrow — Secure fund holding with participant signatures
- ✅ Resolve Wagers — Declare winners with explicit selection
- ✅ Auto Payout — Automatic fund release when all participants sign
- ✅ Manual Release — Release funds after deadline passes
- ✅ Cancel Wagers — Creator can cancel with automatic refunds
- ✅ Dispute Resolution — Submit disputes to Polymarket (ready for integration)
- ✅ Reentrancy Protection — All critical functions protected
- ✅ Access Control — Creator and owner-only functions
- ✅ Input Validation — Comprehensive validation on all inputs
- ✅ Safe External Calls — Proper state updates before transfers
- ✅ Emergency Withdraw — Owner can recover funds if needed
- ✅ Responsive UI — Works on desktop and mobile
- ✅ Real-time Updates — Live transaction status
- ✅ Transaction Tracking — Explorer links for all transactions
- ✅ Error Handling — User-friendly error messages
- ✅ Loading States — Clear feedback during operations
Crypto-Prediction-Market/
├── contracts/ # Smart contract (Solidity, Hardhat)
│ ├── contracts/ # WagerContract.sol (main contract)
│ ├── test/ # Comprehensive test suite
│ ├── scripts/ # Deployment scripts
│ └── abi/ # Contract ABIs
├── frontend/ # React frontend application
│ ├── src/
│ │ ├── components/ # Reusable UI components
│ │ ├── hooks/ # Custom React hooks
│ │ ├── pages/ # Page components
│ │ ├── config/ # Configuration files
│ │ └── utils/ # Utility functions
│ └── public/ # Static assets
└── README.md # This file
- Node.js 18+ and npm
- MetaMask browser extension (or compatible wallet)
- Polygon Amoy testnet MATIC (for testing)
-
Clone the repository
git clone <repository-url> cd Crypto-Prediction-Market
-
Install Frontend Dependencies
cd frontend npm install -
Install Contract Dependencies
cd ../contracts npm install
cd frontend
npm run devThe frontend will start on http://localhost:5173 (or your configured port).
Environment Variables (create .env in frontend/):
VITE_WAGER_CONTRACT_ADDRESS=0x... # Deployed contract address
VITE_WALLETCONNECT_PROJECT_ID=... # Optional: WalletConnect project ID-
Configure Network (in
contracts/hardhat.config.js):- Add your private key to
.env - Configure network settings
- Add your private key to
-
Deploy to Polygon Amoy:
cd contracts npm run deploy:amoy -
Deploy to Polygon Mainnet:
npm run deploy:polygon
cd contracts
npm testAll tests should pass (19/19).
- Framework: React 18 + TypeScript
- Build Tool: Vite 7
- UI Library: Material-UI (MUI) 5
- Web3: wagmi 2 + viem 2
- State Management: Zustand
- Routing: React Router 6
- Styling: Emotion (CSS-in-JS)
- Language: Solidity 0.8.20
- Framework: Hardhat 2
- Security: OpenZeppelin Contracts 5
- Testing: Hardhat + Chai
- Network: Polygon Amoy (testnet) / Polygon (mainnet)
- Linting: ESLint
- Type Checking: TypeScript
- Package Manager: npm
Smart Contract:
- ✅ All 13 functions implemented and tested
- ✅ Security hardened (reentrancy protection, access control)
- ✅ Comprehensive test suite (19/19 tests passing)
- ✅ NatSpec documentation added
- ✅ Gas optimized
- ✅ Ready for audit
Frontend:
- ✅ All contract functions accessible from UI
- ✅ Complete user flows (create, pledge, resolve, release, cancel)
- ✅ Real-time transaction tracking
- ✅ Error handling and validation
- ✅ Responsive design
- ✅ Wallet integration (MetaMask + WalletConnect)
Security:
- ✅ Reentrancy protection on all critical functions
- ✅ Proper access control (creator/owner checks)
- ✅ Input validation throughout
- ✅ Safe external calls with state updates
- ✅ Emergency withdrawal mechanism
- 🔒 Security: Added reentrancy protection to
cancelWager()andsignMultiSig() - 🎯 UX: Added explicit winner selection dropdown
- ⏰ Accuracy: Fixed multi-sig deadline calculation
- 🎨 Features: Added cancel wager and release funds UI buttons
- 📝 Documentation: Added NatSpec comments to all contract functions
- ⚡ Optimization: Removed duplicate code, improved gas efficiency
createWager()- Create a new prediction market wagerpledge()- Pledge funds to join a wagerresolveWager()- Resolve wager and set winner (creator/owner only)signMultiSig()- Sign multi-sig to approve fund releasereleaseFunds()- Release funds to winner (after deadline or all signed)cancelWager()- Cancel wager and refund participants (creator/owner only)
getWager()- Get complete wager detailsgetParticipants()- Get all participants for a wagergetUserWagers()- Get all wagers for a userhasSigned()- Check if user has signed multi-siggetWagerCount()- Get total number of wagers
emergencyWithdraw()- Emergency fund recovery (owner only)
# Compile contracts
npm run compile
# Run tests
npm test
# Deploy to Polygon Amoy
npm run deploy:amoy
# Deploy to Polygon Mainnet
npm run deploy:polygon
# Export ABI
npm run export-abi
# Verify contract on explorer
npm run verify:amoy <CONTRACT_ADDRESS># Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Lint code
npm run lint- ✅ All critical functions use
nonReentrantmodifier - ✅ State updates occur before external calls
- ✅ Access control enforced (creator/owner checks)
- ✅ Input validation on all user inputs
- ✅ Safe external transfers with proper error handling
For questions, issues, or feature requests, please open an issue on the repository.
- E-Mail: admin@hyperbuildx.com
- Telegram: @hyperbuildx
Built with ❤️ for the decentralized prediction market ecosystem