From 5912e03a0992eb287cd3512a085fcdc7d39163c6 Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Mon, 9 Dec 2024 17:27:15 +0000 Subject: [PATCH 1/5] go --- pages/price-feeds/use-real-time-data/solana.mdx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pages/price-feeds/use-real-time-data/solana.mdx b/pages/price-feeds/use-real-time-data/solana.mdx index c6e9cdc0..1f5ddd21 100644 --- a/pages/price-feeds/use-real-time-data/solana.mdx +++ b/pages/price-feeds/use-real-time-data/solana.mdx @@ -227,6 +227,17 @@ await pythSolanaReceiver.provider.sendAll( The [SDK documentation](https://github.com/pyth-network/pyth-crosschain/tree/main/target_chains/solana/sdk/js/pyth_solana_receiver) contains more information about interacting with the Pyth solana receiver contract, including working examples. + + Posting and verifying price updates currently requires multiple transactions + on Solana. If your usecase requires a single transaction, you can reduce the + verification level of the posted price updates by replacing + `addPostPriceUpdates` by `addPostPartiallyVerifiedPriceUpdates` in the + transaction builder. Please read the + [VerificationLevel](https://github.com/pyth-network/pyth-crosschain/blob/main/target_chains/solana/pyth_solana_receiver_sdk/src/price_update.rs#L20) + docs to understand more about the data integrity tradeoffs when using + partially verified price updates. + + ## Additional Resources You may find these additional resources helpful for developing your Solana application. From 8e116cbef0d12a973a513b77d741a66049b9e288 Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Fri, 10 Jan 2025 12:43:32 +0000 Subject: [PATCH 2/5] fix: update solana docs to hermes client --- .../price-feeds/use-real-time-data/solana.mdx | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pages/price-feeds/use-real-time-data/solana.mdx b/pages/price-feeds/use-real-time-data/solana.mdx index 1f5ddd21..0b76f6a2 100644 --- a/pages/price-feeds/use-real-time-data/solana.mdx +++ b/pages/price-feeds/use-real-time-data/solana.mdx @@ -29,11 +29,11 @@ If you are on `v0.30.0{:js}` or any other version, please move to `v0.30.1{:js}` ### Typescript SDK -Pyth provides two Typescript packages, [@pythnetwork/price-service-client](https://github.com/pyth-network/pyth-crosschain/tree/main/price_service/client/js) and [@pythnetwork/pyth-solana-receiver](https://github.com/pyth-network/pyth-crosschain/tree/main/target_chains/solana/sdk/js/pyth_solana_receiver), for fetching Pyth prices and submitting them to the blockchain respectively. +Pyth provides two Typescript packages, [@pythnetwork/hermes-client](https://github.com/pyth-network/pyth-crosschain/tree/main/apps/hermes/client/js) and [@pythnetwork/pyth-solana-receiver](https://github.com/pyth-network/pyth-crosschain/tree/main/target_chains/solana/sdk/js/pyth_solana_receiver), for fetching Pyth prices and submitting them to the blockchain respectively. Add these packages to your off-chain dependencies: ```bash copy -npm install --save @pythnetwork/price-service-client @pythnetwork/pyth-solana-receiver +npm install --save @pythnetwork/hermes-client @pythnetwork/pyth-solana-receiver ``` ## Write Contract Code @@ -155,24 +155,27 @@ To use price update accounts, the frontend code needs to perform two different t #### Fetch price updates -Use `PriceServiceConnection` from `@pythnetwork/price-service-client` to fetch Pyth price updates from Hermes: +Use `PriceServiceConnection` from `@pythnetwork/hermes-client` to fetch Pyth price updates from Hermes: ```typescript copy -import { PriceServiceConnection } from "@pythnetwork/price-service-client"; +import { HermesClient } from "@pythnetwork/hermes-client"; // The URL below is a public Hermes instance operated by the Pyth Data Association. // Hermes is also available from several third-party providers listed here: // https://docs.pyth.network/price-feeds/api-instances-and-providers/hermes -const priceServiceConnection = new PriceServiceConnection( +const priceServiceConnection = new HermesClient( "https://hermes.pyth.network/", - { priceFeedRequestConfig: { binary: true } } + {} ); // Hermes provides other methods for retrieving price updates. See // https://hermes.pyth.network/docs for more information. -const priceUpdateData: string[] = await priceServiceConnection.getLatestVaas([ - "0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43", -]); +const priceUpdateData = ( + await priceServiceConnection.getLatestPriceUpdates( + ["0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43"], + { encoding: "base64" } + ) +).binary.data; // Price updates are strings of base64-enco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BtnlSkHcWEABIp74UFLiiA+MBBvBzhLBxSTKXldiLJ75+U/eqK/ej6qT+I+6S1pzT/ntXdpD25jmQhjtsYEqs/rmgs5U2p4AVRAGYULPcAAAAAABrhAfrtrFhR4yubI7X5QRqMK6xKrj7U3XuBHdGnLqSqcQAAAAAC8IR2AUFVV1YAAAAAAAf6dUkAACcQMZv+5jfvAe6sflX1cL7xu9WWQ9UBAFUA5i32yLSoX+GmfbRNwS3l2zMPesZrctxliv7fD0pBW0MAAAaBiqrXwAAAAADYu55y////+AAAAABmFCz3AAAAAGYULPYAAAaFH6MbAAAAAADcBIdMCre0t06ngCnw+N4IkFpZVqOz9YuwKL+UFdt13ZBtay0YZnkw7QGoaTDCLlsNK1tk1F/qgMyOcYozjOTj41XriIpEPeG2HPYl+u0CKolGlCsz1IDu4w2lyh6LWVaMkEybGz7ih4H2RqCj6BVu182ZqsZgJx9ghzKImAo4cIlWzRTwpm4daAqHa4JEyimFDpFt6UeqvS5TNu2F8W+X+edeiph20EulTI7sx38jwhq5Yc0Mf2ElvFgToGQ806Vs2HynuLwh9OIuTTZh"] From f776909b1ec31fa34bdf368dcb3cacf07fa2b944 Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Fri, 5 Sep 2025 16:22:28 -0700 Subject: [PATCH 3/5] do it --- pages/price-feeds/use-real-time-data/solana.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/price-feeds/use-real-time-data/solana.mdx b/pages/price-feeds/use-real-time-data/solana.mdx index 0b76f6a2..77221097 100644 --- a/pages/price-feeds/use-real-time-data/solana.mdx +++ b/pages/price-feeds/use-real-time-data/solana.mdx @@ -23,8 +23,8 @@ pyth-solana-receiver-sdk ="x.y.z" # get the latest version from https://crates.i ``` -At the time of writing, [pyth-solana-receiver-sdk](https://github.com/pyth-network/pyth-crosschain/tree/main/target_chains/solana/pyth_solana_receiver_sdk) is compatible with Anchor `v0.28.0{:js}`, `v0.29.0{:js}`, and `v0.30.1{:js}`. -If you are on `v0.30.0{:js}` or any other version, please move to `v0.30.1{:js}`. +At the time of writing, [pyth-solana-receiver-sdk](https://github.com/pyth-network/pyth-crosschain/tree/main/target_chains/solana/pyth_solana_receiver_sdk) is compatible with Anchor `v0.28.0{:js}`, `v0.29.0{:js}`, `v0.30.1{:js}` and `v0.31.1{:js}`. +If you are on any other version, please move to `v0.31.1{:js}`. This [repository](https://github.com/guibescos/anchor-pyth/tree/main/programs/anchor-pyth) contains minimal working Solana programs for all these versions. ### Typescript SDK From 966727f66d10ca7a516dc1cd02d63c77bb909ad4 Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Fri, 5 Sep 2025 16:25:35 -0700 Subject: [PATCH 4/5] go --- pages/price-feeds/use-real-time-data/solana.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/price-feeds/use-real-time-data/solana.mdx b/pages/price-feeds/use-real-time-data/solana.mdx index 95ef5d5f..f577b335 100644 --- a/pages/price-feeds/use-real-time-data/solana.mdx +++ b/pages/price-feeds/use-real-time-data/solana.mdx @@ -24,7 +24,7 @@ pyth-solana-receiver-sdk ="x.y.z" # get the latest version from https://crates.i At the time of writing, [pyth-solana-receiver-sdk](https://github.com/pyth-network/pyth-crosschain/tree/main/target_chains/solana/pyth_solana_receiver_sdk) is compatible with Anchor `v0.28.0{:js}`, `v0.29.0{:js}`, `v0.30.1{:js}` and `v0.31.1{:js}`. -If you are on any other version, please move to `v0.31.1{:js}`. This [repository](https://github.com/guibescos/anchor-pyth/tree/main/programs/anchor-pyth) contains minimal working Solana programs for all these versions. +If you are on any other version, please move to `v0.31.1{:js}`. This [repository](https://github.com/guibescos/anchor-pyth/tree/main/programs/anchor-pyth) has branch for each of these versions containing a minimal working Solana program. ### Typescript SDK From edb95ca3deda47e6001e33a0ac06caad962f50e5 Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Fri, 5 Sep 2025 16:29:39 -0700 Subject: [PATCH 5/5] go --- pages/price-feeds/use-real-time-data/solana.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/price-feeds/use-real-time-data/solana.mdx b/pages/price-feeds/use-real-time-data/solana.mdx index f577b335..262e442c 100644 --- a/pages/price-feeds/use-real-time-data/solana.mdx +++ b/pages/price-feeds/use-real-time-data/solana.mdx @@ -24,7 +24,7 @@ pyth-solana-receiver-sdk ="x.y.z" # get the latest version from https://crates.i At the time of writing, [pyth-solana-receiver-sdk](https://github.com/pyth-network/pyth-crosschain/tree/main/target_chains/solana/pyth_solana_receiver_sdk) is compatible with Anchor `v0.28.0{:js}`, `v0.29.0{:js}`, `v0.30.1{:js}` and `v0.31.1{:js}`. -If you are on any other version, please move to `v0.31.1{:js}`. This [repository](https://github.com/guibescos/anchor-pyth/tree/main/programs/anchor-pyth) has branch for each of these versions containing a minimal working Solana program. +If you are on any other version, please move to `v0.31.1{:js}`. This [repository](https://github.com/guibescos/anchor-pyth/tree/main/programs/anchor-pyth) has a branch for each of these versions containing a minimal working Solana program. ### Typescript SDK