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

Viewed 100

How do I fix this issue?

The 0x5f4e... address hardcoded in your getVersion() function doesn't hold any smart contract on the Kovan testnet (link). Even though it has a contract deployed on the mainnet, these environments are separated.
When there's no smart contract on the address, there's nothing to send a response to the internal call. Your code expects an uint256 response from the version() call, so that it can return it from the getVersion().

When it doesn't receive the expected response, it throws an exception, effectively reverting the "main" call.

/ 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();
    }
}
2 Answers
    AggregatorV3Interface priceFeed = AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e);

I checked the address that u used here "0x8A753747A1Fa494EC906cE90E9f37563A8AF630e" found in 4 different chains.

Rinkeby, Kovan, Ropsten, BscScan. Looks like your metamask is connected to Kovan but contract is not deployed to Kovav. Verify which chain your contract is connected and connect to that network in Metamask

Once check the contract is selected correct, If you select AggregationV3Interface contract and deploy it throws this error, select the sol file you are working on and try XD

Related