# Pyth push update simulations

**URL:** <https://dev-forum.pyth.network/t/pyth-push-update-simulations/70>\
**Category:** Price Feeds\
**Created:** [April 17, 2025, 3:52pm UTC](https://dev-forum.pyth.network/t/pyth-push-update-simulations/70 "2025-04-17T15:52:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cryptomiester](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@cryptomiester](https://dev-forum.pyth.network/u/cryptomiester)\
**Post date:** [April 17, 2025, 3:52pm UTC](https://dev-forum.pyth.network/t/pyth-push-update-simulations/70/1 "2025-04-17T15:52:37Z")

</div>

gm team, we integrated pyth on sonic svm. everything works nicely.

the problem is the push transaction happens in three tranasctions and the simulation fails for our transaction.

the transaction can be sent with skipPreflight tho.

is there any ideal flow I can use so that it simulations would not fail? due to price feed not being stale.

I followed this example’s method of addPriceConsumerInstructions()

> <https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/solana/send_usd/app/src/App.tsx>

example of what the end user would see.

 ![image](https://canada1.discourse-cdn.com/flex034/uploads/dev_pyth/original/1X/97664dc86f820c7ea52c8ea99c7735ed36a33e0f.png)

---

<div class="post-metadata">

**Author:** ![tejas\_pyth](https://avatars.discourse-cdn.com/v4/letter/t/a698b9/32.png) [@tejas\_pyth](https://dev-forum.pyth.network/u/tejas_pyth)\
**Post date:** [April 17, 2025, 5:32pm UTC](https://dev-forum.pyth.network/t/pyth-push-update-simulations/70/2 "2025-04-17T17:32:29Z")

</div>

Gmgm, can you please share a snippet of your code that builds and sends the txs? And can you send the exact error log you’re getting in simulation?

---

<div class="post-metadata">

**Author:** ![cryptomiester](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@cryptomiester](https://dev-forum.pyth.network/u/cryptomiester)\
**Post date:** [April 18, 2025, 6:14am UTC](https://dev-forum.pyth.network/t/pyth-push-update-simulations/70/3 "2025-04-18T06:14:48Z")

</div>

on chain we have price stale checker, we do a check for the price update for both the feed and the update account `PriceUpdateV2`

client code snippet:

```typescript
import { Wallet } from "@coral-xyz/anchor";
import {
    InstructionWithEphemeralSigners,
    PythSolanaReceiver,
} from "@pythnetwork/pyth-solana-receiver";
import { Connection } from "@solana/web3.js";
import { AnchorWallet } from "@solana/wallet-adapter-react";
import { HermesClient } from "@pythnetwork/hermes-client";

const HERMES_URL = "https://hermes.pyth.network/";

const SOL_PRICE_FEED_ID =
    "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d";

export async function postPriceUpdate(
    connection: Connection,
    wallet: AnchorWallet | undefined,
    instructions?: InstructionWithEphemeralSigners[],
) {
    if (!wallet) return;
    const hermesClient = new HermesClient(HERMES_URL);
    const pythSolanaReceiver = new PythSolanaReceiver({
        connection,
        wallet: wallet as Wallet,
    });

    const priceUpdateData = await hermesClient.getLatestPriceUpdates(
        [SOL_PRICE_FEED_ID],
        { encoding: "base64" },
    );
    const transactionBuilder = pythSolanaReceiver.newTransactionBuilder({
        closeUpdateAccounts: true,
    });
    const {
        postInstructions,
        closeInstructions,
    } = await pythSolanaReceiver.buildUpdatePriceFeedInstructions(
        priceUpdateData.binary.data,
        0,
    );
    transactionBuilder.closeInstructions.push(...closeInstructions);
    transactionBuilder.addInstructions(postInstructions);

    // add any instructions here
    if (instructions) {
        await transactionBuilder.addPriceConsumerInstructions(
            async (): Promise<InstructionWithEphemeralSigners[]> => {
                return [...instructions];
            },
        );
    }
    return await transactionBuilder.buildVersionedTransactions({
        computeUnitPriceMicroLamports: 0,
        tightComputeBudget: true,
    });
}

```

we use the shardId = 0. and if the price is stale after 300 seconds or 5 minutes. we throw an error on chain.

so simulations assume that the price is too old.

I’m assuming this is the reason you have skipPreflight = true in your examples.

what I want to know is if there is a flow that would make the simulations not fail.

---

<div class="post-metadata">

**Author:** ![tejas\_pyth](https://avatars.discourse-cdn.com/v4/letter/t/a698b9/32.png) [@tejas\_pyth](https://dev-forum.pyth.network/u/tejas_pyth)\
**Post date:** [April 18, 2025, 11:55pm UTC](https://dev-forum.pyth.network/t/pyth-push-update-simulations/70/4 "2025-04-18T23:55:42Z")

</div>

If you’re using the pull model (fetching & updating the price on-demand and inlining your app’s instructions,) I would suggest using `postPriceUpdate` instead of `updatePriceFeed`. This posts an ephemeral price update to the chain for your app to consume, instead of updating a feed (push model). It’s cheaper as well.

With `postPriceUpdate` from the sendusd example, I’m able to run the example with `skipPreflight=false` and I get a wallet popup without a “no simulation” warning:

 ![Untitled 6](https://canada1.discourse-cdn.com/flex034/uploads/dev_pyth/original/1X/45ad7d0aa3bccee5558249893f3ceb82f00b5f5c.png)

[Devnet tx here](https://solscan.io/tx/77u1zM9MzcfRg24B1NqEYYzvs2r8ixHHGCMkTFmpvHxXYyBdhtkhE3z6MCyrFK4gLU5Hi7DoWS3fLNny71dizpo?cluster=devnet).

It’s invoking the SendUSD app’s `transfer` function, which [enforces that the price is no older than 1 hour](https://github.com/pyth-network/pyth-examples/blob/main/price_feeds/solana/send_usd/program/src/lib.rs#L20).

Let me know if that works. If you do want to update the price feed versus posting a single update, lmk and I can help debug that side of things.

Info on single update (Price Update Account) vs updating a feed (Price Feed Account) here: [https://docs.pyth.network/price-feeds/use-real-time-data/solana#write-frontend-code](https://docs.pyth.network/price-feeds/use-real-time-data/solana#write-frontend-code)

---

<div class="post-metadata">

**Author:** ![cryptomiester](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@cryptomiester](https://dev-forum.pyth.network/u/cryptomiester)\
**Post date:** [April 19, 2025, 2:46pm UTC](https://dev-forum.pyth.network/t/pyth-push-update-simulations/70/5 "2025-04-19T14:46:44Z")

</div>

> [@tejas\_pyth](#):
>
> do want to update the price feed versus posting a single update, lmk and I can help debug that side of things.

the reason you are able to run this in one txn is that your sendUSD instruction is simple.

I have a complex instruction to create domains. its pretty hefty since we validate domains on chain.

we hardcode the on chain the price update account for safety reasons that’s why we use:

```auto
await pythSolanaReceiver.buildUpdatePriceFeedInstructions(
        priceUpdateData.binary.data,
        0,
    );

```

with shardId 0 or `7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE`

because I have noticed some programs don’t check for the owner for price\_update\_account.owner and in the heat of the moment when I wrote the program 11 months ago, I made sure to include the price update account but with a hardcode check. it did take me 30 minutes to integrate the onchain account price checker. so big ups there.  
 ![Screenshot 2025-04-19 at 18.36.59](https://canada1.discourse-cdn.com/flex034/uploads/dev_pyth/original/1X/e2b9eae5518eb69c25a15f432119123b46dddcab.png)

anywho, I believe I found my answer. I will have to rewrite some logic and make sure that the postPriceUpdate account is verified on our side.

the reason being is we add the price\_update\_account in the remaining\_accounts rather than have it in the list of anchor accounts.

and FYI, everything works nicely in solana. the above is on sonic svm chain.

since [Account 7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE | Solscan](https://solscan.io/account/7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE) always gets updated on solana.

thank you @tejas_pyth for your help. much appreciated.

---

<div class="post-metadata">

**Author:** ![tejas\_pyth](https://avatars.discourse-cdn.com/v4/letter/t/a698b9/32.png) [@tejas\_pyth](https://dev-forum.pyth.network/u/tejas_pyth)\
**Post date:** [April 21, 2025, 4:23pm UTC](https://dev-forum.pyth.network/t/pyth-push-update-simulations/70/6 "2025-04-21T16:23:44Z")

</div>

Ah I see, glad you were able to find your answer!

---

<div class="post-metadata">

**Author:** ![vincent](https://avatars.discourse-cdn.com/v4/letter/v/e9bcb4/32.png) [@vincent](https://dev-forum.pyth.network/u/vincent)\
**Post date:** [April 25, 2025, 6:37am UTC](https://dev-forum.pyth.network/t/pyth-push-update-simulations/70/7 "2025-04-25T06:37:45Z")

</div>

hey @cryptomiester, sorry but I saw that you said you’ve integrated pyth on sonic svm and everything is working, just wonder if you can share the snippet where you fetch the price? A couple tokens should be fine e.g. USDT, USDC, SONIC and maybe a meme token

thanks
