【问题标题】:Compile bep-20.sol Problem On remix.ethereum.org在 remix.ethereum.org 上编译 bep-20.sol 问题
【发布时间】:2021-05-30 20:10:55
【问题描述】:

pragma solidity ^0.8.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol"

contract Firmspot is ERC20 {
    constructor(uint256 initialSupply) public ERC20 ("Firmspot", "FSp"){
        _mint(msg.sender),initialSupply);
    }
}

我尝试编译上面的代码但不成功,我收到错误;

ParserError: Expected ';' but got 'contract' --> bep-20.sol:5:1: 
|
5 | contract Firmspot is ERC20 { |
|  ^^^^^^^^^^^

有人可以帮帮我吗?

【问题讨论】:

    标签: javascript html compilation token ethereum


    【解决方案1】:

    您的代码有语法错误。您需要以分号结束import 行。

    import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol";
    

    另一个语法错误是在您调用 _mint() 函数时,有一个额外的括号。

    // removed the extra parenthesis
    _mint(msg.sender, initialSupply);
    

    此外,您的代码将发出警告,即构造函数不需要具有 public 可见性修饰符,并且无论如何都会被忽略。您可以安全地从 constructor 中删除可见性修饰符。

    constructor(uint256 initialSupply) ERC20 ("Firmspot", "FSp") {
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-31
      • 2022-01-15
      • 1970-01-01
      • 2019-12-24
      • 2012-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多