smartcontractkit / full-blockchain-solidity-course-py

Ultimate Solidity, Blockchain, and Smart Contract - Beginner to Expert Full Course | Python Edition
MIT License
10.67k stars 2.89k forks source link

Lesson3 call to FundMe.getVersion error #1877

Closed JeremieWU23 closed 1 year ago

JeremieWU23 commented 1 year ago

When I call FundMe.getVersion like 2:47:28 in the video, an error occurs:

call to FundMe.getVersion errored: Returned error: {"jsonrpc":"2.0","error":"execution reverted","id":6025129915402084}

and there is no result below the bottom getVersion.

What is the problem? Here is my code and I check that this is the same as the codes in the video.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface AggregatorV3Interface {
  function decimals() external view returns (uint8);
  function description() external view returns (string memory);
  function version() external view returns (uint256);

  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 addToAmount;

    function fund() public payable {
        addToAmount[msg.sender] += msg.value;
    }

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

Help will be Appreciated !!

JeremieWU23 commented 1 year ago

I use another testnet's price feed address, after changing to Sepolia Testnet it works !