0
ParserError: Source "@openzeppelin/contracts/token/ERC20/ERC20.sol" not found: File not found.

当我在默认的本地 ganache-cli 上部署 brownie 时。

命令:

$ brownie compile

得到:

Brownie v1.17.2 - Python development framework for Ethereum

Compiling contracts...
  Solc version: 0.8.11
  Optimizer: Enabled  Runs: 200
  EVM Version: Istanbul
CompilerError: solc returned the following errors:

ParserError: Source "@openzeppelin/contracts/token/ERC20/ERC20.sol" not found: File not found.

令牌文件头:

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract InvestToken is ERC20 {

brownie-config.yaml 文件:

dependencies:
  # - <organization/repo>@<version>
  - OpenZeppelin/openzeppelin-contracts@4.4.2
compiler:
  solc:
    remappings:
      - '@openzeppelin = OpenZeppelin/openzeppelin-contracts@4.4.2'

命令:

$brownie pm install OpenZeppelin/openzeppelin-contracts@4.4.2

得到:

FileExistsError("Package is aleady installed")
4

1 回答 1

1

我在 brownie-config.yaml 文件中犯了一个错误:

我写:

remappings:
      - '@openzeppelin = OpenZeppelin/openzeppelin-contracts@4.4.2'

它是

remappings:
      - '@openzeppelin=OpenZeppelin/openzeppelin-contracts@4.4.2'

对于那个很抱歉

于 2022-01-13T02:05:41.637 回答