A Flare-based, trust-minimized platform for creating and settling multi-leg parlays using a state channels hub-and-spoke model.
out.mp4
ParlayMarket allows users to create and settle parlays on blockchain-based outcome markets with instant, low-cost collateralization. It leverages a hybrid smart contract and state channel design for rapid, off-chain interaction and final on-chain settlement.
- Multi-leg parlays with ERC-721 tokens representing each position (YES/NO)
- Trust-minimized oracle resolution (UMA, Flare Data Connector)
- Maker determines odds and stake ratios
- Fast and cancellable orders before filling
- Fully non-custodial
- Modular smart contract design
- Comprehensive test scenarios and step-by-step deployment guides
- Solidity 0.8.20
- ParlayMarket - Main contract managing parlay lifecycle
- ParlayToken - ERC-721 for tradable positions
- FlarePolymarketOracle - Oracle using Flare Data Connector (FDC)
- Node.js >= 18
- MetaMask
- Flare Coston2 testnet tokens (faucet link)
git clone <your-repo-url>
git checkout dev2
npm install # or pnpm install
npm run devVisit http://localhost:3000.
- See
/scripts/deploy.mdorDEPLOYMENT.mdfor contract deployment instructions using Hardhat. - Set deployed contract addresses in
lib/contracts.ts. - Quick deploy:
npx hardhat run scripts/deploy.ts --network coston2
parlaymarket/
├── app/ # Next.js pages
│ ├── page.tsx # Home page
│ ├── create/ # Create parlay page
│ ├── browse/ # Browse all parlays
│ ├── parlay/[id]/ # Individual parlay details
│ └── my-parlays/ # User's parlays
├── components/ # React components
│ ├── Navigation.tsx # Top navigation bar
│ ├── WalletConnect.tsx # Wallet connection button
│ ├── ParlayCard.tsx # Parlay card display
│ └── LoadingSpinner.tsx # Loading indicator
├── contracts/ # Solidity smart contracts
│ ├── ParlayMarket.sol # Main parlay contract
│ ├── ParlayToken.sol # ERC-721 position tokens
│ ├── FlarePolymarketOracle.sol # FDC-integrated oracle
│ └── interfaces/ # Contract interfaces
├── hooks/ # React hooks
│ ├── useWeb3.ts # Web3 connection hook
│ └── useParlays.ts # Parlay data fetching
├── lib/ # Utilities
│ ├── contracts.ts # Contract addresses & ABIs
│ └── web3.ts # Web3 helper functions
└── scripts/ # Deployment scripts
└── deploy.md # Deployment guide
graph LR
A[Created] -->|Taker Fills| B[Filled]
A -->|Expiry| C[Cancelled]
B -->|All Markets Resolved| D[Resolved]
B -->|Invalid Market| E[Invalid]
States:
- Created - Maker deposited, waiting for taker
- Filled - Both sides funded, tokens minted
- Resolved - Settled, winner paid out
- Cancelled - Unfilled after expiry, stake returned
- Invalid - One or more markets resolved as invalid, both sides refunded
The codebase is modular and easy to extend:
- Add new oracle sources: Implement
IPolymarketOracleinterface - Add filters/search: Enhance
browse/page.tsxwith filters - Add analytics: Create dashboard pages with stats
# With Hardhat
npx hardhat test
# With Foundry
forge testFlarePolymarketOracle integrates with Flare's Data Connector (FDC) to fetch and verify Polymarket UMA resolution data on-chain.
const oracle = new ethers.Contract(ORACLE_ADDRESS, ABI, signer);
// Submit outcome with FDC attestation
await oracle.submitOutcome(
umaId, // Polymarket UMA question ID
outcome, // 0=NO, 1=YES, 2=INVALID
attestationData, // FDC attestation data
merkleProof // Merkle proof for verification
);For testing without FDC attestation, the oracle owner can set outcomes directly:
const oracle = new ethers.Contract(ORACLE_ADDRESS, ABI, signer);
// Direct outcome setting (owner only)
await oracle.setOutcomeDirect(umaId, 1); // 1 = YES, 0 = NO, 2 = INVALID
// Batch setting
await oracle.setOutcomesBatch([umaId1, umaId2], [1, 0]);- Submit Attestation Request to FDC Hub for Polymarket UMA data
- Wait for Finalization (typically ~90 seconds on Coston2)
- Retrieve Attestation Data from Data Availability Layer
- Submit to Oracle with proof using
submitOutcome() - Oracle Verifies proof via FDC Verification contract
- Outcome Stored and available for parlay resolution
For detailed FDC integration guide, see Flare FDC Documentation.
MIT License - see LICENSE file
- Flare Network: https://flare.network/
- Flare Docs: https://docs.flare.network/
- UMA Protocol: https://docs.umaproject.org/
- Polymarket: https://polymarket.com/
- Next.js: https://nextjs.org/docs
- Connect your wallet and switch to the Flare Coston2 network when prompted.
- Create a parlay with custom markets and stakes.
- Fill a parlay (as a taker).
- Settle when the oracle resolves the referenced events.
- Position tokens are fully tradable until settlement.




