Skip to main content
A contract cannot fetch a price or any other outside fact. An oracle signs the fact instead, and the contract verifies the signature before it uses the value.

What oracles are for

What you build

You build an oracle output, a consumer, or both. An oracle output is one output within Arkade that verifies or stores signed BTC/USD prices. A consumer is a contract that reads a price from that output. Start with DIA BTC/USD Live Oracle for live point-in-time DIA prices verified on the fly with the reusable DiaBtcUsdCents library. Use DIA BTC/USD Expiry Oracle when contracts such as Options need multiple historical expiry fixings stored on the output, and see Multi-Oracle Aggregation to take a median across independent point-in-time signers.

Verify a signed price

The simplest pattern verifies the signature in the consumer. The signer signs a hash of the ticker, the price, and the time. The spender supplies the price, the time, and the signature:
examples/option/option_vault.ark @ v0.1.1
The hex number is BTCUSD in ASCII. int2bytes writes the price and the time as 8 bytes each. This pattern ties the contract to the signer’s key, which the oracle output avoids (The Coupling Problem).

Understand

How a script verifies a signed message, why a contract must not store the key, and how an asset names the output.

DIA BTC/USD Live Oracle

Live point-in-time DIA BTC/USD verification, reusable DiaBtcUsdCents library, and stateless oracle output.