This repository contains a simple Prediction Market smart contract deployable on the Base Network using Remix IDE. Users can bet on outcomes, and the winners receive the total pool proportionally.
- Go to https://remix.ethereum.org
- Connect your wallet (e.g., MetaMask, OKX, Bitget) to Base Testnet or Mainnet.
- File path:
contracts/PredictionMarket.sol - Paste the smart contract code from
PredictionMarket.sol.
- Solidity compiler: 0.8.13
- Enable optimization (optional)
- Click Compile PredictionMarket.sol
Ensure there are no compilation errors.
- Environment: Injected Web3
- Network: Base Testnet/Mainnet
- Constructor parameters:
- ERC20 token address (used for betting)
- Array of outcome names, e.g.:
["TeamA Wins","TeamB Wins","Draw"]
- Click Deploy and confirm in your wallet
placeBet(outcomeId, amount)→ Place your bet on an outcomeoutcomeIdstarts from 0- Approve Marketplace contract to spend your ERC20 tokens first
closeMarket(winningOutcomeId)→ Owner closes the market and declares the winning outcome
claimPayout()→ Winners can claim their share of the total pool
withdrawTokens(amount)→ Owner can withdraw any ERC20 tokens from the contract
- Ensure the market has sufficient liquidity in ERC20 tokens.
- Betting is proportional, payout is based on contribution to winning outcome.
- For production, consider adding:
- Time-limited betting
- Security checks
- Multiple rounds