Price Oracles

Price‑Feed Oracles on Stacks
Smart contracts written in Clarity run in a deterministic sandbox: they can read data in the Stacks and Bitcoin chainstate, but nothing else. Whenever your dApp needs the latest BTC/USD, STX/BTC, or any other market price, you’ll rely on an oracle to bring that data on‑chain in a verifiable way.
This page explains why price‑feed oracles matter on Stacks and links to the specific oracle provider docs with instructions on how to integrate them.
Why you need a price‑feed oracle
Here are some possible scenarios where you might need an oracle.
Liquidations & collateral ratios
Lending / borrowing protocols, margin trading
Signed price updated every N blocks
Stablecoin peg maintenance
BTC‑backed or exogenous‑collateral stablecoins
Reference BTC/USD (or other) price
AMM curve calculations
DEXs that tune fees or rebalance pools
Time‑weighted average price (TWAP)
Derivatives settlement
Options, futures, or perpetual swaps
Final settlement price at expiry
Oracle Providers
There are two oracle providers that Stacks builders commonly use for price data: Pyth and DIA.
Pyth
Pyth is a pull-based oracle. Trust Machines currently maintains the Pyth bridge. See the docs and Clarity contracts on Trust Machine's GitHub repo for the bridge. Check out the step-by-step guide from the Hiro blog:
DIA
DIA is another oracle provider used by Stacks builders. See DIA's guide for how to use DIA oracles with Stacks. Check out the video tutorial to learn more on how DIA works for Clarity smart contracts:
Last updated
Was this helpful?

