Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solidity Source Files Requires different compiler version

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?

like image 630
Ayaan Abbasi Avatar asked Jan 26 '23 21:01

Ayaan Abbasi


2 Answers

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.

like image 199
Adam Kipnis Avatar answered Feb 13 '23 07:02

Adam Kipnis


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

like image 34
0x3bfc Avatar answered Feb 13 '23 08:02

0x3bfc