pyth-network / pyth-crosschain

Crosschain Pyth programs and utilities
https://pyth.network
Other
144 stars 195 forks source link

Pyth Network on Hedera #1355

Closed quiet-node closed 7 months ago

quiet-node commented 7 months ago

Hello! I'm currently delving into Pyth Network on Hedera, but I'm encountering some issues getting it to work.

I've created a simple contract:

contract PythPriceFeed {
    /// @notice HBAR/USD price feed ID can be found here: [Pyth Network Price Feed IDs](https://pyth.network/developers/price-feed-ids)
    bytes32 constant HBAR_USD_PRICE_ID = 0x3728e591097635310e6341af53db8b7ee42da9b3a8d918f9463ce9cca886dfbd;

    /// @notice Pyth contract addresses can be found here: [Pyth Network Contract Addresses](https://docs.pyth.network/price-feeds/contract-addresses/evm)
    address constant TESTNET_PYTH_CONTRACT_ADDRESS = 0xA2aa501b19aff244D90cc15a4Cf739D2725B5729;

    /// @dev Initialize Pyth instance
    IPyth pyth;

    constructor() {
        pyth = IPyth(TESTNET_PYTH_CONTRACT_ADDRESS);
    }

    function getPrice(bytes32 _priceId) view external returns (PythStructs.Price memory) {
        return pyth.getPrice(_priceId);
    }
}

I deployed this contract using Remix IDE and verified it on the Hedera testnet, which can be found here. However, when I attempt to call the .getPrice() method, the transaction is reverted with the error CONTRACT_REVERT_EXECUTED:

call to PythPriceFeed.getPrice
call to PythPriceFeed.getPrice errored: Error occurred: [Request ID: f7d0511e-23c2-4ab9-8804-6f4a82d8666e] execution reverted: CONTRACT_REVERT_EXECUTED.

[Request ID: f7d0511e-23c2-4ab9-8804-6f4a82d8666e] execution reverted: CONTRACT_REVERT_EXECUTED

In addition to the above, I went to your API reference on your docs page at https://docs.pyth.network/price-feeds/api-reference/evm/get-price to try out the getPrice() method, the transaction there also get reverted but with StalePrice()

Screenshot 2024-03-12 at 6 06 57 PM

Do you think the SDK is down or has some problems?

Would appreciate any insights or help debugging this.

quiet-node commented 7 months ago

Ah figured it out I must update prices first before calling other APIs

function updatePriceFeed(bytes[] calldata pythPriceUpdateData) external payable {
        uint value = pyth.getUpdateFee(pythPriceUpdateData);
        pyth.updatePriceFeeds{ value: value }(pythPriceUpdateData);
}