Price feed in Avalanche not working

I have trouble using the Core - Push based to get the price feed in Avalanche fuji network. I used the pyth contract 0x23f0e8FAeE7bbb405E7A7C3d60138FCfd43d7509. And gave price feed ID ETH/USD as given in the documentation.

PythStructs.Price memory priceObject = pyth.getPriceNoOlderThan(0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace, 60);

I called the view function

An unexpected error occurred:

Error: execution reverted (unknown custom error) (action=“call”, data=“0x19abf40e”, reason=null, transaction={ “data”: “0x8fe20099”, “to”: “0xef…sD” }, invocation=null, revert=null, code=CALL_EXCEPTION, version=6.15.0)

Am I missing something with the exact price feed ID for avalanche fuji testnet? Thank you in advance.

The contract is correct: 0x23f0e8FAeE7bbb405E7A7C3d60138FCfd43d7509

The ETH/USD price feed is indeed: 0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace ; ids page.

The error you are encountering is because the price of ETH/USD has not been updated recently enough on Avanlanche testnet.

You can check here the classic errors on EVMs and how to troubleshoot those.

In your case, to resolve this issue:

  • Update the prices by calling updatePriceFeeds() by passing the latest updateData from Hermes.
  • Another method to fetch the price is getPriceUnsafe() If the price feed is available, the method will return the latest prices with timestamp of last update. NOTE: getPriceUnsafe() method does not check the freshness of the price.

To make sure you are getting sufficient price updates automatically, you can also run the Price pusher