Solidity Source Files Requires different compiler version

好久不见. 提交于 2019-12-20 04:15:40

问题


pragma solidity ^0.5.3;

contract Inbox {

    string public message;

    function Inbox(string initialMessage) public {
         message = initialMessage;
    }

    function setMessage(string newMessage) public {
         message = newMessage;
    }

    function getMessage() public view returns (string) {
         return getMessage;
    }

}

Error : browser/Untitled.sol:3:1: ParserError: Source file requires different compiler version (current compiler is 0.5.3-nightly.2019.1.15+commit.6146c59a.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version contract Inbox {

I'm using the correct version. I've tried debugging and look on forums, but I cannot find the right solution. Any other experiencing same problem?


回答1:


The answer is directly in the error message you're receiving:

note that nightly builds are considered to be strictly less than the released version

You are specifying to use version 0.5.3 in your contract which is later than the selected compiler. To get around this, you can either drop down to 0.5.2 or you can change your pragma to

pragma solidity >0.5.2;

For more information, look at this ticket.




回答2:


I would recommend using solc-select (https://github.com/crytic/solc-select), it will allow switching easily between solc versions.



来源:https://stackoverflow.com/questions/54206621/solidity-source-files-requires-different-compiler-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!