Verifiable AI oracle for smart contracts. The Onchain AI Oracle (OAO) routes inference requests to opML (optimistic ML) nodes that run open models (LLaMA 3, Stable Diffusion, etc.) off-chain and post results back; a fraud-proof window lets challengers dispute incorrect inferences via an interactive on-chain dispute game.
- 01verifiable on-chain AI inference
- 02smart-contract callable LLM/SD
- 03opML fraud-proof verification
- 04AI-augmented DeFi/governance
- 05deterministic ML output for contracts
- forge install ora-io/OAO
- pnpm add ethers
| Variable | Scope | Description |
|---|---|---|
| ORA_OAO_ADDRESS | Server | OAO contract address on the target EVM network (Ethereum, Arbitrum, Base, OP, etc.). |
| ORA_MODEL_ID | Server | Model id to call (e.g. 11 for LLaMA 3 8B, 50 for Stable Diffusion). See ORA model registry. |
| EVM_RPC_URL | Server | EVM RPC endpoint for the target chain. |
Use ORA's Onchain AI Oracle (OAO) by inheriting from `AIOracleCallbackReceiver` in your Solidity contract and calling `IAIOracle(ORA_OAO_ADDRESS).requestCallback{value: fee}(modelId, input, address(this), gasLimit, callbackData)`. The opML node runs inference off-chain and invokes your `aiOracleCallback(uint256 requestId, bytes output, bytes callbackData)` after the dispute window closes. Estimate the fee with `IAIOracle.estimateFee(modelId, gasLimit)` and fund the call with native ETH/whatever-gas-token. For prompt models pass UTF-8 bytes; for image models the output is an IPFS CID. Off-chain, you can mirror the same call via the OAO REST/JS helper to preview latency before paying gas. Treat the callback as the only source of truth — never key business logic on the request tx alone.
- ⚑There is a fraud-proof challenge window before the callback finalizes — consumers should not commit irreversible actions on the first response; wait for finality or design a refund path.
- ⚑Each supported model is a separate `modelId` and may be added/removed by the ORA team — pin a modelId and monitor the registry for deprecations.
- ⚑Gas + opML node fee scales with input size and `gasLimit`; large prompts can make calls economically unviable on L1 — prefer L2s (Arbitrum, Base, OP).
- ⚑opML proves *which* output the model produced for a given input, not that the model is unbiased or safe; sanitize inputs and validate outputs at the contract level.
- ⚑Image inference (SD) returns an IPFS CID; pin the result on your own IPFS service or it can disappear after the OAO node prunes.
- ⚑Network congestion / opML node availability can extend callback time from seconds to minutes — design async UX, not blocking RPC waits.
- ⚑Slashing of opML nodes happens only on a successful challenge; honest-but-slow nodes are not penalized, so latency SLAs are best-effort.
- ⚑The opML approach assumes at least one honest watcher — for high-stakes use, run your own challenger or use ORA's opp/ai (zk + opML) variant when available.