ShadowMarket
Encrypted prediction markets with Chainlink-powered settlement and resolution.
What it is
ShadowMarket is a privacy-preserving prediction market built for the Chainlink CRE Hackathon. It is designed to solve one of the biggest problems in onchain markets: order intent leaks before execution. In most prediction markets, visible orders can be copied, front-run, or used to manipulate price discovery. ShadowMarket changes that by letting traders submit encrypted orders instead of plaintext orders.
Here’s how it works:
- Users deposit collateral onchain
- Users submit encrypted orders to the market contract
- Orders are grouped into epochs instead of being matched one by one in public
- Chainlink Automation detects when an epoch is ready to settle or when a market is ready to resolve
- A Chainlink CRE settlement workflow fetches the epoch’s orders, sends them to an auction service, and computes the clearing price and net trader outcomes offchain
- The contract finalizes the epoch onchain using a Merkle-root-based settlement report
- Traders then claim their own settlement with a Merkle proof
- After trading ends, a Chainlink CRE resolution workflow fetches the market question and offchain resolution context, returns the final outcome plus an evidence hash, and finalizes the market onchain
- Once all required settlements are claimed, users can redeem winnings
This architecture solves two problems at once:
- Execution quality and privacy: traders can express views without exposing their order details before clearing
- Resolution trust: final market outcomes are handled through an auditable offchain resolution workflow that writes a structured report back onchain, instead of relying on a simplistic hardcoded oracle path
In short, ShadowMarket combines private order flow, event-driven Chainlink workflows, and onchain settlement guarantees to make prediction markets more fair, more credible, and more usable.
How it Works
ShadowMarket is built as a privacy-preserving prediction market with a clean separation between onchain state custody and offchain private computation.
Core architecture
- Onchain: PrivatePredictionMarket.sol handles collateral custody, encrypted order storage, epoch state tracking, position accounting, and final settlement. All user funds and final state transitions live here.
- Offchain via Chainlink CRE: Private order handling, matching logic, and market resolution run as CRE workflows. CRE fetches encrypted orders, calls external services (auction service for matching, resolution service for outcomes), and delivers cryptographically signed reports back onchain.
- Automation: Chainlink Automation triggers epoch settlements and resolution requests when timing conditions are met, keeping onchain execution lightweight.
The flow
- Deposit → user locks collateral onchain
- Encrypt → frontend encrypts order intent client-side to the auction service public key
- Submit → ciphertext stored onchain via submitEncryptedOrder
- Settle → Automation requests settlement; CRE workflow fetches orders, runs offchain matching, returns clearing price and Merkle root
- Claim → users claim settlement results with Merkle proofs
- Resolve → post-trading, Automation requests resolution; CRE fetches offchain outcome data and delivers resolution report
- Redeem → winning side redeems after claiming all settlements
Why this split matters
Onchain keeps the guarantees: custody, auditability, finality. Offchain via CRE keeps the sensitive computation private: order decryption, matching, external data fetching. This gives users privacy before execution without sacrificing onchain trust after settlement.- Stack: Solidity/Foundry for contracts, Node.js services for auction/resolution, Next.js/React frontend with wagmi/viem, Chainlink CRE and Automation for offchain workflows and triggering.
Links
Created by
- Deepak