Coming from here: How do I specify a different Solidity version in a Truffle contract? I still have the same issue, except that even after trying all of the suggested solutions, and even having the truffle-config.js working before by specifying the right version there, my new project doesn't seem to take the version entered in consideration. I'm working with:

Truffle v5.1.15 (core: 5.1.15)
Solidity - 0.6.4 (solc-js)
Node v12.16.1
Web3.js v1.2.1

And this is my compiler code:

compilers: {
    solc: {
        version: "0.6.4"

Whenever I start a new .sol file with pragma solidity ^0.6.4, pragma is highlighted with the following error:

SyntaxError: Source file requires different compiler version (current compiler is 0.4.17+commit.bdeb9e52.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.6.4;

So my IDE still believes my compiler is going to be 0.4.17... If I keep writing, I keep getting errors due to deprecated error highlighting (constructor and emit events not working, now is okay...).

Does anyone know what I might have missed?

  • Your IDE is wrong. Are you using atom? Which extension/plugin are you using? Sometimes reinstalling the extension will fix that message. – Ismael Mar 18 '20 at 17:42
  • Any chance you have Truffle 4.x globally-installed on your machine (i.e., via npm install -g truffle)? – goodvibration Mar 18 '20 at 17:46
  • I'm using VSCode, I've already tried npm uninstall -g truffle followed by npm install -g truffle, I've already tried disabling and reenabling the solidity extension by Juan Blanco, but everything is still the same... So I think I have all the latest versions of everything :/ – Thanh-Quy Nguyen Mar 18 '20 at 17:47
  • 1
    @Thanh-QuyNguyen It seems the extension uses the version of solc installed in your project. If you run npm install solc@0.6.4 in your project it will use that version. – Ismael Mar 18 '20 at 18:28
  • 1
    @Ismael That solved it! Thanks! – Thanh-Quy Nguyen Mar 18 '20 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.