【问题标题】:Compile Error in pragma solidity 0.8.0 and otherspragma solidity 0.8.0 和其他版本中的编译错误
【发布时间】:2021-08-02 15:08:57
【问题描述】:

当我尝试编译我的 bep20 智能合约时,它说:

ParserError:无效的令牌。 --> bep-20.sol:6:53: | 6 | 构造函数(uint256 initialSupply)公共ERC20(“银河系”, “牛奶”) { | ^

我使用 pragma solidity ^0.8.0;但最新版本是pragma solidity ^0.8.4;。所有版本都试过了,还是不行。

谁能帮我解决这个问题?

【问题讨论】:

    标签: compilation solidity smartcontracts erc20 bep20


    【解决方案1】:

    您需要使用正则引号" 或撇号' 字符,您的sn-p 使用左引号这可能是由于从将常规引号替换为左引号作为安全措施的网站复制造成的。

    此外,Solidity 0.8 会在构造函数上使用可见性修饰符时发出警告。删除 public 可见性修饰符。

    constructor(uint256 initialSupply) ERC20("MilkyWayGalaxy", "MILKYGAL") {
    

    【讨论】:

    • 非常感谢彼得。现在问题解决了。你是最棒的 :) 谢谢你uuu
    猜你喜欢
    • 1970-01-01
    • 2021-08-15
    • 2022-07-05
    • 2021-09-10
    • 2021-07-11
    • 2021-09-05
    • 1970-01-01
    • 2021-09-16
    • 2022-11-12
    相关资源
    最近更新 更多