I am using solidity version "pragma solidity ^0.4.20;". When I checked JSON files of contract, compiler version shows :
"compiler": {
"name": "solc",
"version": "0.4.21+commit.dfe3193c.Emscripten.clang"
}
Still I am getting error :
Source file requires different compiler version (current compiler is
0.5.0+commit.1d4f565a.Emscripten.clang – note that nightly builds are considered to be strictly less than the released version
Command 'truffle version' gives :
Truffle v4.1.5 (core: 4.1.5)
Solidity v0.4.21 (solc-js)
Best Answer
During solidity (solc) 0.5 releases the different frameworks like solc, truffle, web3, openzeppelin had a timeframe where some had a 0.5 compatible version released and some didn't. I think you could have changed specified the solc version like here (didn't try that) but meanwhile all of the mentioned fully support 0.5 (openzeppelin since 2 days ago at time of writing).
Consider doing the following
Check with
truffle version
in a terminal window at some other place (not project dir) if it matches the current release here otherwise do this:Usually you should avoid installing global packages but e.g. BlockCatIO/solidity-flattener requires that solc is installed globally because of certain features (installation described here). Remember to upgrade that one too.
When you then run truffle-compile you should still see errors because they changed the syntax of pragma (found that here).
So change:
I also recommend upgrading ganache-cli (I had problems running the tests with old version):
You might then still see compile errors but that's what makes v0.5 great because they made some improvements you should troubleshoot one-by-one
Here the Breaking Changes in Solidity 0.5.0
Doing this I got it compiling again :)