在 remix.ethereum.org 上编译 bep-20.sol 问题

时间:2021-05-30 20:10:55

标签: javascript html compilation token ethereum

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 { |
|  ^^^^^^^^^^^

有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

您的代码有语法错误。您需要以分号结束 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") {