Autonomous YES/NO share prediction markets on 0G.
Prophet is a prediction market protocol where every market trades two assets:
YESsharesNOshares
Each share is priced between $0.00 and $1.00 by an on-chain AMM. When the market resolves, the winning share redeems for $1.00 and the losing share redeems for $0.00.
The goal is not to build a simple betting app. Prophet is market infrastructure: protocol-owned liquidity, autonomous market operations, verifiable AI-assisted resolution, and decentralized storage for market memory.
Today's prediction markets — Polymarket, Augur, Manifold — share four structural gaps that have never been closed together:
| Gap | What it means |
|---|---|
| Gatekept creation | Platforms decide which markets exist. A company can't list a prediction on their own product launch. An analyst can't monetize their thesis. A user can't trade their hot take. |
| Public positions | Every bet is visible on-chain the moment it's placed. Whales front-run informed positions. Sophisticated capital stays out. |
| Human resolution | UMA, Augur, Polymarket — someone always casts the deciding vote. Slow. Gameable. No accountability trail. |
| Cold-start liquidity | New markets launch empty. Human LPs don't show up for long-tail questions. Most markets die at 50/50. |
Prophet closes all four with a single protocol: permissionless creation, sealed positions, AI oracle resolution, and autonomous liquidity. All running on 0G infrastructure.
Prediction markets need more than a nice trading UI. They need:
- permissionless market creation — anyone, any question, no approval
- continuous liquidity from day one
- prices that move with demand and slippage
- deterministic settlement with a verifiable evidence trail
- permanent resolution evidence stored and auditable by anyone
- automated market operations that run without human intervention
Prophet uses 0G as the infrastructure layer for that system:
- 0G Chain for market contracts, AMM settlement, and liquidity accounting
- 0G Compute for AI-assisted question validation, oracle reasoning, and market intelligence
- 0G Storage for market metadata, oracle reasoning, agent state, and audit trails
Prophet is already deployed on 0G Galileo testnet. Judges can inspect the core contracts directly on 0G Scan:
| Contract | What It Does | 0G Scan |
|---|---|---|
| ProphetFactory | Deploys and registers new markets | 0xEd51...7bD4 |
| MarketContract | Per-market YES/NO AMM trading and settlement logic | Deployed per market by the factory |
| LiquidityPool | Holds protocol-owned USDT liquidity for autonomous market making | 0x13Ab...DA8e |
| Mock USDT | Testnet collateral used for trading | 0xc2B0...7F49 |
| PositionVault | Sealed/private position infrastructure | 0x89FA...794E |
| PayoutDistributor | Payout distribution support contract | 0x238D...9740 |
Prophet turns any clear YES/NO question into a tradable AMM market.
Example market:
Will it rain tomorrow?
The market has:
YES share
NO share
If the AMM shows:
YES = $0.70
NO = $0.30
then the market is pricing the YES outcome at roughly 70 cents and the NO outcome at roughly 30 cents.
Users can:
- create markets
- buy YES shares
- buy NO shares
- sell YES shares back to the AMM
- sell NO shares back to the AMM
- see wallet USDT balances
- see owned YES/NO share balances
- view AMM share prices in dollars
- redeem winning shares after settlement
The protocol can:
- allocate liquidity from a protocol-owned liquidity pool
- seed market AMM reserves
- collect trading fees
- return unused liquidity and fees after settlement
- use agents to monitor markets, pricing, liquidity health, and resolution state
Implemented:
- YES/NO AMM market contract
- protocol-owned
LiquidityPool - market creation via
ProphetFactory - AMM buy/sell quotes
- AMM share redemption
- cancelled-market neutral redemption
- trading fee accrual
- liquidity allocation and return flow
- frontend trading modal with balances, slippage protection, loading states, and reverted transaction handling
- autonomous market-maker agent with queued transactions
- oracle agent integration path
- 0G Compute diagnostics
- 0G Storage upload/readback diagnostics
Verified locally:
forge test --offline -> 232 passing contract tests
npm run typecheck -> agent TypeScript passes
npm run build -> frontend production build passes
npm run test:storage -> 0G Storage upload/readback passes
npm run test:compute -> 0G Compute live inference passes
After creating the environment files in the Environment Setup section, run:
# 1. Run contract tests
cd contracts
forge test --offline
# 2. Run 0G diagnostics
cd ../agent
npm install
npm run test:storage
npm run test:compute
# 3. Run the frontend
cd ../frontendV2
npm install
npm run devThen open:
http://localhost:3000
+-----------------------------+
| Frontend |
| Next.js + wagmi + viem |
| |
| - create markets |
| - trade YES/NO shares |
| - show AMM prices |
| - show balances |
+--------------+--------------+
|
v
+-------------------+ +---------------+---------------+ +----------------------+
| 0G Storage | | 0G Chain | | 0G Compute |
| | | EVM contracts on 16602 | | |
| - market metadata |<------>| |<------>| - question checks |
| - oracle records | | ProphetFactory | | - oracle inference |
| - price snapshots | | MarketContract | | - pricing rationale |
| - agent state | | LiquidityPool | | - TEE attestation |
| - audit memory | | PositionVault | | |
| | | PayoutDistributor | | |
+-------------------+ +---------------+---------------+ +----------------------+
^
|
+-------------------+-------------------+
| |
v v
+---------------------+ +---------------------+
| Oracle Agent | | Market Maker Agent |
| | | |
| - monitors deadline | | - allocates pool |
| - calls 0G Compute | | - monitors AMM |
| - writes reasoning | | - queues txs |
| - posts verdict | | - returns liquidity |
+---------------------+ +---------------------+
One contract per market.
Responsibilities:
- holds market state
- tracks YES/NO AMM reserves
- prices buys and sells
- stores user YES/NO share balances
- accrues trading fees
- settles winning share redemption
- handles cancelled-market redemption
- returns protocol-owned liquidity after settlement
Important functions:
seedLiquidity(uint256 collateralAmount)
buyShares(bool isYes, uint256 collateralAmount, uint256 minSharesOut)
sellShares(bool isYes, uint256 sharesIn, uint256 minCollateralOut)
redeemWinningShares()
redeemCancelledShares()
getAmmState(address trader)
getBuyAmount(bool isYes, uint256 collateralAmount)
getSellAmount(bool isYes, uint256 sharesIn)Protocol-owned liquidity source.
Responsibilities:
- holds idle USDT
- lets LPs deposit and withdraw
- allows the market-maker agent to allocate liquidity to valid markets
- tracks allocated capital
- records returned principal and fees
Market registry and deployment contract.
Responsibilities:
- creates new market contracts
- validates market addresses
- stores market list for frontend and agents
- wires market contracts to oracle, market-maker, vault, and distributor roles
These support the legacy sealed-position flow and payout distribution path. The current primary user flow is AMM YES/NO share trading, but these contracts remain part of the architecture for private commitments and future sealed-market extensions.
Prophet uses a binary YES/NO AMM with complete-set accounting.
When liquidity is seeded:
USDT collateral enters the market
YES reserve increases
NO reserve increases
Buying YES:
YES reserve decreases
NO reserve increases
YES price rises
NO price falls
Buying NO:
NO reserve decreases
YES reserve increases
NO price rises
YES price falls
Selling shares uses the complete-set invariant so the market does not overpay in imbalanced states.
The sell equation is:
(sameReserve + sharesIn - collateralOut) *
(oppositeReserve - collateralOut)
= sameReserve * oppositeReserve
This keeps pricing continuous, applies slippage, and protects market solvency under thin liquidity and one-sided trading.
The market-maker agent is not a simple trading bot. It acts like an autonomous exchange operator.
It:
- scans existing markets on startup
- listens for new market creation
- reads on-chain AMM reserves
- allocates protocol liquidity from
LiquidityPool - tracks market liquidity tiers
- listens for buy/sell events
- pushes AMM prices to the frontend cache
- queues transactions to avoid nonce collisions
- listens for resolution/cancellation events
- returns settled liquidity back to the pool
- runs a recovery loop so missed events do not strand funds
The flywheel:
Users trade
-> protocol earns fees
-> liquidity pool grows
-> market-maker agent deploys deeper liquidity
-> markets become smoother to trade
-> more users trade
-> more fees accrue
Problem solved:
Prophet needs a fast EVM-compatible settlement layer for market creation, trading, liquidity accounting, and redemption.
Used for:
ProphetFactoryMarketContractLiquidityPoolPositionVaultPayoutDistributor- USDT collateral transfers
- AMM reserve updates
- market lifecycle transitions
- challenge and resolution flow
Network used:
0G Galileo Testnet
Chain ID: 16602
RPC: https://evmrpc-testnet.0g.ai
Explorer: https://chainscan-galileo.0g.ai
Libraries:
- Solidity
0.8.20 - Foundry
- OpenZeppelin
- ethers v6
- viem/wagmi
Problem solved:
Prediction markets need automated intelligence for question validation, resolution reasoning, and market analysis without relying on a centralized AI backend.
SDK/API used:
@0glabs/0g-serving-broker
OpenAI-compatible provider endpoint returned by 0G Compute
Implemented in:
agent/src/shared/compute.ts
agent/src/scripts/test-compute.ts
frontendV2/src/app/api/validate-question/route.ts
Prophet uses 0G Compute for:
- validating whether a market question is clear and resolvable
- suggesting resolution sources
- oracle reasoning at market resolution
- market-maker probability/pricing inference when no AMM price exists yet
- TEE provider attestation checks
- billing header generation for provider requests
Reliability hardening:
- broker caching
- account/ledger bootstrap
- compute ledger top-up support
- provider signer acknowledgement
- TEE attestation verification
- configurable strict TEE mode via
COMPUTE_REQUIRE_TEE=1 - timeout handling
- retry handling
- strict JSON extraction and validation
- confidence threshold enforcement for oracle responses
Problem solved:
Prediction markets need permanent, decentralized, auditable memory for market metadata, oracle reasoning, and agent state.
SDK/API used:
@0gfoundation/0g-storage-ts-sdk
Indexer
MemData
Implemented in:
agent/src/shared/storage.ts
agent/src/scripts/test-storage.ts
frontendV2/src/lib/server/og-storage.ts
frontendV2/src/app/api/store-metadata/route.ts
frontendV2/src/app/api/og-storage/route.ts
Prophet stores:
- market metadata
- resolution source metadata
- AI-generated market overview
- oracle reasoning records
- oracle working state
- market-maker state
- price snapshots
Storage key pattern:
market:{address}:metadata
market:{address}:prices
market:{address}:resolution
market:{address}:payout
agent:oracle:working:{address}
agent:mm:state
Reliability hardening:
- upload retries
- download retries
- Merkle tree generation before upload
- read-after-write verification
- checksum comparison after upload
- temporary file cleanup after downloads
Live diagnostic currently verifies:
- upload to 0G Storage
- download from 0G Storage
- round-trip content match
- market metadata download
aiOverviewpresence in stored metadata
.
├── contracts/
│ ├── src/
│ │ ├── ProphetFactory.sol
│ │ ├── MarketContract.sol
│ │ ├── LiquidityPool.sol
│ │ ├── PositionVault.sol
│ │ └── PayoutDistributor.sol
│ ├── script/Deploy.s.sol
│ └── test/
│
├── agent/
│ └── src/
│ ├── market-maker/index.ts
│ ├── oracle/index.ts
│ ├── shared/compute.ts
│ ├── shared/storage.ts
│ └── scripts/
│ ├── test-compute.ts
│ └── test-storage.ts
│
└── frontendV2/
└── src/
├── app/
├── app/_components/trade-panel.tsx
└── lib/
The repo currently defaults to this 0G Galileo deployment:
| Contract | Address | 0G Galileo Explorer |
|---|---|---|
| Mock USDT | 0xc2B0D2A7e858F13B349843fF87dBF4EBF9227F49 |
View on 0G Scan |
| ProphetFactory | 0xEd51e3d6Ba8914875616bBcDd9aa9D4A00B27bD4 |
View on 0G Scan |
| PositionVault | 0x89FAcA46A2782b4751F697ddFe0A0b9124Eb794E |
View on 0G Scan |
| PayoutDistributor | 0x238D341Bb358AC7C8Ae0A22b35897bECE97b9740 |
View on 0G Scan |
| LiquidityPool | 0x13AbE644693DA19f9A895C8c82Cf53879580DA8e |
View on 0G Scan |
For judging the latest source, redeploy with the steps below and replace these addresses in contracts/.env, agent/.env, and frontendV2/.env.local.
Install:
- Node.js 20+
- npm
- Foundry
- a wallet funded with 0G Galileo testnet tokens
Clone and install:
git clone <repo-url>
cd PROPHET
cd agent
npm install
cd ../frontendV2
npm install
cd ../contracts
git submodule update --init --recursiveCreate contracts/.env:
PRIVATE_KEY=<deployer_private_key>
OG_CHAIN_RPC_TESTNET=https://evmrpc-testnet.0g.ai
OG_CHAIN_RPC_MAINNET=https://evmrpc.0g.ai
USDT_ADDRESS=
ORACLE_AGENT_ADDRESS=<oracle_wallet_address>
MARKET_MAKER_ADDRESS=<market_maker_wallet_address>
PROTOCOL_TREASURY=<treasury_wallet_address>If USDT_ADDRESS is empty, the deploy script deploys MockUSDT and mints test tokens to the deployer.
Create from the example:
cd agent
cp .env.example .envRequired:
PRIVATE_KEY_ORACLE=<oracle_private_key>
PRIVATE_KEY_MM=<market_maker_private_key>
ORACLE_NACL_SECRET_KEY=<optional_for_legacy_sealed_flow>Optional overrides:
OG_CHAIN_RPC=https://evmrpc-testnet.0g.ai
OG_INDEXER_RPC=https://indexer-storage-testnet-turbo.0g.ai
COMPUTE_PROVIDER_ADDRESS=0xa48f01287233509FD694a22Bf840225062E67836
COMPUTE_REQUIRE_TEE=0
STORAGE_VERIFY_WRITES=1PRIVATE_KEY_ORACLE=<server_side_oracle_private_key_for_validation_api>
OG_CHAIN_RPC=https://evmrpc-testnet.0g.ai
OG_INDEXER_RPC=https://indexer-storage-testnet-turbo.0g.ai
COMPUTE_PROVIDER_ADDRESS=0xa48f01287233509FD694a22Bf840225062E67836
NEXT_PUBLIC_PROPHET_FACTORY_ADDRESS=<factory_address>
NEXT_PUBLIC_POSITION_VAULT_ADDRESS=<vault_address>
NEXT_PUBLIC_PAYOUT_DISTRIBUTOR_ADDRESS=<distributor_address>
NEXT_PUBLIC_USDT_ADDRESS=<usdt_address>
NEXT_PUBLIC_LIQUIDITY_POOL_ADDRESS=<pool_address>
NEXT_PUBLIC_ORACLE_NACL_PUBLIC_KEY=<public_key_for_legacy_sealed_flow>Never commit real private keys.
cd contracts
forge test --offlineExpected:
232 tests passed
cd agent
npm run typecheckcd frontendV2
npm run buildFrom contracts/:
forge script script/Deploy.s.sol:DeployProphet \
--rpc-url og_testnet \
--broadcast \
--legacy \
--gas-price 3000000000 \
-vvvThe deploy script prints:
USDT_ADDRESS
PROPHET_FACTORY_ADDRESS
POSITION_VAULT_ADDRESS
PAYOUT_DISTRIBUTOR_ADDRESS
LIQUIDITY_POOL_ADDRESS
Copy those into:
contracts/.env
agent/.env
frontendV2/.env.local
frontendV2/src/lib/contracts.ts, if you want defaults updated
agent/src/shared/config.ts, if you want defaults updated
Then regenerate frontend ABIs after contract changes from the repo root:
cd ..
node -e 'const fs=require("fs"); for (const n of ["MarketContract","LiquidityPool","ProphetFactory","PositionVault","PayoutDistributor"]) { const artifact=JSON.parse(fs.readFileSync("contracts/out/"+n+".sol/"+n+".json","utf8")); fs.writeFileSync("frontendV2/src/lib/abis/"+n+".json", JSON.stringify({abi: artifact.abi})); }'Start the frontend:
cd frontendV2
npm run devOpen:
http://localhost:3000
Start both agents:
cd agent
npm run startOr run individually:
npm run oracle
npm run market-makerRun these before judging/demoing.
cd agent
npm run test:storageThis verifies:
- 0G Chain RPC connection
- wallet balance
- 0G Storage upload
- 0G Storage download
- round-trip data integrity
- market metadata availability
cd agent
npm run test:computeThis verifies:
- 0G Chain RPC connection
- broker creation
- compute ledger account
- provider metadata
- TEE attestation
- billing headers
- live inference response
- JSON parsing
Use the 0G Galileo testnet faucet:
https://faucet.0g.ai
Fund:
- deployer wallet
- oracle wallet
- market-maker wallet
- any wallet used by judges to test the frontend
When using the deployed MockUSDT, open the app and go to:
/faucet
Connect a wallet and claim:
50 mock USDT
The faucet is for testnet only and has no real value.
- Connect wallet on 0G Galileo.
- Claim mock USDT from
/faucet. - Create a market.
- Wait for the market-maker agent to allocate liquidity.
- Open the market page.
- Buy YES or NO shares.
- Observe share price moving between
$0.00and$1.00. - Sell a portion of shares back to the AMM.
- Run the oracle/market-maker agents to process resolution and liquidity return flows.
Recommended demo order:
- Show the dashboard and market list.
- Create a new market question.
- Show 0G Compute validating the question.
- Show metadata written to 0G Storage.
- Show the market-maker agent detecting the market.
- Show protocol liquidity allocation.
- Buy YES/NO shares and show AMM price movement.
- Show user share balances and USDT balances.
- Run
npm run test:storageto prove 0G Storage upload/readback. - Run
npm run test:computeto prove 0G Compute provider, TEE attestation, billing headers, and live inference.
Prophet is designed around these constraints:
- liquidity is finite
- large trades must create slippage
- YES and NO prices must remain bounded between
$0and$1 - the AMM must not create claims that collateral cannot satisfy
- resolution must be deterministic
- agent failures must be recoverable
- storage and compute integrations must fail loudly and verifiably
Current hardening:
- non-reentrant contract paths
- slippage protection on frontend trades
- conservative AMM rounding
- queued market-maker transactions
- recovery loop for missed settlement events
- 0G Storage read-after-write checksum verification
- 0G Compute timeout/retry/JSON validation
- optional strict TEE enforcement
Most prediction markets depend on human market creation, human liquidity providers, and human resolution committees.
Prophet pushes these responsibilities into autonomous infrastructure:
market creation -> assisted by 0G Compute
market memory -> stored on 0G Storage
market trading -> handled by on-chain YES/NO AMM
liquidity -> managed by autonomous market-maker agent
resolution -> assisted by oracle agent using 0G Compute
audit trail -> persisted through 0G Storage
settlement -> enforced by 0G Chain contracts
That is the core hackathon thesis:
0G is not just a chain Prophet deploys to. 0G is the compute, storage, and settlement substrate that makes autonomous prediction market infrastructure possible.