A simple binary prediction market dApp deployed on Base (mainnet or Sepolia testnet). Users predict whether ETH/USD price will go UP or DOWN within a fixed round, stake ETH, and winners split the pool.
- Smart contract: Solidity
0.8.24, Hardhat, Chainlink ETH/USD price feed (Base) - Frontend: React + Vite + TypeScript, wagmi v2 + viem, RainbowKit
- Chain: Base Mainnet (8453) / Base Sepolia (84532)
contracts/PredictionGame.sol # Main contract
scripts/deploy.ts # Hardhat deploy script
test/PredictionGame.test.ts # Tests
hardhat.config.ts
frontend/ # Vite + React dApp
npm install
npx hardhat compile
npx hardhat test
# Deploy to Base Sepolia
cp .env.example .env # add PRIVATE_KEY + BASESCAN_API_KEY
npx hardhat run scripts/deploy.ts --network baseSepoliacd frontend
npm install
cp .env.example .env # add VITE_CONTRACT_ADDRESS + VITE_WC_PROJECT_ID
npm run dev- Owner (or anyone) calls
startRound()— locks current ETH/USD price from Chainlink, opens a 5-minute betting window. - Players call
bet(true)for UP orbet(false)for DOWN with ETH stake. - After the round duration, anyone calls
endRound()— fetches new price, determines winner side. - Winners call
claim(roundId)to withdraw their proportional share of the losing pool + their original stake. 2% protocol fee.
| Network | Chain ID | Chainlink ETH/USD |
|---|---|---|
| Base Mainnet | 8453 | 0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70 |
| Base Sepolia | 84532 | 0x4aDC67696bA383F43DD60A9e78F2C97Fbbfc7cb1 |
MIT