Search code examples
javascripthtmlcompilationtokenethereum

Compile bep-20.sol Problem On remix.ethereum.org


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);
    }
}

I tried compiling the code above but it was unsuccessful, the error I receive;

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

Please can someone help me out?


Solution

  • Your code has a syntax error. You need to end the import line with a semicolon.

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

    Another syntax error is in your call of the _mint() function, there's an extra parenthesis.

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

    Also, your code is going to give a warning that the constructor doesn't need to have the public visibility modifier and that it's going to be ignored anyway. You can safely remove the visibility modifier from the constructor.

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