4

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
3

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

| improve this answer | |
2

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

| improve this answer | |
1

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.

| improve this answer | |
  • 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
0

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

| improve this answer | |
0

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.
| improve this answer | |

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.