Pyth: How to Use Real-Time Data in Solana Programs
Install Pyth SDKs
Rust SDK
[dependencies]pyth-solana-receiver-sdk ="0.1.0"Typescript SDK
npm install --save @pythnetwork/price-service-client @pythnetwork/pyth-solana-receiverWrite Contract Code
use pyth_solana_receiver_sdk::price_update::{PriceUpdateV2};
#[derive(Accounts)]
#[instruction()]
pub struct Sample<'info> {
#[account(mut)]
pub payer: Signer<'info>,
// Add this account to any instruction Context that needs price data.
pub price_update: Account<'info, PriceUpdateV2>,
}Write Frontend Code
Price Feed Accounts
Price Update Accounts
Was this helpful?