Next.js 14 + Prisma dashboard for Polymarket markets.
- Install deps:
npm install - Set
DATABASE_URLto a Postgres connection string (required in all environments). - Copy
.env.exampleto.envand update:DATABASE_URL="postgresql://USER:PASSWORD@HOST:5432/DB?sslmode=require"
- Set user-wallet trading config in
.env.localor deployment env:ENABLE_TRADING=truePOLYMARKET_BUILDER_CODE=0x...POLYPICKS_SESSION_SECRET=...(32+ chars)
- Do not set
POLYMARKET_PRIVATE_KEYfor normal trading. Users sign orders from connected wallets. - Optional admin/reporting credentials:
POLYMARKET_API_KEY,POLYMARKET_SECRET, andPOLYMARKET_PASSPHRASEare only used by builder analytics/reporting utilities.POLYMARKET_PRIVATE_KEYis only used by local live-attribution/admin scripts.
- Server-only builder relayer credentials:
POLYMARKET_BUILDER_API_KEY,POLYMARKET_BUILDER_SECRET, andPOLYMARKET_BUILDER_PASSPHRASEare used only by/api/polymarket/submitto forward user-signed Safe/proxy/deposit-wallet transactions to Polymarket relayer/submit.- Do not configure wallet-scoped relayer credentials for the builder submit path, and never expose builder credentials with
NEXT_PUBLIC_.
- Optional client flags:
NEXT_PUBLIC_CLOB_DEBUG=falseNEXT_PUBLIC_POLY_RELAYER_URL=NEXT_PUBLIC_POLY_SIGNATURE_TYPE=3for new deposit-wallet users. Use1or2only for legacy proxy/Safe accounts.POLYMARKET_DATA_API_BASE_URL=https://data-api.polymarket.com
- For soccer stats, set
FOOTBALL_DATA_API_KEYin.env.local(local dev) or Vercel Project Settings → Environment Variables. - Generate Prisma client:
npx prisma generate - Start dev server:
npm run dev
- Set
DATABASE_URLin Project Settings to your Postgres connection string. - Run migrations in production:
- Vercel will auto-run
npm run vercel-buildif present. vercel-buildruns migrations only whenVERCEL_ENV=production.- Optional: set
ALLOW_DB_RESET_ON_FAILED_MIGRATIONS=1to auto-reset a fresh database on failed migrations.
- Vercel will auto-run
- Do not run
prisma db pullagainst production; it can overwriteprisma/schema.prismaand drop models that are not yet present in the database. - For user-wallet trading deployments, the required trading runtime vars are only
ENABLE_TRADING=true,POLYMARKET_BUILDER_CODE, andPOLYPICKS_SESSION_SECRET. Server-side Polymarket API credentials and private keys are optional admin/reporting inputs, not trading blockers. - For relayer-backed Safe/proxy/deposit-wallet transactions, configure server-only Builder API credentials:
POLYMARKET_BUILDER_API_KEY,POLYMARKET_BUILDER_SECRET, andPOLYMARKET_BUILDER_PASSPHRASE.
The app uses the Polymarket Gamma/Data API and an optional RTDS WebSocket for live prices.
Builder-attributed trading uses CLOB V2 builderCode. The browser fetches the server-configured bytes32 code before signing, the SDK serializes it into the final order builder field, and the server rejects posts where that field is missing or mismatched.
Order signing defaults to Polymarket V2 deposit-wallet signature type 3 (POLY_1271). Existing proxy/Safe wallets can still use their legacy type (1 or 2). Browser user trades do not use normal EOA type 0.