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-querywhen 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¶
- A funded wallet submits a request for some external datum, such as an asset price.
- Validators execute the oracle service locally.
- Each validator may see slightly different raw values because the source is external and nondeterministic.
- The service emits a
service-responsethat points at a contract and usescontract-query(address)as its consensus strategy. - Validators call
service-consensus-query(payload)on that contract and compare the returned bytes. - 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.