On-chain oracles

At Riften Labs, we’re testing out an on-chain oracle contract. It’s currently in use on Cauldron dangerzone (hoover a token) to fetch the USD price of BCH.

The contract we’ve deployed fetches the price from oracles.cash and embeds it into a NFT commitment (I hope you don’t mind General Protocols). This allows us to both:

  • Read the price off the blockchain using electrum to use in a user interface, like we do on Cauldron
  • Fetch the price in other contracts by taking it as input and using introspection


The code for this is in oracle.cash.

Price aggregation

Additionally, there is a contract (aggregated.cash) that takes 3 other oracle contracts as input and publishes the median price of the three. It can also be chained to get “median of median” of more entities:


The goal is to have multiple independent oracles and be able to get a price within a contract that is resistant to one or more of the entities “going rouge”.

Hoping for some review and feedback. The code and more info at Riften Labs / Moria / oracle-contract · GitLab


Hey, it’s really cool to see another oracles.cash user in the wild! We absolutely don’t mind you guys using it - in fact we encourage creative uses! Just gotta keep a few things in mind:

  1. Just like all things in life, the commitment to run the oracle isn’t eternal. It’ll very likely run out way before heat death of the universe or the next thermonuclear world war, whichever comes first.

  2. But we are committed to doing things responsibly as far as we physically can…

  3. … and you can help extend the commitment further into the future by contributing to its operations at some point.

Happy hunting!


You guys are the best :pray:

This is addressed in the contract. Contract owner can change the oracle used.

You can optionally verify that the oracle used in the contract has not been changed by
checking the first 20 bytes of the commitment. These bytes should match the hash of the oracle public key (hash160).

So short running contracts may want to additionally verify the oracle hash. Long running contracts may want to only verify the oracle category. For long running contract, it’s suggested that the DeFi application owner deploy their own oracle contract (so that they are the owner).