Solidity开发bug汇总

2020年9月22日10:59:33BCOS评论537阅读模式

编译器与代码版本不一致问题

(代码版本pragma solidity ^0.4.25),产生如下报错:

{ "component": "general", "formattedMessage": "StringUtil.sol:1:1: SyntaxError: Source file requires different compiler version (current compiler is 0.4.25-develop.2019.12.3+commit.8f645f02.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version\npragma solidity ^0.4.25;\r\n^----------------------^\n", "message": "Source file requires different compiler version (current compiler is 0.4.25-develop.2019.12.3+commit.8f645f02.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version", "severity": "error", "sourceLocation": { "end": 24, "file": "StringUtil.sol", "start": 0 }, "type": "SyntaxError" }

解决:

改为pragma solidity ^0.4.2

^0.4.25表示0.4.25以上,0.5以下的版本,因此与当前编译器版本不兼容,导致错误。

BCOS最后更新:2020-11-6