Skip to content

Oracle

An oracle service fetches data from an external source, then turns that observation into a contract call once validators agree on how to interpret it.

Contract and service split

Contract

  • defines the deterministic rule for accepting or normalizing oracle data
  • exposes service-consensus-query when normalization is needed
  • applies the final on-chain state change once the response is accepted

Service

  • fetches the external data
  • packages that observation into contract-data
  • chooses the consensus strategy for the response
  • feeds the result back into normal contract execution

How it works

  1. A funded wallet submits a request for some external datum, such as an asset price.
  2. Validators execute the oracle service locally.
  3. Each validator may see slightly different raw values because the source is external and nondeterministic.
  4. The service emits a service-response that points at a contract and uses contract-query(address) as its consensus strategy.
  5. Validators call service-consensus-query(payload) on that contract and compare the returned bytes.
  6. Once those normalized bytes match across quorum, the contract executes with the original payload.

Concepts introduced

External data fetches

The service runtime can talk to APIs, hosted backends, or other off-chain data sources.

contract-query consensus

Validators do not need to agree on the exact raw payload. They need to agree on the deterministic result produced by the target contract's service-consensus-query.

Contract-defined normalization

The target contract can round, floor, clamp, or bucket the input before consensus is checked. That lets the contract define acceptable precision or slippage instead of hard-coding it into the service.