Skip to main content

ORA

ORA is a verifiable oracle protocol that brings AI and complex compute onchain.

Its main product, Onchain AI Oracle (OAO), integrates AI capabilities directly onchain.

ORA breaks down the limitations of smart contracts by offering verifiable AI inference, so developers can innovate freely.

OAO quickstart​

This quickstart is designed to help you to build a smart contract on Linea able to interact with OAO. See more details in our docs.

Workflow​

  1. The user contract sends the AI request to OAO on Linea by calling the requestCallback function on the OAO contract.
  2. Each AI request will initiate an opML inference.
  3. OAO will emit a requestCallback event that will be collected by opML node.
  4. The opML node will run the AI inference, and then upload the result on Linea, waiting for the challenge period.
    1. During the challenge period, the opML validators will check the result, and challenge it if the submitted result is incorrect.
    2. If the submitted result is successfully challenged by one of the validators, the submitted result will be updated on Linea.
    3. After the challenge period, the submitted result on chain is finalized.
  5. When the result is uploaded or updated on Linea, the provided AI inference in opML will be dispatched to the user's smart contract via its specific callback function.

Integration​

Overview​

To integrate with OAO, you will need to write your own contract.

To build with AI models of OAO, we provided an example of contract using OAO: Prompt.

Smart contract integration​

  1. Inherit AIOracleCallbackReceiver in your contract and bind with a specific OAO address:
constructor(IAIOracle _aiOracle) AIOracleCallbackReceiver(_aiOracle) {}
  1. Write your callback function to handle the AI result from OAO. Note that only OAO can call this function:
function aiOracleCallback(uint256 requestId, bytes calldata output, bytes calldata callbackData) external override onlyAIOracleCallback()
  1. When you want to initiate an AI inference request, call OAO as follows:
aiOracle.requestCallback(modelId, input, address(this), gas_limit, callbackData);

Reference​

Two models are available on Linea: Stable Diffusion (ID: 50) and Llama3 8B Instruct (ID: 11).

Prompt and SimplePrompt are both example smart contracts interacted with OAO.

For simpler application scenarios (eg. prompt engineering-based AI like GPTs), you can directly use Prompt or SimplePrompt.

SimplePrompt saves gas by only emitting the event without storing historical data.

Linea Mainnet contracts: