A production-ready, mobile-first sports prediction dApp built on Polymarket's infrastructure. Predict soccer match outcomes and earn rewards.
- Polymarket Integration: Real markets powered by Polymarket's CLOB and Gamma APIs
- Share-Based Trading: Buy/sell shares with accurate profit calculations
- Secure Wallet Connection: wagmi v2 integration (no private keys required)
- USDC Approval Flow: Automated approval handling before orders
- Real-time Market Data: Live prices and liquidity from Polymarket
- Mobile-First Design: Responsive UI built with Tailwind CSS
- Framework: Next.js 14 (App Router, TypeScript)
- Styling: Tailwind CSS
- UI Components: shadcn/ui
- Blockchain: Polygon Mainnet (Chain ID: 137)
- Wallet: wagmi v2 + viem v2
- State Management: TanStack Query v5
- API Client: @polymarket/clob-client
- HTTP Client: Axios
- Node.js 18+ and npm
- WalletConnect Project ID (Get one here)
- Clone the repository:
git clone <repository-url>
cd poly-seershub- Install dependencies:
npm install- Configure environment variables:
cp .env.example .env.localEdit .env.local and add your WalletConnect Project ID:
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_project_id_here
- Run the development server:
npm run dev- Open http://localhost:3000 in your browser.
poly-seershub/
├── app/ # Next.js App Router pages
│ ├── layout.tsx # Root layout with providers
│ ├── page.tsx # Homepage
│ ├── matches/ # Match listing and details
│ └── dashboard/ # User dashboard
├── components/
│ ├── ui/ # shadcn/ui base components
│ ├── match/ # Match-related components
│ ├── wallet/ # Wallet connection
│ └── layout/ # Navbar, Footer
├── lib/
│ ├── polymarket/ # Polymarket API integrations
│ ├── wagmi.ts # wagmi configuration
│ ├── constants.ts # Contract addresses & constants
│ └── utils.ts # Utility functions
├── hooks/
│ ├── usePolymarketMarkets.ts # Fetch markets
│ ├── usePlacePrediction.ts # Place orders (with USDC approval)
│ ├── useApiCredentials.ts # Generate API credentials
│ └── useUserPositions.ts # Fetch user positions
└── types/
├── polymarket.ts # Polymarket types
└── match.ts # Match types
CRITICAL: This app NEVER asks for private keys. API credentials are generated using wagmi's useWalletClient hook:
const { data: walletClient } = useWalletClient();
const credentials = await generateApiCredentials(walletClient);The app uses a share-based input model (not amount-based):
// User inputs: Number of shares
const shares = 10;
const price = 0.65; // Current market price
// Calculations
const cost = shares * price; // 10 * 0.65 = $6.50
const potentialPayout = shares * 1.0; // 10 * $1 = $10.00
const profit = potentialPayout - cost; // $10 - $6.50 = $3.50Before placing an order, the app automatically checks and requests USDC approval:
const requiredUsdc = shares * price;
const currentAllowance = await getAllowance();
if (currentAllowance < requiredUsdc) {
await approveUsdc(requiredUsdc); // Triggers wallet approval
}
await placePrediction({ size: shares, price });Team names are extracted from the outcomes array (NOT from the question string):
const homeTeam = market.outcomes[0]; // e.g., "Arsenal"
const awayTeam = market.outcomes[1]; // e.g., "Chelsea"| Variable | Description | Required |
|---|---|---|
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID |
WalletConnect Cloud Project ID | Yes |
NEXT_PUBLIC_GAMMA_API_URL |
Polymarket Gamma API URL | No (has default) |
NEXT_PUBLIC_CLOB_API_URL |
Polymarket CLOB API URL | No (has default) |
NEXT_PUBLIC_CHAIN_ID |
Polygon Chain ID (137) | No (has default) |
- Go to WalletConnect Cloud
- Sign up or login
- Create a new project
- Copy your Project ID
-
Push code to GitHub (already done if you see this)
-
Import project in Vercel
- Go to Vercel Dashboard
- Import your GitHub repository
- Framework Preset: Next.js (auto-detected)
-
Configure Environment Variables
Go to Project Settings → Environment Variables and add:
Variable Value Required NEXT_PUBLIC_WALLETCONNECT_PROJECT_IDYour WalletConnect Project ID ✅ YES NEXT_PUBLIC_GAMMA_API_URLhttps://gamma-api.polymarket.com❌ Optional (has default) NEXT_PUBLIC_CLOB_API_URLhttps://clob.polymarket.com❌ Optional (has default) NEXT_PUBLIC_DATA_API_URLhttps://data-api.polymarket.com❌ Optional (has default) NEXT_PUBLIC_CHAIN_ID137❌ Optional (has default) CRITICAL: Only
NEXT_PUBLIC_WALLETCONNECT_PROJECT_IDis REQUIRED! -
Deploy
- Click "Deploy"
- Wait 2-3 minutes
- Your app will be live!
- Open your deployed URL
- Click "Connect Wallet"
- Connect with MetaMask or WalletConnect
- Browse matches and test predictions
# 1. Set environment variables
cp .env.example .env.local
# Edit .env.local and add your WALLETCONNECT_PROJECT_ID
# 2. Build
npm run build
# 3. Start
npm start- Never expose private keys: The app uses wagmi's wallet client
- USDC approval: Users approve only the required amount
- Client-side credential storage: For production, store API credentials securely on the backend
MIT
For issues or questions, please open an issue on GitHub.