问题描述
尝试运行:
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
第 1 步:
第 2 步:
第 3 步:
选择localNodeModule
可能需要重新启动 IDE
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。