Reputation: 1
Why did remix give a NOT FOUND
error?
(I knew safemath
is not necessary since v0.8.)
code:
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.6 <0.9.0;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";
contract FundMe {
using SafeMathChainlink for uint256;
mapping(address => uint256) public addressToAmountFunded;
address[] public funders;
address public owner;
constructor() public {
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){
AggregatorV3Interface priceFeed = AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e);
return priceFeed.version();
}
function getPrice() public view returns(uint256){
AggregatorV3Interface priceFeed = AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e);
(,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;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function withdraw() payable onlyOwner public {
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);
}
}
Errror: not found "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol"
I use same code FundMe.sol via Patrick Collins github lesson3 here is the error
Upvotes: 0
Views: 1524
Reputation: 11
Simple Suggestion: create a new contract file undername "SafeMathChainlink.sol and given code below in contract folder, and put a code import "./SafeMathChainlink.sol" in FundMe.sol instead of giving chainlink;
Upvotes: 1
Reputation: 81
pragma solidity >=0.6.0 <0.9.0;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol"; import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";
COMPILER👇
0.6.6+commit.6c089d02
Upvotes: 1
Reputation: 31
If you came here following the "Solidity, Blockchain, and Smart Contract Course – Beginner to Expert Python Tutorial" course by Patrick Collins; here's what you need to change to make this work:
If you get this error:
ParserError: Source file requires different compiler version (current compiler is 0.8.11+commit.d7f03943.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version
--> @chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol:2:1:
|
2 | pragma solidity ^0.6.0;
| ^^^^^^^^^^^^^^^^^^^^^^^
Make sure:
pragma solidity ^0.6.0;
(or similar; i.e.: pragma solidity >=0.6.6 <0.9.0;
) at the top of your contract,pragma solidity ^0.6.0;
)Upvotes: 0