Skip to main content
This guide shows how to build a Rust application that reads on-chain price data from the Pragma oracle using Foreign Procedure Invocation (FPI).

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:
  1. Fetching the oracle’s storage to discover all registered publisher IDs
  2. Importing each publisher account as a ForeignAccount
  3. Running a transaction script that calls get_median on the oracle via FPI
The oracle performs the aggregation on-chain and returns the median to your stack.

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.
The oracle library (pm_accounts::oracle) is published as part of pragma-miden. You can add it as a git dependency or copy the compiled MASM into your own project.

CLI (quick testing)

For quick spot-checks without writing Rust, the pm-oracle-cli wraps the same logic: