Cassandra
Cassandra is an unattended Discreet Log Contract (DLC) oracle webserver written in Go and Rust. Her attestations are fully compliant with the DLC specifications, and so should be interoperable with any wallet or service which consumes the same class of announcements and attestations.
I’ve been working on her for some time, and I’m now confident enough in her to publish API documentation for Cassandra, in the hopes that the Bitcoin ecosystem at large will benefit from a benevolent and free oracle service, compliant with modern standards. If she becomes very popular, Cassandra’s attestations may someday be gated behind a lightning or ecash paywall. For now, she is completely free and public!
What is this?
Cassandra cryptographically announces & attests to a variety of real-world events and financial data from upstream sources automatically. You, dear user, may consume Cassandra’s attestations to build conditional Bitcoin payment contracts which are contingent on the outcomes of certain events, or the prices of Bitcoin in different fiat currencies. Cassandra’s cryptographic statements are exposed through the conduition.io/oracle
API.
Click hear to read more about how DLCs work.
API
To view general public information about the oracle:
1 | $ curl https://conduition.io/oracle/info |
1 | { |
Cassandra has two upstream event sources: Polymarket and CryptoCompare.
Update 2024-07-14
After witnessing the unreliable nature of the Polymarket API demonstrated to me over time, I have updated Cassandra to stop announcing new Polymarket events. Polymarket’s API is too brittle to use as a source of truth on which to base contractually binding signatures on which to stake real money.
- Events are often not resolved by their prescribed end date.
- Some events’ data is invalid for no obvious reason (missing important data fields).
- Some events’ outcomes and expected end dates are modified for no clear reason (which is illegal in a DLC protocol).
- Their API is rate limited, which prevents Cassandra from fetching timely updates for the numerous markets she is expected to track.
The description of Cassandra’s Polymarket API has been removed in the interest of brevity. Existing announced polymarket events will be tracked and attested to, to the best of Cassandra’s ability, but new polymarket events will not be announced. If you need to see the documentation for Cassandra’s old Polymarket API, here is a link to the now-removed API docs which are still viewable in my website’s git history.
The CryptoCompare event source is working just fine.
CryptoCompare (Pricing Data)
Bitcoin is currently the only commodity/asset whose price is attested to. Pricing data is sourced from CryptoCompare‘s API. Cassandra attests to hourly Bitcoin price candles for the following set of fiat currencies:
- USD
- EUR
- JPY
- GBP
- AUD
- CHF
- CAD
- SGD
- NZD
This list may change in the future, but existing announcements will always be honored as long as CryptoCompare’s API remains available.
Cassandra makes 4 attestations per fiat currency - one for each data-point in a one-hour candle:
- Open price (the starting price at a specified candle time)
- Close price (the final price one hour after the specified candle time)
- Highest price in the hour
- Lowest price in the hour
These are known as open
, close
, high
, and low
respectively.
9 fiat currencies, with 4 high/low/open/close attestations per currency results in 36 attestations and 36 announcements per hour.
Cassandra announces CryptoCompare price events well ahead of time. Currently that lookahead period is 8 weeks, but this may be adjusted in the future.
Prices are signed using digit decomposition: The price is broken down into base 10 digits, and each individual digit in the price is signed as a string using a separate nonce. This allows downstream consumers of Cassandra’s attestations to construct Contract Execution Transactions (CETs) for their Discreet Log Contracts with much greater efficiency.
GET /announcements/cryptocompare/BTC/:currency/:timestamp/:pricetype
currency
is a fiat currency in whose value Bitcoin’s price will be measured (e.g.USD
).timestamp
is either:- A unix second timestamp. Should be an integer divisible by 3600, indicating the top of an hour.
- An RFC-3339 timestamp, e.g.
2024-07-10T12:00:00Z
. Again, should be a specific hour.
pricetype
is any of:open
high
low
close
The timestamp
value indicates the time at the beginning of the price candle which will be attested to. About one minute after the timestamp
is reached, Cassandra will create attestations for the open
prices in those currencies. One hour later, Cassandra will attest to the high
, low
, and close
prices as well. We must wait the extra hour for high/low/close prices, as those prices could change up until the following one-hour candle begins.
Announcements for a given price candle are created 8 weeks ahead of the candle’s open time.
Example:
1 | $ curl https://conduition.io/oracle/announcements/cryptocompare/BTC/USD/2024-05-30T22:00:00Z/open |
1 | { |
The announcement
is a JSON representation of the oracle_announcement
message type, described here in the DLC specifications. Specifically Cassandra uses the dlc_messages
Rust crate to build announcements. The serialized
field is a hex-encoded binary representation of the same announcement data.
GET /attestations/cryptocompare/BTC/:currency/:timestamp/:pricetype
currency
is a fiat currency in whose value Bitcoin’s price will be measured (e.g.USD
).timestamp
is either:- A unix second timestamp. Should be an integer divisible by 3600, indicating the top of an hour.
- An RFC-3339 timestamp, e.g.
2024-07-10T12:00:00Z
. Again, should be a specific hour.
pricetype
is any of:open
high
low
close
Be aware that attestations for high
, low
, and close
price types only be available one hour AFTER the timestamp
, as these prices can only be fixed at the end of their one-hour candle.
Example:
1 | $ curl https://conduition.io/oracle/attestations/cryptocompare/BTC/USD/1717106400/close |
1 | { |
The attestation
is a JSON representation of the oracle_attestation
message type, described here in the DLC specifications. Specifically Cassandra uses the dlc_messages
Rust crate to build attestations. The serialized
field is a hex-encoded binary representation of the same attestation data.
The price
field is the raw price attested to, denominated in units of currency
. The outcome integer which Cassandra actually signs is price * (10 ** precision)
, where precision
comes from the initial announcement. Generally, precision = -2
(for cents).
Disclaimer
Cassandra runs and attests to outcomes without my personal supervision. Her data is sourced upstream APIs. If those services return faulty or incorrect data, then Cassandra’s attestations will also be faulty. You should consider Cassandra as a layer of interoperability that enables DLCs to be built from upstream data sources. Cassandra does not independently validate that data.