我正在尝试在我的本地机器上测试和复制 FundMe.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.6
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 {
uint minimumUSD = 50 * 10 ** 18;
require(getConversionRate(msg.value) >= minimumUSD, "You need to spend more ETH! reminder by: Marco Rado");
addressToAmountFunded[msg.sender] += msg.value;
funders.push(msg.sender);
}
function getVersion() public view returns (uint256) {
AggregatorV3Interface priceFeed = AggregatorV3Interface(0x9326BFA02ADD2366b30bacB125260Af641031331);
return priceFeed.version();
}
function getPrice() public view returns(uint256) {
AggregatorV3Interface priceFeed = AggregatorV3Interface(0x9326BFA02ADD2366b30bacB125260Af641031331);
(,int256 answer,,,) = priceFeed.latestRoundData();
return uint256(answer * 10000000000);
//4,143.080000000000000000
}
function getConversionRate(uint256 ethAmount) public view returns (uint256) {
uint ethPrice = getPrice();
uint 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);
}
}
带有 brownie-config.yaml
dependencies:
- smartcontractkit/chainlink-brownie-contracts@1.2.0
compiler:
solc:
remappings:
- '@chainlink=smartcontractkit/chainlink-brownie-contracts@1.2.0'
但是当我编译时使用:brownie compile
我得到了这个 ValueError:
marco@MarcoD2-5212019 MINGW64 ~/Documents/Blockchain/Smart Contracts University/demos/brownie_fund_me (main) $ brownie compile INFO: 找不到给定模式的文件。Brownie v1.16.3 - 以太坊的 Python 开发框架
文件“C:\Users\marco.local\pipx\venvs\eth-brownie\lib\site-packages\brownie_cli_main _.py ”,第 64 行,在 main importlib.import_module(f"brownie._cli.{cmd} ").main() 文件“C:\Users\marco.local\pipx\venvs\eth-brownie\lib\site-packages\brownie_cli\compile.py”,第 50 行,在 main proj = project.load()文件“C:\Users\marco.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\main.py”,第 745 行,在加载返回项目(名称,project_path)文件“C: \Users\marco.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\main.py",第 180 行,在init self.load() 文件“C:\Users\marco.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\main.py”,第 235 行,加载 self._compile(已更改, self._compiler_config, False) 文件“C:\Users\marco.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\main.py”,第 102 行,编译优化器=compiler_config[” solc"].get("优化器", 无), 文件 "C:\Users\marco.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\ compiler_init.py”,第 105 行,compile_and_format find_solc_versions(solc_sources, install_needed=True,silent=silent) 文件“C:\Users\marco.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\ compiler\solidity.py",第 150 行,在 find_solc_versions pragma_specs[path] = sources.get_pragma_spec(source, path) File "C:\Users\marco.local\pipx\venvs\eth-brownie\lib\site-packages\ brownie\project\sources.py”,第 218 行,在 get_pragma_spec 返回 NpmSpec(pragma_string) 文件“C:\Users\marco.local\pipx\venvs\eth-brownie\lib\site-packages\semantic_version\base.py” ,第 618 行,在初始化中 self.clause = self._parse_to_clause(expression) File "C:\Users\marco.local\pipx\venvs\eth-brownie\lib\site-packages\semantic_version\base.py",第 1225 行,在 _parse_to_clause 中返回 cls。 Parser.parse(expression) File "C:\Users\marco.local\pipx\venvs\eth-brownie\lib\site-packages\semantic_version\base.py",第 1265 行,解析中引发 ValueError("Invalid NPM block在 %r: %r" % (expression, block)) ValueError: Invalid NPM block in '^0.6.6 import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol"': 'import'
marco@MarcoD2-5212019 MINGW64 ~/Documents/Blockchain/Smart Contracts University/demos/brownie_fund_me(主要)