Skip to main content
This is the end-to-end usage guide. It walks through every public method on the Charli3 class in the order you will actually use them. Copy the snippets, they work as-is against preprod.

Install

Env needed:
  • BLOCKFROST_PROJECT_ID from blockfrost.io (only for the refresh flow, reads do not need it).

Create the client

Constructor options

The preset baked into the SDK has addresses, policy IDs, oracle node URLs, and the reference script for both networks. You never have to look those up.

Reading prices

getOdvReference(pair)

The main read. Returns the current on-chain price for one pair, plus the UTXO it came from so you can cite it.

getPrice(pair)

Same as getOdvReference but returns only the price, no UTXO pointer. Use when you do not need the on-chain citation.

getAllPrices()

Reads every pair in the preset in parallel. Good for a dashboard row.
Feeds that fail to read come back with rawValue: 0n and isExpired: true instead of throwing, so you can render the list without wrapping each entry in try/catch.

getOracleReference(pair)

Same shape as getOdvReference but reads the legacy (non-ODV) oracle address. Only use this if you need a feed that is not on ODV yet.

Listing what is available

listFeeds()

Legacy feed presets.

listOdvFeeds()

The ODV pull-oracle feeds, which is probably what you want.
Each entry has the policy ID, oracle address, reference script pointer, validity length, and the six oracle node URLs and public keys.

Refreshing a stale price

submitRound2(lucid, pair, opts?)

The full refresh flow in one call. Collects signed feeds from the six oracle nodes, builds the Round 2 tx, asks the nodes for signatures, signs with your wallet, and submits. Takes about 30 seconds end to end.
Result:
Options:
Cost: about 1.5 tADA tx fee plus min-UTXO on the outputs. The SDK never takes a cut. When to call: only when the read returned isExpired: true. Refreshing a fresh feed is a waste of fees.

Lower-level: run Round 1 on its own

collectFeeds(pair, opts?)

Fetches signed feed messages from the six oracle nodes and verifies them, without building a tx. Use this if you want to show “what the nodes are seeing” without posting anything.
Every entry in feeds.feeds has nodeUrl, value, timestamp, messageCborHex, signatureHex, and verificationKeyHex. You can show them to the user, or use presetFeeds on submitRound2 later to avoid collecting twice.

Types

Full type list is exported from charli3-js and also in src/types.ts.

Lower-level exports

Anything below the Charli3 class is re-exported for power users:

Common patterns

Read-or-refresh

Price a USD amount in ADA

Show every pair

Errors

Either the feed has never been posted on this network, or Kupo is slow. Retry, or pass your own kupoUrl in the constructor.
Some oracle nodes were offline, so the SDK could not collect enough signed feeds to hit consensus. Usually temporary.
The validator rejected the tx. Common causes: stale validity window (your clock is off), missing signature, or the wallet ran out of tADA.

Next

How it works

Round 1 / Round 2, IQR consensus, datum layout.

AI agents

Plug the SDK into any tool-calling LLM with one markdown file.