1

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?

Thanh-Quy Nguyen
  • 326
  • 1
  • 2
  • 11
  • 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
  • Type npm ls truffle from some path outside of your project folder. – goodvibration Mar 18 '20 at 17:50
  • I just uninstalled it, so I get empty right now... And even that didn't fix it and I'm still stuck with 0.4.17... Something more weird is I have another project from 5 months ago which used to working fine, then had the same problem about a month ago, and then got it back to be working again. All I did was uninstalling npm and installing nvm before instead. But the point is the older project is working, so I believe this to be a local problem... – Thanh-Quy Nguyen Mar 18 '20 at 17:52
  • @Thanh-QuyNguyen I use VS Code with Juan extension and I've no issues. Check if there's an old version of solc installed globally npm ls -g --depth=0, uninstall it if that's the case. Also look at the extension settings it allows to override the version you want. – Ismael Mar 18 '20 at 18:12
  • @Ismael I have nothing, but just in case I uninstalled solc and reinstalled it, and it still doesn't work :/ – Thanh-Quy Nguyen Mar 18 '20 at 18:15
  • 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

0 Answers0