I use Solidity Remix IDE for develop purpose. And when I finish I copy in VisualStudio Code and i attach to my project folder. But visual is telling me that i have a problem with the version. I can compile, migrate and use this contract when I deploy at ganache but the warning still there.

Any idea?

enter image description here enter image description here

  • can you make right click in VSCode on a file and say "Open in Terminal" and write "truffle version" there and check if it's the same result? I'm not sure if that's the same as if you go into truffle console because that could be installed globally. it would help if you share your package.json – CodingYourLife Nov 27 '18 at 1:19

In my Visual Studio Code I use the Juan Blanco extension to help me coding Solidity. The solution is to change in the config json the attributes.

enter image description here enter image description here

Find the version that yo want to compile in.

Here the web: https://github.com/ethereum/solc-bin/tree/gh-pages/bin

enter image description here enter image description here

  • I downloaded a .js file from the link above and put "solidity.compileUsingLocalVersion": "/home/phil/Programs/soljson-v0.6.9+commit.3e3065ac.js" in ~/.config/Code/User/settings.json. Now my juanblanco.solidity extension is compiling against the version I want. – Philip Rego Aug 24 '20 at 3:19
  • If you want to change the version truffle uses see ethereum.stackexchange.com/a/62923/28140 – Philip Rego Aug 24 '20 at 4:40

This is because you are using different version of solidity compiler.So just replace the first line with:

pragma solidity >=0.4.24;

But the problem is with solidity 0.5 onwards,there are major changes.So try to update the contract according to the newer version or you can change the default compiler as mentioned by @Eduardo


TLDR: change pragma solidity ^0.4.24 to pragma solidity ^0.5 to get rid if the warning

It's because you updated truffle and your compiler is a newer version than the one indicated in that line, and that the one you used in remix.

Execute truffle version in a console to see which version you have installed and see which version will be used for compilation.

  • 1
    I have checked truffle version and it's the same as my pragma version in the contract, but am still getting this error. Also tried solidity.compileUsingLocalVersion set to the same version as truffle... still getting the error. – robertdavid Nov 26 '18 at 13:00
  • Same error. Truffle version is same that I specified in the top of the solidity file. – UnexpectedCharacter Nov 26 '18 at 14:54
  • Have you tried pragma solidity ^0.4.24; Without the space or the ""? – Enrique Alcazar Nov 26 '18 at 16:06
  • I try ^0.4.24 and still getting the error. If Ichange the version to 0.5 the error go out. But the idea is to follow the 0.4.24 version. To prevent version problems – UnexpectedCharacter Nov 27 '18 at 7:02

The currently top answer seems to be VisualStudio specific and seems strange to me...

But it helps changing

pragma solidity ^ "0.4.24"

(which would more commonly be written like this)

pragma solidity ^0.4.24

To this - WORKS (VisualStudio Code still shows error but it compiles)

pragma solidity 0.4.24;

Note that by doing this you fix your contract to that version...

The problem must have something to do with truffle 0.5 breaking changes and it makes sense according to the error message. Currently solidity github repo released 0.5 but truffle's according changes are still in beta so this might be a temporary issue where no consistent version exists...

Update: I think now it's safe to say upgrade if possible. Also there is a compiler section in truffle.js that could help to switch between solc versions


This worked for me:

  • In the toolbar, Go to View > Extensions or Press Ctrl + Shift + X.
  • In the Extensions:Marketplace on the left side of the screen and uninstall Solidity Extended.
  • The warning will go away.

If you still have a problem with the version in VS Code, this worked for me:

Install specific solc version locally or globally: npm i -g solc or npm i solc.

Add this setting in local VSCode settings: .vscode/settings.json

    "solidity.compileUsingRemoteVersion": "v0.7.4+commit.3f05b770",
    "solidity.enableLocalNodeCompiler": false

In my case I am using solidity v0.7.4. Note also the other config: "solidity.enableLocalNodeCompiler": false

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.