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. To read prices in your contract, start with Oracle Output. It is a contract that stores signed BTCUSD prices in one output any contract can read.

What oracles are for

What you build

You build an oracle output, a consumer, or both. The oracle output is one output within Arkade that stores the prices the signers sign. A consumer is a contract that reads a price from the output. Oracle Output is the contract, with one signer. Multi-Oracle Aggregation is the same contract with more signers, and the consumers that take a median.

Verify a signed price

The simplest pattern verifies the signature in the consumer itself. 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 @ f9f8866
The hex number is the ticker BTCUSD in ASCII. num2bin writes the price and the time as 8 bytes each. This pattern ties the contract to the signer’s key. The Coupling Problem explains why the oracle output avoids that.

Understand

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

Oracle Output

The contract, with the source to copy.