On-chain prediction markets & 15-minute speed markets on HashKey Chain
HashPredict is built for the HashKey Chain Horizon Hackathon. It demonstrates a full-stack prediction market platform deployed entirely on HashKey Chain Testnet, showcasing:
- DeFi innovation — CPMM-based binary options with automated market making
- Gasless UX — ERC-2771 meta-transactions so users never pay gas
- Real-time infrastructure — Automated keeper bot + Pyth oracle streaming
- Production readiness — End-to-end trading, resolution, and settlement
Connect a wallet to HashKey Chain Testnet (Chain ID 133). Use the Faucet page to get test USDT, then trade on any market.
HashPredict is a decentralized prediction market platform where users bet on the outcome of real-world events using USDT on HashKey Chain.
It offers two types of markets:
- Prediction Markets — Long-term binary markets (e.g., "Will BTC hit $100,000 by June 2026?") with YES/NO outcome tokens and CPMM pricing
- Speed Markets — 60-minute binary options on live crypto prices (BTC, ETH, SOL). Predict whether the price goes UP or DOWN from the strike price. New markets are created automatically every 60 minutes by a keeper bot.
All trades are gasless through an embedded wallet and ERC-2771 relayer — no MetaMask popups, no gas fees.
1. Browse Markets → Pick a market (e.g., "Will BTC hit $100k?")
2. Buy YES or NO → Spend USDT to buy outcome tokens via CPMM
3. Wait for Result → Oracle resolves the market after deadline
4. Claim Winnings → Winners redeem tokens 1:1 for USDT
1. Pick an Asset → BTC, ETH, or SOL
2. See Strike Price → Current Pyth oracle price at market creation
3. Buy UP or DOWN → Predict if price goes above or below strike
4. Auto-Resolution → Keeper bot resolves after 60 minutes using Pyth
5. Claim if You Won → Winners get ~1.87x payout
User creates embedded wallet (localStorage)
→ Signs EIP-2612 permit (approve USDT)
→ Signs EIP-712 ForwardRequest (trade)
→ Relayer submits both on-chain
→ User pays $0 gas
┌─────────────────────────────────────────────────────────────┐
│ HashKey Chain Testnet │
│ │
│ ┌─────────────────┐ ┌──────────────────┐ ┌────────────┐ │
│ │ MarketFactory │ │ SpeedMarketAMM │ │ MockUSDT │ │
│ │ + Prediction │ │ (monolithic, │ │ (6 dec, │ │
│ │ Market (each) │ │ all markets │ │ EIP-2612 │ │
│ │ + OutcomeToken │ │ in one contract)│ │ permit) │ │
│ └────────┬────────┘ └───────┬──────────┘ └─────┬──────┘ │
│ │ │ │ │
│ └───────────────────┼────────────────────┘ │
│ │ │
│ ┌────────────────┴──────────────┐ │
│ │ ERC2771Forwarder │ │
│ │ (gasless meta-tx relay) │ │
│ └────────────────┬──────────────┘ │
└───────────────────────────────┼───────────────────────────────┘
│
┌──────────────┼──────────────┐
│ │ │
┌──────┴──────┐ ┌────┴─────┐ ┌──────┴──────┐
│ Frontend │ │ Keeper │ │ Relayer │
│ (Next.js) │ │ Bot │ │ (API route)│
│ │ │ │ │ │
│ - Markets │ │ - Create │ │ - Execute │
│ - Speed │ │ slots │ │ meta-tx │
│ - Trade │ │ - Resolve│ │ - Permit │
│ - Portfolio │ │ - Recycle│ │ relay │
│ - Charts │ │ LP │ │ │
└─────────────┘ └──────────┘ └─────────────┘
│
┌──────┴──────┐
│ Pyth Hermes │
│ (price │
│ oracle) │
└─────────────┘
| Layer | Technology | Version |
|---|---|---|
| Smart Contracts | Solidity + OpenZeppelin | 0.8.24 |
| Contract Tooling | Foundry (forge, cast) | Latest |
| Frontend | Next.js + React | 16.2.3 / 19.2.4 |
| Blockchain Interaction | wagmi + viem | 3.6.1 / 2.47.12 |
| Wallet Connect | RainbowKit | 2.2.10 |
| Charts | Recharts | 3.8.1 |
| Keeper Bot | Node.js + viem + node-cron | - |
| Price Oracle | Pyth Network (Hermes API + SSE) | - |
| Chain | HashKey Chain Testnet | Chain ID 133 |
| Styling | Tailwind CSS v4 | 4.x |
All contracts are deployed on HashKey Chain Testnet:
| Contract | Address | Purpose |
|---|---|---|
| MarketFactory | 0x04D068D15cfe5F75103a0345e267C876411FcE91 |
Creates and tracks prediction markets |
| SpeedMarketAMM | 0x108695f4B62d8964A06e1aaDA65FB3317737b2ac |
Monolithic speed market with CPMM |
| MockUSDT | 0x8065Fec351216Fbd636dc3216884A2eDbBdE1bE2 |
ERC-20 collateral token (6 decimals, EIP-2612) |
| ERC2771Forwarder | 0x8844fF945204c986c78b4Fe6d942a1C7797f76c5 |
Gasless meta-transaction relay |
| SupraResolver | 0xfdB2eC399c9Fb0a1b815B3B1229D4b9806D602b4 |
Oracle-based market resolution |
- CPMM (Constant Product Market Maker):
k = reserveYes * reserveNofor binary option pricing with 2% fee - Monolithic SpeedMarketAMM: All speed markets in one contract via
mapping(uint256 => SpeedMarket)— cheaper than deploying per-market contracts for 60-min lifespan - Internal balance tracking: Speed markets use
upBalances[marketId][user]instead of ERC-20 outcome tokens — saves gas for short-lived markets - ERC-2771 gasless:
_msgSender()throughout for meta-transaction support via trusted forwarder
- Binary Prediction Markets — YES/NO markets with CPMM automated market making
- 60-Minute Speed Markets — Real-time binary options on BTC/ETH/SOL with live Pyth price feeds
- Gasless Trading — Embedded wallet + ERC-2771 forwarder + EIP-2612 permits = zero gas for users
- Automated Keeper Bot — Creates new speed markets every 60 min, resolves expired ones using Pyth settlement prices, recycles liquidity
- Live Price Charts — Real-time SSE streaming from Pyth with Polymarket-style chart UI
- On-chain Leaderboard — Rankings computed from actual Buy/Sell/Claim events across all markets
- Portfolio Tracking — View all positions across prediction and speed markets with claim support
- Cyberpunk UI — Glassmorphism, neon glow effects, animated floating elements
git clone https://github.com/YOUR_USERNAME/HashKey-Chain-Horizon-Hackathon.git
cd HashKey-Chain-Horizon-Hackathoncd contracts
forge install
forge build
# Deploy (set your private key)
export PRIVATE_KEY=0x...
forge script script/DeployAll.s.sol --rpc-url https://testnet.hsk.xyz --broadcast
forge script script/DeploySpeedMarket.s.sol --rpc-url https://testnet.hsk.xyz --broadcast# Frontend
cp frontend/.env.local.example frontend/.env.local
# Update contract addresses in .env.local
# Keeper
cp keeper/.env.example keeper/.env
# Update KEEPER_PRIVATE_KEY, SPEED_MARKET_ADDRESS, etc.cd keeper
npm install
npm run dev
# Logs: Creating BTC slot... Creating ETH slot... Creating SOL slot...cd frontend
npm install
npm run dev
# Open http://localhost:3000Visit /faucet in the app or:
cast send 0x8065Fec351216Fbd636dc3216884A2eDbBdE1bE2 "faucet(uint256)" 10000000000 \
--rpc-url https://testnet.hsk.xyz --private-key $PRIVATE_KEYHashKey-Chain-Horizon-Hackathon/
├── contracts/ # Solidity smart contracts (Foundry)
│ ├── src/
│ │ ├── MarketFactory.sol
│ │ ├── PredictionMarket.sol
│ │ ├── SpeedMarketAMM.sol
│ │ ├── OutcomeToken.sol
│ │ ├── MockUSDT.sol
│ │ └── SupraResolver.sol
│ └── script/ # Deployment scripts
├── frontend/ # Next.js 16 web app
│ ├── src/app/ # Pages (markets, speed, portfolio, etc.)
│ ├── src/components/ # React components
│ ├── src/hooks/ # Custom hooks (wagmi, Pyth, trade)
│ └── src/lib/ # Utilities, ABIs, contract config
├── keeper/ # Automated keeper bot
│ └── src/
│ ├── jobs/ # createSlot, resolveSlots, recycleLiquidity
│ ├── monitoring/ # Health check server
│ └── index.ts # Cron scheduler
└── README.md
MIT