From 6dc0478e2c21752ce9918e1487ccd0f640fb1764 Mon Sep 17 00:00:00 2001 From: Zhe <106411133+zhe-t@users.noreply.github.com> Date: Sun, 22 Dec 2024 19:29:11 +0000 Subject: [PATCH] feat: add pyth example to readme --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 98708ec..4d85a43 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,19 @@ import { PublicKey } from "@solana/web3.js"; })(); ``` +### Fetch Price Data from Pyth + +```typescript +import { pythFetchPrice } from "solana-agent-kit"; + +const price = await pythFetchPrice( + agent, + "0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43" +); + +console.log("Price in BTC/USD:", price); +``` + ## API Reference ### Core Functions @@ -247,6 +260,10 @@ Stake SOL with Jupiter to earn rewards. Send an SPL token airdrop to many recipients at low cost via ZK Compression. +#### `pythFetchPrice(agent, priceFeedID)` + +Fetch price data from Pyth's Hermes service. + ## Dependencies The toolkit relies on several key Solana and Metaplex libraries: @@ -258,6 +275,7 @@ The toolkit relies on several key Solana and Metaplex libraries: - @metaplex-foundation/umi - @lightprotocol/compressed-token - @lightprotocol/stateless.js +- @pythnetwork/price-service-client ## Contributing