Skip to main content
DiaBtcUsdCents (dia_btc_usd_cents.ark) is a reusable Arkade Language library for verifying and reading DIA Lasernet BTC/USD price updates rounded to USD cents. DiaBtcUsdOracle (dia_btc_usd_oracle.ark) wraps that verification in a recursive output identified by a one-unit asset (Asset as Contract ID), so consumer contracts never hardcode DIA’s signer key. Unlike DIA BTC/USD Expiry Oracle (DiaBtcUsdExpiryOracle), which verifies the same DIA feed and stores eight rolling expiry slots, DiaBtcUsdOracle stores no history and needs no offchain publisher to pre-write fixings. Instead, whoever spends a consumer co-spends DiaBtcUsdOracle as input 1 and attaches a fresh DIA signature directly to that transaction. Use DIA BTC/USD Expiry Oracle for scheduled expiry fixings such as Options, and use DiaBtcUsdOracle when a contract needs a live point-in-time price at any moment, such as margin calls in Loans.

Source

Save dia_btc_usd_cents.ark alongside your consumer contract or alongside dia_btc_usd_oracle.ark. Compile the exact same source on every party, because any edit changes the derived contract addresses.
dia_btc_usd_cents.ark
dia_btc_usd_oracle.ark

Constructor

operatorExitDelay is not a constructor parameter, because the SDK binds it to the operator’s exit delay (CSV delays).

Quote Packet

When a consumer co-spends DiaBtcUsdOracle, the spending transaction carries a 17-byte extension packet of type 34 (0x22). Integers use 8-byte little-endian sign-magnitude encoding (int2bytes(n, 8)).

Functions

DiaBtcUsdOracle.verify

Runs when a consumer co-spends the oracle output as input 1.
  • Enforces DIA’s live validity window (checkTime(time) and !checkTime(intentExpiry) on the operator’s enclave clock), mirroring DIA’s OracleIntentRegistry so live quotes expire after one hour on Lasernet.
  • Calls DiaBtcUsdCents.verifyPrice to check DIA’s EIP-712 signature via checkSigFromStack and round the 18-decimal price to USD cents. DIA BTC/USD Expiry Oracle calls the same function with its own expiry window.
  • Checks that packet 34 matches (price, time) and recreates the same DiaBtcUsdOracle script, satoshi value, and identity unit on output 0.

DiaBtcUsdCents.readPrice

Lets any consumer contract read the verified quote in one call.
  • Confirms that input 1 holds the single unit of oracleId and parses packet 34 into a PriceQuote.
  • Because migrate requires a single input (tx.numInputs == 1), any multi-input Arkade transaction spending oracleId must execute verify.
  • Leaves contract-specific timestamps (such as a loan’s setup time or maturity) to the consumer.

DiaBtcUsdOracle.migrate

Moves the identity unit to a new script so adminPk can rotate oraclePk or adopt a newer DIA schema without changing open consumer contracts.
  • Requires tx.numInputs == 1 and a valid signature from adminPk, while keeping the satoshi value and identity asset on output 0.
  • Because adminPk controls migration, consumers trust both DIA’s signer key and the key holding adminPk.

DiaBtcUsdOracle.unilateral

Provides the onchain exit if the operator stops cosigning.
  • Waits for operatorExitDelay after unrolling onchain and requires a signature from adminPk.

Live DIA Inputs

For live BTC/USD updates, query getLatestIntentByType("OracleUpdate", "BTC/USD") on DIA Lasernet (https://rpc.diadata.org/, registry 0x5612599CF48032d7428399d5Fcb99eDcc75c06A7). Bind oraclePk to DIA’s Lasernet signer (0x100211ee120bca9f272034d98b1b026bb4ab735ebeb5da8be6a69bf7ee0ea24cfd48, address 0x10e34723aA722C7A9860f5eC6446f22252dB168a). Pass the first 64 bytes of its 65-byte Ethereum signature as oracleSig. When multiple DIA signers publish to OracleIntentRegistry, filter recent IntentRegistered logs by BTC/USD and that signer address before calling getIntent. Those six bytes32 constants are DIA’s EIP-712 OracleIntent digest for an OracleUpdate. TYPEHASH is keccak256 of OracleIntent(string intentType,string version,uint256 chainId,uint256 nonce,uint256 expiry,string symbol,uint256 price,uint256 timestamp,string source) from OracleIntentUtils.sol. DOMAIN is the separator for name "DIA Oracle", version "1.0", chain 1050, the registry above, and salt 0. INTENT_TYPE, VERSION, SYMBOL, and SOURCE are keccak256 of "OracleUpdate", "1.0", "BTC/USD", and "DIA Oracle". During local testing, bind oraclePk to your own 0x10-prefixed secp256k1 key and sign that digest without editing either contract file.