狼愛(ài)上貍

          我胡漢三又回來(lái)了

          truffle里的solc版本與實(shí)際solc版本沖突的問(wèn)題

          1.因?yàn)閟olc@0.5.1出現(xiàn)調(diào)用簡(jiǎn)單運(yùn)算合約出現(xiàn)返回0的問(wèn)題,所以把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.建立簡(jiǎn)單合約Greeter.sol后,利用truffle compile后,出現(xiàn):
          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.再次編譯,出現(xiàn)
          /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.打開(kāi)Migrations.sol文件,
          把pragma solidity >=0.4.25 <0.6.0;
          修改為:pragma solidity >=0.4.24 <0.6.0;
          編譯通過(guò)。

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

          主站蜘蛛池模板: 武隆县| 峨眉山市| 伊宁县| 昆明市| 八宿县| 化州市| 金坛市| 韶山市| 大埔区| 鹤庆县| 乌兰浩特市| 阿克陶县| 苏尼特左旗| 工布江达县| 闸北区| 云梦县| 旌德县| 苏州市| 霞浦县| 沈阳市| 涟水县| 马鞍山市| 西乌珠穆沁旗| 凤城市| 宽城| 沾益县| 睢宁县| 皮山县| 隆昌县| 连云港市| 白朗县| 新绛县| 吉首市| 武川县| 淮阳县| 区。| 康平县| 赣州市| 晋州市| 峨山| 仙居县|