狼愛上貍

          我胡漢三又回來了

          truffle里的solc版本與實際solc版本沖突的問題

          1.因為solc@0.5.1出現調用簡單運算合約出現返回0的問題,所以把solc降到了0.4.22。
          2.安裝truffle后,npm install -g truffle,版本有所不同:
          PS C:\> truffle version
          Truffle v5.0.24 (core: 5.0.24)
          Solidity v0.5.0 (solc-js)
          Node v10.16.0
          Web3.js v1.0.0-beta.37
          3.建立簡單合約Greeter.sol后,利用truffle compile后,出現:
          Error: CompileError: ParsedContract.sol:1:1: ParserError: Source file requires different compiler version (current compiler is 0.5.8+commit.23d335f2.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
          pragma solidity ^0.4.24;
          ^----------------------^

          Compilation failed. See above.
          4.修改truffle-config.js文件:
          module.exports = {
          // Uncommenting the defaults below
          // provides for an easier quick-start with Ganache.
          // You can also follow this format for other networks;
          // see <http://truffleframework.com/docs/advanced/configuration>
          // for more details on how to specify configuration options!
          /*
          networks: {
          development: {
          host: "127.0.0.1",
          port: 7545,
          network_id: "*"
          },
          test: {
          host: "127.0.0.1",
          port: 7545,
          network_id: "*"
          }
          }
          */
          compilers: {
          solc: {
          version: "0.4.24"
          }
          }
          };
          5.再次編譯,出現
          /C/users/administrator/webstormprojects/testtruffle/contracts/Migrations.sol:1:1: SyntaxError: Source file requires different compiler version (current compiler is 0.4.24+commit.e67f0147.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
          pragma solidity >=0.4.25 <0.6.0;
          ^------------------------------^
          6.打開Migrations.sol文件,
          把pragma solidity >=0.4.25 <0.6.0;
          修改為:pragma solidity >=0.4.24 <0.6.0;
          編譯通過。

          posted on 2019-06-25 09:05 狼愛上貍 閱讀(2101) 評論(0)  編輯  收藏 所屬分類: Blockchain

          主站蜘蛛池模板: 凌云县| 普定县| 工布江达县| 湘潭市| 儋州市| 翼城县| 旬阳县| 平江县| 晋江市| 鸡泽县| 新田县| 衡阳县| 文安县| 大新县| 桂平市| 安宁市| 南部县| 平武县| 高州市| 徐闻县| 阜新市| 辛集市| 南郑县| 托克逊县| 奇台县| 麻阳| 祁连县| 江永县| 河北省| 海口市| 高碑店市| 台北县| 枣庄市| 满城县| 铁力市| 重庆市| 柞水县| 徐水县| 逊克县| 金湖县| 光泽县|