不支持文件导入回调? 第 1 步:第 2 步:第 3 步:

问题描述

尝试运行:

1.) Dappuniversity 项目 (dappuniversity/dbank) 2.) 宠物店教程

Truffle v5.3.3(核心:5.3.3) 节点 v14.15.5

当Truffle要求编译器/solc匹配5.3.3时,ser如何编译代码@0.8.4导入OpenZeppelin的ERC20.sol模板?

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

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

contract Token is ERC20 {

  //add minter variable

  //add minter changed event

  constructor() public payable ERC20("Name","Symbol") {

    //asign initial minter

  }

  //Add pass minter role function

  function mint(address account,uint256 amount) public {

    //check if msg.sender have minter role

    _mint(account,amount);

  }

}

找不到源“@openzeppelin/contracts/token/ERC20/ERC20.sol”:不支持文件导入回调

解决方法

错误:
Source "@openzeppelin/contracts/token/ERC20/ERC20.sol" not found: File import callback not supported enter image description here

第 1 步:

安装 Solidity 扩展 enter image description here

第 2 步:

  • 右键单击错误。
  • 选择“更改默认工作区...” enter image description here

第 3 步:

选择localNodeModule
可能需要重新启动 IDE enter image description here

,

ERC20 文件需要其他文件

export function getRotatedEllipseBounds(
  x: number,y: number,rx: number,ry: number,rotation: number
) {
  const c = Math.cos(rotation)
  const s = Math.sin(rotation)
  const w = Math.hypot(rx * c,ry * s)
  const h = Math.hypot(rx * s,ry * c)

  return {
    minX: x + rx - w,minY: y + ry - h,maxX: x + rx + w,maxY: y + ry + h,width: w * 2,height: h * 2,}
}

不清楚您是否正确安装了 OpenZeppelin。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...