Sealva-Devs
Prediction-Market-Web3
TypeScriptโœจ New

Production-ready crypto prediction market platform with secure smart contracts and modern React frontend. Features peer-to-peer wagering, multi-sig escrow, automatic payouts, and comprehensive security measures. Built with Solidity, Hardhat, React, and wagmi/viem.

Last updated Jul 10, 2026
45
Stars
422
Forks
0
Issues
0
Stars/day
Attention Score
95
Language breakdown
TypeScript 74.7%
Solidity 15.9%
JavaScript 8.1%
HTML 0.7%
CSS 0.5%
โ–ธ Files click to expand
README

Crypto Prediction Market โ€” Production-Ready EVM Prediction Market Platform

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.

kurokage


What Is This Platform?

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.

Core Components

  • 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

Features

Core Functionality

  • โœ… 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)

Security Features

  • โœ… 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

User Experience

  • โœ… 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

Project Structure

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

Quick Start

Prerequisites

  • Node.js 18+ and npm
  • MetaMask browser extension (or compatible wallet)
  • Polygon Amoy testnet MATIC (for testing)

Installation

  • 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

Running the Frontend

cd frontend
npm run dev

The frontend will start on http://localhost:5173 (or your configured port).

Environment Variables (create .env in frontend/):

VITEWAGERCONTRACT_ADDRESS=0x...  # Deployed contract address VITEWALLETCONNECTPROJECT_ID=...  # Optional: WalletConnect project ID

Deploying the Contract

  • Configure Network (in contracts/hardhat.config.js):
- Add your private key to .env - Configure network settings
  • Deploy to Polygon Amoy:
cd contracts
   npm run deploy:amoy
  • Deploy to Polygon Mainnet:
npm run deploy:polygon

Running Tests

cd contracts
npm test

All tests should pass (19/19).


Tech Stack

Frontend

  • 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)

Smart Contract

  • Language: Solidity 0.8.20
  • Framework: Hardhat 2
  • Security: OpenZeppelin Contracts 5
  • Testing: Hardhat + Chai
  • Network: Polygon Amoy (testnet) / Polygon (mainnet)

Development Tools

  • Linting: ESLint
  • Type Checking: TypeScript
  • Package Manager: npm

Project Status

โœ… Production Ready

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

Recent Improvements

  • ๐Ÿ”’ Security: Added reentrancy protection to cancelWager() and signMultiSig()
  • ๐ŸŽฏ 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

Smart Contract Functions

Core Functions

  • createWager() - Create a new prediction market wager
  • pledge() - Pledge funds to join a wager
  • resolveWager() - Resolve wager and set winner (creator/owner only)
  • signMultiSig() - Sign multi-sig to approve fund release
  • releaseFunds() - Release funds to winner (after deadline or all signed)
  • cancelWager() - Cancel wager and refund participants (creator/owner only)

View Functions

  • getWager() - Get complete wager details
  • getParticipants() - Get all participants for a wager
  • getUserWagers() - Get all wagers for a user
  • hasSigned() - Check if user has signed multi-sig
  • getWagerCount() - Get total number of wagers

Admin Functions

  • emergencyWithdraw() - Emergency fund recovery (owner only)

Development

Contract Scripts

# 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>

Frontend Scripts

# Start development server
npm run dev

Build for production

npm run build

Preview production build

npm run preview

Lint code

npm run lint

Security Considerations

  • โœ… All critical functions use nonReentrant modifier
  • โœ… 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

Support

For questions, issues, or feature requests, please open an issue on the repository.


Built with โค๏ธ for the decentralized prediction market ecosystem

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท Sealva-Devs/Prediction-Market-Web3 ยท Updated daily from GitHub