Skip to content

Repository files navigation

BIG Market - Prediction Market Platform

A Polymarket-style decentralized prediction market platform built on Polygon Amoy Testnet.

Features

  • 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

Tech Stack

Smart Contracts

  • Solidity 0.8.22
  • OpenZeppelin Upgradeable Contracts (UUPS)
  • Hardhat
  • Polygon Amoy Testnet (Chain ID: 80002)

Frontend

  • Next.js 14
  • TypeScript
  • Tailwind CSS
  • Wagmi v2
  • RainbowKit
  • Recharts (for betting pool visualization)

Setup

Prerequisites

  • Node.js 18+
  • npm or yarn
  • MetaMask or compatible wallet
  • Polygon Amoy testnet MATIC (get from faucet)

Smart Contract Setup

  1. Navigate to contracts directory:
cd contracts
  1. Install dependencies:
npm install
  1. Create .env file:
PRIVATE_KEY=your_private_key_here
POLYGON_AMOY_RPC=https://rpc-amoy.polygon.technology
  1. Compile contracts:
npm run compile
  1. Deploy to Polygon Amoy:
npm run deploy

The 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
  1. Note the proxy address from the deployment output

Frontend Setup

  1. Navigate to frontend directory:
cd frontend
  1. Install dependencies:
npm install
  1. Create .env.local file:
NEXT_PUBLIC_CONTRACT_ADDRESS=0x... (from deployment)
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_walletconnect_project_id

Get a WalletConnect Project ID from cloud.walletconnect.com

  1. Run development server:
npm run dev
  1. Open http://localhost:3000

Usage

Creating Events

  1. Connect your wallet (must be owner or authorized creator)
  2. Navigate to "Create" page
  3. Fill in event details:
    • Title
    • Category
    • Image (will be compressed to 5KB)
    • Context/Description
    • End Time
    • Outcomes (at least 2)
  4. Submit transaction

Placing Bets

  1. Browse events on home page
  2. Click on an event to view details
  3. Select outcome and enter bet amount
  4. Confirm transaction (2% platform fee applies)

Resolving Events

  1. Owner can resolve events after end time
  2. Navigate to event page
  3. Select winning outcome
  4. Submit resolution transaction

Claiming Payouts

  1. After event is resolved, winners can claim payouts
  2. Navigate to event page
  3. Click "Claim Payout" button
  4. Payout is proportional to your bet vs total pool

Managing Authorized Creators

  1. Owner can authorize/revoke creators
  2. Navigate to "Whitelist" page
  3. Enter address to authorize or check status
  4. Authorize/revoke as needed

Project Structure

.
├── 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

Smart Contract Functions

  • createEvent() - Create a new prediction event
  • updateEvent() - Update event details (before bets or resolution)
  • placeBet() - Place a bet on an outcome
  • resolveEvent() - Resolve event with winning outcome (owner only)
  • claimPayout() - Claim proportional payout for winning bets
  • authorizeCreator() - Authorize address to create events (owner only)
  • revokeCreator() - Revoke authorization (owner only)

Network

Quick Start

  1. Deploy Contract:

    cd contracts
    npm install
    # Create .env with PRIVATE_KEY and POLYGON_AMOY_RPC
    npm run compile
    npm run deploy
  2. 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.

License

MIT

About

Private TypeScript frontend for the BIG product concept.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages