Canonical: https://solanashreds.xyz/learn/oracle-updates-on-solana

# How oracle price updates appear in Solana transactions

A Solana oracle price update under the pull model: what the update transaction carries, and which fields a decoder can read before confirmation.

A Solana oracle price update under the pull model is an ordinary transaction that someone sends to post a signed price on chain. With Pyth, the feed id, price, confidence, exponent and publish time sit in plain bytes inside the instruction data, so a decoder can read them from shreds before the transaction is confirmed.

## Pull oracles: the user posts the price

In a push design, the oracle network writes prices to chain on its own schedule. In a pull design, the oracle network signs prices off chain, and whoever needs a fresh price, a trading bot, a lending app or a keeper, brings the signed price on chain in their own transaction. The program checks the signatures and writes the price into an account that other programs can read.

For anyone decoding chain data this has a useful side effect: the price travels inside the transaction, as instruction data. It is not hidden in program state that you would need to read separately. The same bytes reach a shred receiver as soon as the leader sends the block out.

Pyth on Solana uses two programs for this, both listed with their sources on the [program IDs page](https://solanashreds.xyz/learn/program-ids). The receiver, `rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ`, checks updates. The push oracle, `pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT`, keeps one well known account per feed up to date by calling the receiver. The receiver's own config account names `HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ` as the Wormhole program whose verified messages it accepts.

## A Pyth update, instruction by instruction

We fetched 15 distinct recent successful Pyth transactions on 18 November 2026 and named each instruction by its Anchor discriminator.

| Step | Program | Instruction | Count in the sample |
| --- | --- | --- | --- |
| 1. Make room for the signed root | Wormhole | `init_encoded_vaa` | 11 |
| 2. Upload the signed root in pieces | Wormhole | `write_encoded_vaa` | 11 |
| 3. Check the guardian signatures | Wormhole | `verify_encoded_vaa_v1` | 11 |
| 4. Post one price per feed | push oracle | `update_price_feed` | 55 |
| 5. Check the price against the root | receiver, called by step 4 | `post_update` | 57 inner calls |
| 6. Return the rent | Wormhole | `close_encoded_vaa` | 12 |

One transaction instead used the receiver's `post_update_atomic`, which carries the signed root inline. The signed root is a Wormhole message, called a VAA, holding a Merkle root over many prices; each `update_price_feed` then proves one price against it. A single transaction often updates several feeds: the push oracle transactions in our sample posted between 1 and 7 prices each.

Step 5 is a [cross-program invocation](https://solanashreds.xyz/learn/inner-instructions-and-cpi), so it is not in the transaction bytes. Step 4 is, and that is where the price is.

## Reading the price from the instruction bytes

1. Check the program is the push oracle and the first 8 bytes are the [Anchor discriminator](https://solanashreds.xyz/learn/anchor-discriminators) of `update_price_feed`.
2. Read a 4-byte little-endian length, then that many bytes: the signed message. This is ordinary [Borsh](https://solanashreds.xyz/learn/borsh-encoding) for a byte vector.
3. Skip the Merkle proof: a 4-byte count, then 20 bytes per proof entry. The first update we decoded had 12 entries.
4. Skip one byte of treasury id, read the 2-byte shard id, then the 32-byte feed id argument.
5. Parse the message. A first byte of 0 marks a price message. After it come the feed id (32 bytes), price (i64), confidence (u64), exponent (i32), publish time (i64) and previous publish time (i64). Unlike everything around it, these fields are big-endian.
6. Check that the feed id in the message equals the feed id argument, as the program itself does. The price is `price × 10^exponent`, and the confidence uses the same exponent.

For example, one update we decoded carried a price of 1,337,508 with exponent -5, which is 13.37508. Reading the same feed's account later showed the identical feed id and exponent, stored little-endian by the receiver. As an offline check, the account address derived from each decoded shard id and feed id was one of that instruction's own accounts, in all 55 updates.

## A tested decoder

The function below is the one our examples test against the fixtures: it decoded all 55 `update_price_feed` instructions in 12 transactions, across 38 distinct feeds.

```typescript file="src/pyth-update.ts"
// Read the Pyth price carried by a Pyth push oracle `update_price_feed` instruction, straight from its data.
// Layout: pyth-crosschain pyth-push-oracle (update_price_feed(params, shard_id, feed_id)), pyth_solana_receiver_sdk
// (PostUpdateParams { merkle_price_update { message: Vec<u8>, proof: Vec<[u8; 20]> }, treasury_id }), and
// pythnet_sdk messages.rs (PriceFeedMessage, big-endian, type byte 0).
import { sighash } from "./anchor.ts";

export const PYTH_PUSH_ORACLE = "pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT";
const UPDATE_PRICE_FEED = Buffer.from(sighash("update_price_feed"));

export type PythPrice = { feedId: string; price: bigint; conf: bigint; exponent: number; publishTime: bigint; prevPublishTime: bigint; shardId: number };

export function decodePythUpdate(data: Uint8Array): PythPrice | null {
  const d = Buffer.from(data.buffer, data.byteOffset, data.byteLength);
  if (d.length < 8 || !d.subarray(0, 8).equals(UPDATE_PRICE_FEED)) return null;
  let o = 8;
  const len = d.readUInt32LE(o); o += 4;
  const m = d.subarray(o, o + len); o += len;           // the signed Pythnet message
  o += 4 + d.readUInt32LE(o) * 20;                       // Merkle proof: count, then 20-byte nodes
  o += 1;                                                // treasury_id
  const shardId = d.readUInt16LE(o); o += 2;
  const feedArg = d.subarray(o, o + 32).toString("hex");
  if (m[0] !== 0 || m.length < 69) return null;          // 0 = PriceFeedMessage
  const feedId = m.subarray(1, 33).toString("hex");
  if (feedId !== feedArg) return null;                   // the program checks the same thing
  return { feedId, price: m.readBigInt64BE(33), conf: m.readBigUInt64BE(41), exponent: m.readInt32BE(49),
    publishTime: m.readBigInt64BE(53), prevPublishTime: m.readBigInt64BE(61), shardId };
}
```

It needs only `sighash` from the Anchor helper shown in the [Anchor decoding guide](https://solanashreds.xyz/docs/decode/anchor-instructions).

## Switchboard On-Demand

Switchboard On-Demand also follows the pull model, under program `SBondMDrcV3K4kxZR1HNVT7osZxAHVHgYXL5Ze1oMUv`. Its Anchor IDL is published on chain, and names its feed updates `pull_feed_submit_response` and related variants, which a decoder can handle with the same IDL approach as Pyth.

What we saw on chain is a caution. The program's last 1,000 signatures stretched over about 17 million slots, and a sample of 50 of those transactions held only randomness requests and oracle heartbeats, with no feed submissions. So before you build on Switchboard updates, check how its feeds reach the chain today, rather than assuming they look like Pyth's.

## Questions about oracle updates

### Is the price in an unconfirmed update trustworthy?

The price bytes are signed off chain, but your decoder has not checked those signatures, and the transaction may still fail. Treat it as a strong early signal, and wait for confirmation before acting on it as settled.

### Why do the fields switch to big-endian?

The message is produced off chain in Pyth's own wire format, which is big-endian. Solana programs use little-endian Borsh, so the bytes around the message are little-endian, while the message inside keeps its original order.

### Do I need the Wormhole steps to read the price?

No. The price is in step 4. The Wormhole steps matter only if you want to verify the signatures yourself.

## What an unconfirmed update does not prove

Decoding `update_price_feed` tells you which price someone tried to post, not that the program accepted it. The Merkle proof is checked against a root from an earlier step, and the receiver rejects a stale or invalid update. A failed transaction still appears in the block. Several transactions in one block can also post the same feed, in which case the order decides what the account holds. For settled values, read the price account or check the transaction's outcome with RPC.

## Using oracle prices in a pipeline

[Reading an IDL](https://solanashreds.xyz/learn/reading-an-idl) shows how to find instruction layouts for other oracles, and [program events](https://solanashreds.xyz/learn/solana-program-events) covers what programs write to their logs. To decode updates like these from live shreds, [compare the plans](https://solanashreds.xyz/pricing).
