0

I'm trying to get the version to show up when I test it but keep receiving this message.

call to FundMe.getVersion errored: VM execution error. Reverted 0x

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.6 <0.9.0;

interface AggregatorV3Interface {

  function decimals()
    external view returns (
        uint8
    );

  function description()
    external view returns (
        string memory
    );

  function version()
    external view returns (
      uint256
    );

  // getRoundData and latestRoundData should both raise "No data present"
  // if they do not have data to report, instead of returning unset values
  // which could be misinterpreted as actual reported values.
  function getRoundData(
    uint80 _roundId
  )
    external view returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

  function latestRoundData()
    external view returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

}

contract FundMe {

    mapping(address =>uint256) public addressToAmountFunded;

    function fund() public payable {
        addressToAmountFunded[msg.sender] += msg.value;
        //What the eth --> usd conversion rate
    }

    function getVersion() public view returns (uint256) {
        AggregatorV3Interface priceFeed = AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e);
        return priceFeed.version();
    }
}

3 Answers 3

0

Change your address to 0x9326BFA02ADD2366b30bacB125260Af641031331.

Replace this: AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e);

with this:

AggregatorV3Interface(0x9326BFA02ADD2366b30bacB125260Af641031331);

0

If you are using Rinkeby test network, try switching to Kovan test network. Use the address 0x9326BFA02ADD2366b30bacB125260Af641031331 for ETH-USD. It worked for me I was getting the same error.

0

In case its helpful to someone that comes here from google, my issue was that I had a typo in a method declaration in the AggregatorV3Interface interface. I erroneously had wrote lastestRoundData instead of latestRoundData (extra "s").

Since the solidity compiler of course knows nothing about the actual interface, it took my typo as the true name and didn't raise any other warnings.

If you copy & paste the actual interface instead of trying to hand type it like me you'll avoid this error. For convenience, here is the correct AggregatorV3Interface

  function decimals() external view returns (uint8);

  function description() external view returns (string memory);

  function version() external view returns (uint256);

  // getRoundData and latestRoundData should both raise "No data present"
  // if they do not have data to report, instead of returning unset values
  // which could be misinterpreted as actual reported values.
  function getRoundData(uint80 _roundId)
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

  function latestRoundData()
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );
}

source https://github.com/smartcontractkit/chainlink/blob/develop/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.