- Yair Mark
If you try to use a newer version of solidity than the solc version you have you will get the following error:
SyntaxError: Source file requires different compiler version (current compiler is 0.4.25+commit.59dbf8f1.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version pragma solidity ^0.5.2;
You can upgrade solc and truffle if you want but a quicker fix is to change the pragma as below:
pragma solidity ^0.4.25;
The most important parts to understand about the above are:
- The Solidity version used matches the
compiler isversion in the error message.
- Make sure you precede the version with
^. This tells the solidity compiler that the code is at least that version or higher. This allows you to use version 0.5.0 features yet still use an older solc compiler.