# Encountering error using price feeds

**URL:** <https://dev-forum.pyth.network/t/encountering-error-using-price-feeds/263>\
**Category:** Price Feeds\
**Created:** [July 3, 2025, 8:34pm UTC](https://dev-forum.pyth.network/t/encountering-error-using-price-feeds/263 "2025-07-03T20:34:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![strawberry](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@strawberry](https://dev-forum.pyth.network/u/strawberry)\
**Post date:** [July 3, 2025, 8:34pm UTC](https://dev-forum.pyth.network/t/encountering-error-using-price-feeds/263/1 "2025-07-03T20:34:37Z")

</div>

Hi, I am encountering an error when trying to use pyth-sdk-solidity, I am hoping somebody here can spot the problem.

I am deploying on Flow Testnet.

This is the contract code:

```auto
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import "@pythnetwork/pyth-sdk-solidity/IPyth.sol";
import "@pythnetwork/pyth-sdk-solidity/PythStructs.sol";

//This contract uses Pyth
contract FlowUsdPriceFeed {
    IPyth pyth;
    bytes32 flowusd_identifier;

    uint256 private alpha = 1e18; //Smoothing factor

    /**
     * @param pythContract The address of the Pyth contract 0x2880aB155794e7179c9eE2e38200202908C17B43
     _flow_usd_identifier is Crypto.FLOW/USD 0x2fb245b9a84554a0f15aa123cbb5f64cd263b59e9a87d80148cbffab50c69f30 stable
     */
    constructor(address pythContract, bytes32 _flowusd_identifier) {
        // The IPyth interface from pyth-sdk-solidity provides the methods to interact with the Pyth contract.
        // Instantiate it with the Pyth contract address from https://docs.pyth.network/price-feeds/contract-addresses/evm
        pyth = IPyth(pythContract);
        flowusd_identifier = _flowusd_identifier;
    }

    //Returns the mantissa and the expo which is negative
    function getPrice() external view returns (int64, int32) {
        PythStructs.Price memory price = pyth.getPriceNoOlderThan(
            flowusd_identifier,
            60 
        );
        return (price.price, price.expo);
    }

    /**
     * @notice Returns the EWMA price using new oracle data
     * @param mantissa The raw integer price from the oracle (e.g., 4049444)
     * @param exponent The number of decimals the mantissa should be divided by (e.g., 8)
     */

    function getEWMAPrice(
        uint256 mantissa,
        uint256 exponent
    ) external pure returns (uint256) {
        require(exponent <= 77, "Exponent too large"); // Prevent overflow: 10^77 is close to uint256 max
        uint256 denominator = 10 ** exponent;

        // Convert price to fixed-point (1e18 scale)
        uint256 price = (mantissa * 1e18) / denominator;

        return price;
    }
}

```

When trying to call the getPrice function with ethers.js, the function reverts:  
`Error: execution reverted (unknown custom error) `

The address of the pyth contract is : 0x2880aB155794e7179c9eE2e38200202908C17B43  
The identifier for the price feed is : 0x2fb245b9a84554a0f15aa123cbb5f64cd263b59e9a87d80148cbffab50c69f30

---

<div class="post-metadata">

**Author:** ![Aditya520](https://yyz2.discourse-cdn.com/flex034/user_avatar/dev-forum.pyth.network/aditya520/32/12_2.png) [@Aditya520](https://dev-forum.pyth.network/u/Aditya520)\
**Post date:** [July 3, 2025, 10:11pm UTC](https://dev-forum.pyth.network/t/encountering-error-using-price-feeds/263/2 "2025-07-03T22:11:11Z")

</div>

> [@strawberry](#):
>
> When trying to call the getPrice function with ethers.js, the function reverts:  
> `Error: execution reverted (unknown custom error) `

Hey, are you [updating](https://arc.net/l/quote/bitacpoy) the prices before calling the method?

You can try the same method [here in our API Reference](https://api-reference.pyth.network/price-feeds/evm/getEmaPriceUnsafe).

---

<div class="post-metadata">

**Author:** ![strawberry](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@strawberry](https://dev-forum.pyth.network/u/strawberry)\
**Post date:** [July 4, 2025, 3:55pm UTC](https://dev-forum.pyth.network/t/encountering-error-using-price-feeds/263/3 "2025-07-04T15:55:50Z")

</div>

Thanks for the reply.

What I needed was the `getEmaPriceUnsafe` so I can call the function from a view function without paying for an update.
