Ready-to-run example
Clone the repo and run
cargo run --release -p consume-price — reads BTC/USD from the Pragma oracle on testnet, no configuration needed.How it works
Pragma Miden uses a decentralized publisher model: the oracle account stores only a registry of publisher IDs — prices live in each publisher’s own account. Consuming price data requires:- Fetching the oracle’s storage to discover all registered publisher IDs
- Importing each publisher account as a
ForeignAccount - Running a transaction script that calls
get_medianon the oracle via FPI
Step 1: Set up your project
Cargo.toml — the oracle runs on Miden 0.17 (node 0.17 rejects 0.16 clients; MSRV is Rust 1.98.1); pm-accounts provides the compiled oracle package and pm-utils-cli a ready-made testnet client:
Step 2: Resolve the oracle’s foreign accounts
Because Pragma’s oracle depends on multiple publishers, you must import every registered publisher account alongside the oracle itself before executing the FPI call.src/main.rs:
Step 3: Call get_median via FPI
The oracle’s get_median procedure is called from a transaction script executed read-only against the oracle account (execute_program, nothing is submitted, so no fee is paid). The script pushes the pair word and calls the oracle via FPI. Since Miden 0.16 a transaction script is a @transaction_script pub proc main … end block.
Step 4: Run
Response format
Divide by
10^decimals of the pair to get the USD value: 8 decimals for most pairs (100_000_000), 6 for USDT/USD, USDC/USD and XAUT/USD. The per-pair decimals are listed below.
Available assets
suffix is always 0 today. 6:0 to 14:0 are Miden-only feeds (not published on Starknet).
Oracle reference
Contract addresses change between testnet iterations: the testnet was reset with node 0.17 in October 2026 and the 0.16 accounts no longer exist. Always refer to the pragma-miden README for the latest oracle ID.
CLI (quick testing)
For quick spot-checks without writing Rust, thepm-oracle-cli wraps the same logic: