Custom error 0x6ce2251a

Just a simple price feed function following the docs to retrieve price of ETH to USD, however it reverted with this error: 0x6ce2251a

Here is my script for interacting and the priceUpdate array is retrieve from Hermes, I think the array is correct because the parsed data is there.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

import {Script, console} from "forge-std/Script.sol";
import {PythPriceFeed} from "src/PythPriceFeed.sol";
import {Vm} from "forge-std/Vm.sol";
import {PythStructs} from "@pythnetwork/pyth-sdk-solidity/PythStructs.sol";

contract GetETHUSDPrice is Script {
    PythPriceFeed pythPriceFeed;

    function run() external {
        address pythContract = Vm(address(vm)).getDeployment(
            "PythPriceFeed",
            uint64(block.chainid)
        );

        pythPriceFeed = PythPriceFeed(payable(pythContract));
        bytes[] memory priceUpdate = new bytes[](1);
        priceUpdate[
            0
        ] = "0x...";

        vm.startBroadcast();
        PythStructs.Price memory price = pythPriceFeed.getEThUSDPrice(
            priceUpdate
        );
        vm.stopBroadcast();
        console.log("ETH/USD Price: ", price.price);
    }
}

I have also funded a few eth to my contract on Chain Sepolia: PythPriceFeed | Address 0x2127c26e297ae9782f41d99049ffc1051a157c9e | Etherscan

Here are the full logs:

0x2127C26e297aE9782f41D99049fFc1051A157C9E::getEThUSDPrice([0x..])
    β”‚   β”œβ”€ [9168] ERC1967Proxy::fallback([0x...]) [staticcall]
    β”‚   β”‚   β”œβ”€ [3755] PythUpgradable::getUpdateFee([0x...]) [delegatecall]
    β”‚   β”‚   β”‚   └─ ← [Return] 1
    β”‚   β”‚   └─ ← [Return] 1
    β”‚   β”œβ”€ [14566] ERC1967Proxy::fallback{value: 1}([0x..])
    β”‚   β”‚   β”œβ”€ [13652] PythUpgradable::updatePriceFeeds{value: 1}([0x..]) [delegatecall]
    β”‚   β”‚   β”‚   β”œβ”€ [6255] 0x41c9e39574F40Ad34c79f1C99B66A45eFB830d4c::parseAndVerifyVM(0x..) [staticcall]
    β”‚   β”‚   β”‚   β”‚   β”œβ”€ [854] 0x8D254a21b3C86D32F7179855531CE99164721933::parseAndVerifyVM(0x..) [delegatecall]
    β”‚   β”‚   β”‚   β”‚   β”‚   └─ ← [Revert] custom error 0x6ce2251a
    β”‚   β”‚   β”‚   β”‚   └─ ← [Revert] custom error 0x6ce2251a
    β”‚   β”‚   β”‚   └─ ← [Revert] custom error 0x6ce2251a
    β”‚   β”‚   └─ ← [Revert] custom error 0x6ce2251a
    β”‚   └─ ← [Revert] custom error 0x6ce2251a
    └─ ← [Revert] custom error 0x6ce2251a

Hey @LuoYingjie

Congratulations on your first post. Thank you for sharing the code and the logs.

I see you are generating the parsed data here.

        priceUpdate[
            0
        ] = "0x...";

Please use the data from hermes using the methods listed in How to Fetch Price Updates

When anyone passes price updates, the contract checks it for the verification as shown in the full logs.

    β”‚   β”‚   β”‚   β”œβ”€ [6255] 0x41c9e39574F40Ad34c79f1C99B66A45eFB830d4c::parseAndVerifyVM(0x..) [staticcall]

YES, I’m taking the data from the docs with this command below:

curl -X 'GET' 'https://hermes.pyth.network/v2/updates/price/latest?ids%5B%5D=0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace'

However, it still reverts..

The data looks like this:

0x504e41550100000003b80100000004....

But, not working.

The data looks correct, but can you run your script with your data here.

        priceUpdate[
            0
        ] = "0x...";

Just making sure that you are inserting data here before proceeding ahead.

That’s exactly what I do, I have inserted data there but not working.

Can you share your contract and the script in a gist? I will run it locally and get back to you.

Surely yes, here is the link:

Only one contract there and the script is: GetETHUSDPrice.s.sol

You can get the priceUpdate by running

make get-price-update

And the for getting the price feed you need to first deploy the contract and send a bit eth to the contract, then run

make get-eth-usd-price

You could also run the script in your preferred way. Thanks a lot for checking this!

Have you deployed the contract on any testnet and tried interacting with it?
It looks like forge scripts somehow creates a fork in the backend for these operations and create a transaction object for you to send it.

Refer to this post.

Ohhhhh god it worked!

I just deployed a new one and the transaction succeed!

Thanks a lot bro for checking!

1 Like