← Protocols
Switchboard
Oracle·Solana · Sui · Aptos · EVM · Multi-chain

Switchboard

01Description

Solana-native, permissionless oracle with on-demand (pull) data feeds, verifiable randomness, and TEE-backed publisher infrastructure. Anyone can fork and customize a feed; supports Solana, SVM rollups, Sui, Aptos, and EVM via the on-demand SDK.

02Best for
  • 01Solana DeFi price feeds (low cost, on-demand)
  • 02custom / long-tail data feeds (anyone can build one)
  • 03verifiable randomness on Solana
  • 04TEE-attested oracle publisher data
  • 05SVM rollups and non-EVM (Sui, Aptos) feeds
03Install
  • pnpm add @switchboard-xyz/on-demand @switchboard-xyz/common
  • cargo add switchboard-on-demand
04Environment variables
VariableScopeDescription
SWITCHBOARD_QUEUEClientSwitchboard On-Demand queue pubkey for the target Solana cluster (mainnet vs devnet differ). See docs.switchboard.xyz network/queue addresses.
SWITCHBOARD_CROSSBAR_URLClientCrossbar gateway endpoint used to fetch signed oracle responses off-chain (default `https://crossbar.switchboard.xyz`). Pin a dedicated gateway for production.
05Prompt snippet
Use Switchboard On-Demand for pull feeds: off-chain build the update tx with `PullFeed.fetchUpdateIx({ crossbarClient, numSignatures })` from `@switchboard-xyz/on-demand` (it returns a Solana instruction + lookup tables that bundle signed oracle responses), prepend it to your program instruction in the same tx, then on-chain in your Anchor / native program load via `PullFeedAccountData::parse(feed_account.data.borrow())` and call `feed.get_value(&clock, max_stale_slots, min_samples, only_positive)` — always pass `max_stale_slots` and `min_samples >= 3`. For randomness use `Randomness::create` + commit/reveal with `Randomness::reveal_ix`. On EVM/Sui/Aptos use the corresponding `on-demand` receiver contract and submit the same Crossbar-signed payload.
06Gotchas
  • Switchboard On-Demand is PULL-based — every consuming tx must include the `fetchUpdateIx` (or its EVM/Sui/Aptos equivalent) before your read; forgetting it leaves the feed stale and reads will fail freshness checks.
  • Always set `max_stale_slots` (e.g. 100 = ~40s on Solana) and `min_samples >= 3` in `get_value` — the defaults are NOT safe; reading without these is the #1 oracle exploit pattern on Solana.
  • Network fees: each pull update pays oracles via the queue's reward token; ensure your program's payer or user has SOL for tx fees AND the queue funding requirements; randomness pays a separate oracle reward.
  • Mainnet and devnet use different queue pubkeys, different Crossbar URLs, and different feed pubkeys — never reuse a devnet feed pubkey on mainnet (silent stale-data bug).
  • Decimal scaling: `get_value` returns a `Decimal` (i128 mantissa + scale) — convert carefully into your token's native units; mixing scales across assets in the same market causes orders-of-magnitude bugs.
  • Public Crossbar gateway is rate-limited and best-effort; production apps should pin a dedicated gateway and add retry/SSE fallback before the tx is submitted.
  • EVM / Sui / Aptos receivers each have their own contract address per chain — verify against `docs.switchboard.xyz` per-chain pages before hardcoding.
07Alternatives