1

I want to verify the contract using the API etherscan token

FundMe.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import"node_modules/@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; 
import"node_modules/@openzeppelin/contracts/utils/math/SafeMath.sol";


contract FundMe {
    

    mapping(address => uint256) public addressToAmountFunded;
    address[] public funders;
    address public owner;
    AggregatorV3Interface public priceFeed;
    
    // if you're following along with the freecodecamp video
    // Please see https://github.com/PatrickAlphaC/fund_me
    // to get the starting solidity contract code, it'll be slightly different than this!
  constructor() public {
        priceFeed = AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e);
        owner = msg.sender;
    }

    function fund() public payable {
        uint256 minimumUSD = 50 * 10**18;
        require(
            getConversionRate(msg.value) >= minimumUSD,
            "You need to spend more ETH!"
        );
        addressToAmountFunded[msg.sender] += msg.value;
        funders.push(msg.sender);
    }

    function getVersion() public view returns (uint256) {
        return priceFeed.version();
    }

    function getPrice() public view returns (uint256) {
        (, int256 answer, , , ) = priceFeed.latestRoundData();
        return uint256(answer * 10000000000);
    }

    // 1000000000
    function getConversionRate(uint256 ethAmount)
        public
        view
        returns (uint256)
    {
        uint256 ethPrice = getPrice();
        uint256 ethAmountInUsd = (ethPrice * ethAmount) / 1000000000000000000;
        return ethAmountInUsd;
    }

    function getEntranceFee() public view returns (uint256) {
        // minimumUSD
        uint256 minimumUSD = 50 * 10**18;
        uint256 price = getPrice();
        uint256 precision = 1 * 10**18;
        // return (minimumUSD * precision) / price;
        // We fixed a rounding error found in the video by adding one!
        return ((minimumUSD * precision) / price) + 1;
    }

    modifier onlyOwner() {
        require(msg.sender == owner);
        _;
    }

   
    function withdraw() public payable onlyOwner {
        payable(msg.sender).transfer(address(this).balance);

        for (
            uint256 funderIndex = 0;
            funderIndex < funders.length;
            funderIndex++
        ) {
            address funder = funders[funderIndex];
            addressToAmountFunded[funder] = 0;
        }
        funders = new address[](0);
    }
}

deploy.py

from brownie import FundMe
from scripts.helpful_scripts import get_account





def deploy_fund_me():
  account= get_account()
  # firstly we deploy our contract and then we need to verfiy and publish our smartcontract in etherscan 
  fund_me= FundMe.deploy({"from": account}, publish_source=True)
  print(f"Contract deployed to {fund_me.address}")
    


def main():
    deploy_fund_me()

Error that I have enter image description here

The File path of the AggregatorV3Interface.sol

enter image description here

How to sort this bug ? as the error path is different the the AggregatorV3Interface.sol one

1 Answer 1

0

Try importing it as:

import"https://raw.githubusercontent.com/smartcontractkit/chainlink/develop/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; 

enter image description here

2
  • Tried not working Mar 28 at 10:57
  • Check updated post - another approach: using SafeMath.sol, you can use Solidity's built-in overflow checking functions. For example, instead of (ethPrice * ethAmount) / 1000000000000000000;, you can use ethPrice.mul(ethAmount).div(1e18); where mul is equivalent to * and div is equivalent to /. This saves gas by eliminating the need for an external library.
    – VX3
    Mar 28 at 14:59

Your Answer

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

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