A Polymarket-style decentralized prediction market platform built on Polygon Amoy Testnet.
- Upgradeable Smart Contract: UUPS proxy pattern for future upgrades
- Event Management: Create, edit, and resolve prediction events
- Betting System: Place bets on outcomes with 2% platform fee
- Payout System: Proportional payouts for winning bets
- Image Storage: Client-side compressed images (max 5KB) stored on-chain
- Category Filtering: Organize events by category
- Search & Pagination: Find events easily
- Dark Theme UI: Modern, responsive design
- Solidity 0.8.22
- OpenZeppelin Upgradeable Contracts (UUPS)
- Hardhat
- Polygon Amoy Testnet (Chain ID: 80002)
- Next.js 14
- TypeScript
- Tailwind CSS
- Wagmi v2
- RainbowKit
- Recharts (for betting pool visualization)
- Node.js 18+
- npm or yarn
- MetaMask or compatible wallet
- Polygon Amoy testnet MATIC (get from faucet)
- Navigate to contracts directory:
cd contracts- Install dependencies:
npm install- Create
.envfile:
PRIVATE_KEY=your_private_key_here
POLYGON_AMOY_RPC=https://rpc-amoy.polygon.technology- Compile contracts:
npm run compile- Deploy to Polygon Amoy:
npm run deployThe deployment script will:
- Deploy the contract as a UUPS proxy
- Save deployment info to
deployments/amoy.json - Copy the ABI to
../frontend/lib/abi.json
- Note the proxy address from the deployment output
- Navigate to frontend directory:
cd frontend- Install dependencies:
npm install- Create
.env.localfile:
NEXT_PUBLIC_CONTRACT_ADDRESS=0x... (from deployment)
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_walletconnect_project_idGet a WalletConnect Project ID from cloud.walletconnect.com
- Run development server:
npm run dev- Connect your wallet (must be owner or authorized creator)
- Navigate to "Create" page
- Fill in event details:
- Title
- Category
- Image (will be compressed to 5KB)
- Context/Description
- End Time
- Outcomes (at least 2)
- Submit transaction
- Browse events on home page
- Click on an event to view details
- Select outcome and enter bet amount
- Confirm transaction (2% platform fee applies)
- Owner can resolve events after end time
- Navigate to event page
- Select winning outcome
- Submit resolution transaction
- After event is resolved, winners can claim payouts
- Navigate to event page
- Click "Claim Payout" button
- Payout is proportional to your bet vs total pool
- Owner can authorize/revoke creators
- Navigate to "Whitelist" page
- Enter address to authorize or check status
- Authorize/revoke as needed
.
├── contracts/
│ ├── contracts/
│ │ └── BigMarketV1.sol
│ ├── scripts/
│ │ ├── deploy.ts
│ │ └── authorize.ts
│ ├── deployments/
│ │ └── amoy.json
│ └── hardhat.config.ts
├── frontend/
│ ├── app/
│ │ ├── page.tsx (Home)
│ │ ├── create/
│ │ ├── event/[id]/
│ │ ├── edit/[id]/
│ │ └── whitelist/
│ ├── components/
│ │ └── Navbar.tsx
│ ├── lib/
│ │ ├── contract.ts
│ │ ├── abi.ts
│ │ └── imageCompression.ts
│ └── package.json
└── README.md
createEvent()- Create a new prediction eventupdateEvent()- Update event details (before bets or resolution)placeBet()- Place a bet on an outcomeresolveEvent()- Resolve event with winning outcome (owner only)claimPayout()- Claim proportional payout for winning betsauthorizeCreator()- Authorize address to create events (owner only)revokeCreator()- Revoke authorization (owner only)
- Network: Polygon Amoy Testnet
- Chain ID: 80002
- RPC: https://rpc-amoy.polygon.technology
- Explorer: https://amoy.polygonscan.com/
-
Deploy Contract:
cd contracts npm install # Create .env with PRIVATE_KEY and POLYGON_AMOY_RPC npm run compile npm run deploy
-
Setup Frontend:
cd frontend npm install # Create .env.local with NEXT_PUBLIC_CONTRACT_ADDRESS and NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID npm run dev
See DEPLOYMENT.md for detailed deployment instructions.
MIT