【问题标题】:pragma solidity - compilation error in jpmorganchase cakeshoppragma solidity - jpmorganchase cakeshop 中的编译错误
【发布时间】:2018-12-19 21:02:15
【问题描述】:

我正在运行来自 SimpleStorage 示例的简单代码,并在其上添加了几行用于其他合同的代码。合同从松露编译得很好。但是在 Cakeshop Integrated IDE 上却显示编译错误。

pragma solidity ^0.4.24;
pragma experimental ABIEncoderV2;
contract SimpleStorage {

    uint public storedData; 

    event Change(string message, uint newVal);

    function SimpleStorage(uint initVal) {
        Change("initialized", initVal);
        storedData = initVal;
    }

    function set(uint x) {
        Change("set", x);
        storedData = x;
    }

    function get() constant returns (uint retVal) {
        return storedData;
    }

}

它应该在 cakeshop Web UI 上编译,因为它在本地机器上编译

【问题讨论】:

    标签: sdk ethereum solidity truffle quorum


    【解决方案1】:

    使用 Remix,您的合同可能存在以下问题:

    1. 您正在使用构造函数的合同名称。您应该改用constructor 关键字。
    2. 您的所有函数都缺少可见性修饰符。考虑将public 修饰符添加到每个函数,包括构造函数。
    3. 应使用emit 关键字调用事件。示例:emit Change("set", x);

    【讨论】:

      猜你喜欢
      • 2021-08-02
      • 2021-09-16
      • 2022-11-12
      • 2022-01-15
      • 1970-01-01
      • 2022-12-02
      • 1970-01-01
      • 2019-05-05
      • 1970-01-01
      相关资源
      最近更新 更多