Skip to content

Zireaelst/Mirage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

32 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

β—ˆ Mirage Market

A sybil-resistant, privacy-preserving prediction market protocol powered by Chainlink CRE and World ID.

πŸ† Built for Convergence: A Chainlink Hackathon


πŸ“‹ Project Description

Mirage Market is a prediction market protocol where positions are hidden, identities are verified, and settlements are automated.

The Problem: Existing prediction markets expose user positions publicly, enabling front-running, social pressure, and privacy violations. Most markets also rely on centralized resolution oracles that can be manipulated.

Our Solution:

  1. Privacy-Preserving Commitments β€” Users commit positions as encrypted hashes (commit-reveal scheme). Amounts and choices remain hidden until settlement.
  2. Sybil Resistance β€” World ID verification via Chainlink CRE ensures one-person-one-vote without exposing personal data on-chain.
  3. Automated AI Settlement β€” When a market closes, a CRE workflow fetches real-world data via Confidential HTTP, resolves the outcome deterministically, and writes the settlement on-chain β€” no human oracle needed.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        MIRAGE MARKET                         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚  Next.js 14  │────▢│  Ethereum Sepolia Smart Contractsβ”‚    β”‚
β”‚  β”‚  App Router  β”‚     β”‚                                 β”‚    β”‚
β”‚  β”‚  + Wagmi v2  β”‚     β”‚  β€’ ShadowMarketV2.sol           β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚  β€’ IdentityGate.sol             β”‚    β”‚
β”‚        β”‚              β”‚  β€’ PrivatePayouts.sol            β”‚    β”‚
β”‚        β”‚              β”‚  β€’ SettlementReceiver.sol        β”‚    β”‚
β”‚        β–Ό              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                   β”‚                         β”‚
β”‚  β”‚  World ID   β”‚                   β”‚                         β”‚
β”‚  β”‚  IDKit v2   β”‚                   β–Ό                         β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚         β”‚            β”‚     CHAINLINK CRE (DON)          β”‚    β”‚
β”‚         β”‚            β”‚                                   β”‚    β”‚
β”‚         └───────────▢│  Identity Workflow:               β”‚    β”‚
β”‚                      β”‚    HTTP β†’ WorldID API β†’ onchain   β”‚    β”‚
β”‚                      β”‚                                   β”‚    β”‚
β”‚                      β”‚  Settlement Workflow:              β”‚    β”‚
β”‚                      β”‚    EVM Log β†’ Confidential HTTP     β”‚    β”‚
β”‚                      β”‚    β†’ Deterministic Resolve         β”‚    β”‚
β”‚                      β”‚    β†’ onchain write                 β”‚    β”‚
β”‚                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”— Chainlink Integration β€” File Links

All files that use Chainlink CRE:

CRE Workflows

File Purpose
settlement-workflow/main.ts Core CRE workflow β€” EVM log trigger β†’ Confidential HTTP (CoinGecko) β†’ deterministic resolution β†’ SettlementReceiver onchain write
settlement-workflow/workflow.yaml Workflow definition β€” triggers, consensus (identical), targets
settlement-workflow/cre.config.json Runtime configuration β€” contract addresses, chain, API URL
identity-workflow/main.ts Identity CRE workflow β€” HTTP trigger β†’ World ID API verify β†’ IdentityGate onchain write
identity-workflow/workflow.yaml Workflow definition β€” HTTP trigger, identical consensus
identity-workflow/cre.config.json Runtime configuration β€” World ID app ID, IdentityGate address

Smart Contracts (Chainlink CRE Targets)

File Purpose
SettlementReceiver.sol Receives settlement data from CRE DON β†’ calls settleMarket() on ShadowMarketV2
ShadowMarketV2.sol V2 market contract β€” upgraded with CRE-compatible settlement + proportional claims

Frontend (Chainlink-Related UI)

File Purpose
settlements/page.tsx Settlements feed showing CRE workflow activity and tx hashes
contracts.ts ABI definitions + Sepolia addresses for all CRE-connected contracts

πŸ› οΈ Tech Stack

Layer Technology
Frontend Next.js 14 (App Router), TypeScript, Tailwind CSS
Wallet Wagmi v2, viem, WalletConnect
Identity World ID (IDKit v2), Chainlink CRE Identity Workflow
Oracle / Settlement Chainlink CRE (TypeScript SDK β†’ WASM), Confidential HTTP
Smart Contracts Solidity 0.8.24, Hardhat, OpenZeppelin
Network Ethereum Sepolia Testnet
Privacy Commit-Reveal scheme, Merkle proof payouts

πŸ“¦ Smart Contracts (Sepolia Testnet)

Deployed on: 2026-03-04
Deployer: 0x6602130E170195670407CeE93932C1B0b9454aDD

Contract Address Etherscan
IdentityGate 0x50DF50C761bA75Da4d5edf29943e7da310A8E135 View
ShadowMarketV2 0x54576aC5a0cF7566287d7fcb410c8f523357889d View
PrivatePayouts 0x34eb886073984C7c3a063351530D057886FA78Af View
SettlementReceiver 0x25Fb1b433Db1dFAfF1C73Dd189E7183d8fDe0FC4 View
WorldID Router 0x469449f251692e0779667583026b5a1e99512157 View

πŸš€ How to Run

Prerequisites

  • Node.js v18+
  • Bun v1.3+ (for CRE workflows)
  • CRE CLI (curl -sSL https://cre.chain.link/install.sh | bash)

1. Install Dependencies

npm install

2. Environment Setup

cp .env.example .env
# Fill in:
#   NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID
#   NEXT_PUBLIC_WORLD_ID_APP_ID
#   PRIVATE_KEY (for contract deployment)

3. Run Frontend (Dev)

cd apps/web
npm run dev
# β†’ http://localhost:3000

4. Deploy Contracts

cd packages/contracts
npx hardhat run scripts/deploy.ts --network sepolia

5. Simulate CRE Workflow

# Install CRE CLI
curl -sSL https://cre.chain.link/install.sh | bash

# Login to CRE
cre login

# Simulate Settlement Workflow
cd cre-workflows/settlement-workflow
bun install
cre workflow simulate .

# Simulate Identity Workflow
cd ../identity-workflow
bun install
cre workflow simulate .

πŸ“‚ Repository Structure

mirage/
β”œβ”€β”€ apps/web/                        # Next.js 14 frontend
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ markets/[id]/            # Market detail + commit position
β”‚   β”‚   β”œβ”€β”€ markets/[id]/reveal/     # Reveal & claim winnings
β”‚   β”‚   β”œβ”€β”€ markets/create/          # Create new market
β”‚   β”‚   β”œβ”€β”€ portfolio/               # User portfolio dashboard
β”‚   β”‚   └── settlements/             # CRE settlement feed
β”‚   β”œβ”€β”€ components/web3/             # WorldIDButton, CommitPosition, ClaimWinnings
β”‚   └── lib/                         # contracts.ts, types.ts, wagmi.ts
β”œβ”€β”€ packages/contracts/              # Solidity smart contracts
β”‚   β”œβ”€β”€ contracts/
β”‚   β”‚   β”œβ”€β”€ ShadowMarketV2.sol       # V2 prediction market
β”‚   β”‚   β”œβ”€β”€ IdentityGate.sol         # World ID sybil gate
β”‚   β”‚   β”œβ”€β”€ PrivatePayouts.sol       # Merkle proof payouts
β”‚   β”‚   └── SettlementReceiver.sol   # CRE settlement target
β”‚   └── scripts/deploy.ts           # Hardhat deployment script
β”œβ”€β”€ cre-workflows/                   # β˜… Chainlink CRE Workflows
β”‚   β”œβ”€β”€ settlement-workflow/         # EVM Log β†’ API β†’ Settle
β”‚   β”‚   β”œβ”€β”€ main.ts                  # Handler logic (CRE SDK)
β”‚   β”‚   β”œβ”€β”€ workflow.yaml            # Workflow definition
β”‚   β”‚   └── cre.config.json          # Runtime config
β”‚   └── identity-workflow/           # HTTP β†’ WorldID β†’ Onchain
β”‚       β”œβ”€β”€ main.ts                  # Handler logic (CRE SDK)
β”‚       β”œβ”€β”€ workflow.yaml            # Workflow definition
β”‚       └── cre.config.json          # Runtime config
└── README.md

πŸ† Prize Tracks

Track How Mirage Qualifies
Chainlink CRE & AI ($17k) Settlement workflow uses CRE with Confidential HTTP, deterministic resolution, and EVM log triggers
Prediction Markets ($16k) Full prediction market with commit-reveal privacy, proportional payouts, and automated settlement
Privacy ($16k) Encrypted commitments, Merkle proof payouts, Confidential HTTP β€” positions never visible on-chain
World ID + CRE ($5k) Identity workflow brings World ID verification to Sepolia via CRE, enabling sybil resistance on any chain

πŸ“ License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors