Use Randomifier
Make your first call.
Choose how you want to use Randomifier: run the JavaScript example on your computer, or call it from your own Solana program.
Live on Solana mainnet.
Option 1: run the JavaScript example
This path is for developers using a computer terminal. It reads the result without connecting a wallet.
- Install Node.js 20 or newer.
- Download the complete example ZIP and unzip it.
- Open the extracted
randomifier-node-examplefolder in a terminal. - Run the two commands below, one after the other.
The reader selects the published Solana network, simulates the call, and prints the result. You can run it without connecting a wallet.
npm install
node solana-read.mjs
What should I see?
The terminal prints a result containing compositeValue, the number your app can use, and compositeHash, a fingerprint of the prices used. measuredUnits reports the compute used by the call.
If it says a price is too old, one of the price feeds needs a fresh update before the program can return a result. If you see an RPC rate-limit message, retry later or use your own RPC integration.
Download individual files
solana-read.mjs · verify-contract.mjs. Keep them in the same folder and install @solana/web3.js@1.98.4.
Option 2: call from a Solana program
Download the Rust helper. It builds the call and checks the returned program, basket and result. Pass the seven price accounts in order, followed by the Randomifier program.
Use the tested Rust helper
Add these tested crate versions to your program's Cargo.toml, then place the downloaded helper beside your program source:
[dependencies]
solana-account-info = "=2.3.0"
solana-cpi = "=2.2.1"
solana-instruction = "=2.3.3"
solana-program-error = "=2.2.2"
solana-pubkey = "=2.4.0"
#[path = "solana-cpi.rs"]
mod randomifier;
// Inside your instruction handler; accounts are seven feeds, then the program.
let (x, source_digest) = randomifier::read_randomifier(accounts)?;
The helper requests read-only feed access and checks the returned program, format and basket. Keep X as a u128. Your transaction pays its normal chain fee; this call adds no separate service payment.
Result format and integer precision
The instruction uses program DZzj8jz1vicWa6WAqSNrxwDQg8uH9Um6QeE7yLnfw3H3.
Direct and CPI calls use the same validation. The decoder checks the returned program ID,
exact 95-byte length, magic, basket version 2, formula basket hash
5d13fe3aa4ebca82b5db4a60cb308a829a3f2d69970f53720efdc3a2a694bdd7,
sample count 7 and normalized exponent −18. After CPI, read return data immediately,
before another invocation can replace it. Re-simulate the complete consuming transaction
after adding its budget and any other instructions.
Use the supplied account list
The reader includes all seven price accounts in the required order. Use that list when constructing your own call.
Using X in an application
Use exact integers, rather than JavaScript floating-point numbers. The captured −8 input exponents produce X values divisible by 1010: rawX % 2 and rawX % 100 both return zero throughout this capture. Define and test your output mapping. The result is public and repeatable. Define when your application reads the prices and how it handles a retry.
More downloads
The reader and Rust helper are available directly from this site. Download the technical reports →
Optional reference for coding assistants
The coding assistant reference contains the same program address, account list and result format as this guide.
Free to use. Support development →