This page is written for 0G Labs judges evaluating Track 2 (Agentic Trading Arena). It documents every 0G module Prophet uses, the specific SDK calls, the implementation files, and why each integration is non-superficial.
Integration Summary
Prophet integrates three distinct 0G modules. Each module is used because the product cannot work without it — removing any one of them makes the system either centralized, unverifiable, or non-functional.0G Chain
Why 0G Chain Specifically
Ethereum is economically infeasible for Prophet. The oracle agent submits multiple transactions per market resolution (postResolution, revealPositions). At Ethereum L1 gas prices, a single resolution cycle would cost 200. This makes the oracle economically unviable for any market under $10,000 in volume. 0G Chain provides:- 11,000 TPS — high enough to handle many concurrent market resolutions
- Sub-second finality — oracle reads resolution events quickly
- Low gas cost — oracle can submit transactions economically
- EVM-compatible — all existing Solidity tooling works without modification
- Chain ID 16602 (Galileo testnet) / 16600 (mainnet)
What Runs on 0G Chain
Every contract in Prophet lives on 0G Chain:ProphetFactory.sol— market registry and factoryMarketContract.sol— per-market AMM and lifecycleLiquidityPool.sol— protocol-owned liquidityPositionVault.sol— encrypted position storagePayoutDistributor.sol— payout calculation and distribution
createMarket()— ProphetFactorybuyShares(),sellShares()— MarketContractcommitPosition()— PositionVaulttriggerResolution(),postResolution(),finalizeResolution()— MarketContractrevealPositions()— PositionVaultredeemWinningShares()— MarketContract
Client SDKs
Frontend: wagmi v2 + viem configured for 0G Chain:0G Compute
The Problem It Solves
Prophet’s oracle is only trustworthy if it is decentralized. A centralized AI backend (OpenAI, Anthropic API) would make the oracle dependent on a single company’s uptime, pricing, and content policies. A single API key could be revoked, censored, or rate-limited — killing every market resolution simultaneously. 0G Compute provides decentralized, pay-per-use AI inference with TEE attestation — no single company controls it, and the inference provider cannot fake results without the TEE attestation being invalidated.SDK and Implementation
agent/src/shared/compute.ts— broker initialization, provider management, inference functionagent/src/scripts/test-compute.ts— integration test scriptfrontendV2/src/app/api/validate-question/route.ts— server-side question validation endpoint
Use Case 1: Question Validation at Market Creation
When a user creates a market, the frontend sends the question to/api/validate-question. This Next.js API route calls 0G Compute to determine if the question:
- Is binary (can only resolve YES or NO)
- Is specific and unambiguous
- Has a clear resolution criterion
- Is verifiable by public evidence
{ valid: bool, reason: string, suggestedSources: string[] }.
Invalid questions are rejected before the market is created — saving gas and preventing unresolvable markets from entering the system.
Use Case 2: Oracle Resolution at Deadline
The primary use. AftertriggerResolution is called, the oracle agent:
Use Case 3: Market Pricing Inference
The market-maker agent calls 0G Compute to get an initial price estimate for each new market — before any trades have occurred. The model assesses the market question and returns a starting YES probability, which the agent uses to set the initial AMM seed ratio.Provider Details
TEE Attestation
broker.verifyService(providerAddress) checks that the inference provider is running inside a TEE and that the TEE environment matches the published configuration. With COMPUTE_REQUIRE_TEE=1, the oracle will refuse to post a verdict if TEE verification fails.
Billing Headers
The 0G Compute SDK handles billing automatically via payment headers attached to each API request. The oracle agent’s wallet funds the ledger; the SDK deducts per-token costs. This means the oracle pays for its own compute in $0G — no monthly API bills, no vendor relationship.Reliability Design
The compute integration includes:- Retry on timeout: inference calls retry up to 3 times with exponential backoff
- JSON extraction: if the model returns markdown-wrapped JSON, the parser strips the fences before parsing
- Confidence threshold: responses below 70% confidence trigger a second pass rather than posting a low-confidence verdict
0G Storage
The Problem It Solves
Prediction markets live and die on oracle credibility. If the oracle posts a verdict but no one can verify why, the market is no more trustworthy than a human committee. 0G Storage provides permanent, decentralized, tamper-proof storage where the oracle’s full reasoning chain can live forever. The root hash stored on-chain commits to the exact content — anyone can download it and verify independently.SDK and Implementation
- Standard indexer (
https://indexer-storage-testnet-standard.0g.ai) returns 503 intermittently - Always use turbo indexer:
https://indexer-storage-testnet-turbo.0g.ai
agent/src/shared/storage.ts— upload/download helpers with retry and checksum verificationfrontendV2/src/lib/server/og-storage.ts— server-side storage client for API routesfrontendV2/src/app/api/og-storage/route.ts— API route that proxies storage reads to the frontendagent/src/scripts/test-storage.ts— integration test script
Upload with Retry and Verification
Download with Retry
Storage Key Patterns
Every piece of data stored in 0G Storage is a JSON blob. The root hash from the upload is what gets stored on-chain (in contract state or emitted as an event). The “key” is the root hash itself — there is no separate key-value layer. What Prophet stores and when:Oracle Reasoning Object Structure
Frontend Storage Access
The frontend reads oracle reasoning via a server-side proxy to avoid CORS issues with the indexer:Diagnostics
Prophet ships two diagnostic scripts to verify 0G connectivity:npm run test:storage
Located atagent/src/scripts/test-storage.ts. It:
- Connects to 0G Storage via turbo indexer
- Uploads a timestamped JSON payload
- Downloads it back using the returned root hash
- Verifies the content matches exactly (checksum)
- Reports latency and pass/fail status
npm run test:compute
Located atagent/src/scripts/test-compute.ts. It:
- Initializes the
@0glabs/0g-serving-brokerwith the oracle wallet - Gets service metadata for the configured provider
- Verifies TEE attestation (if
COMPUTE_REQUIRE_TEE=1) - Sends a minimal test prompt asking for a simple JSON response
- Verifies the response is valid JSON with expected fields
- Reports latency and pass/fail status
What Would Break Without Each 0G Module
This is not a superficial integration. Prophet is architecturally dependent on all three 0G modules.