1

I updated to the latest version of Truffle using:

npm uninstall -g truffle

followed by:

npm install -g truffle

I verified this succeeded by doing:

truffle --version

and got this:

enter image description here

You can clearly see that I'm on version 5.0.3

I read that updating Truffle would pretty much also automatically update the Solidity compiler.

but when I do:

solc --version

I get this:

enter image description here

So its still on version 0.4.24

So I did again.
And again.
And its not working.

I've done it globally - and I've done it locally, meaning in my specific project's Directory.

Nothing works.

I tried doing it directly, by uninstalling Solidity - like this:

npm uninstall solc -g

-then reinstalling it using:

npm install solc -g

I've done pretty much everything I can think of, but its still telling me that I'm on version 0.4.24.

What's going on? What am I missing here?

========================================================

UPDATE:

I added the following to my truffle.js file:

compilers: {
    solc: {
        version: "0.5.0"  // ex:  "0.4.20". (Default: Truffle's installed solc)
    }
}

That's obviously supposed to force the use of that particular version of the compiler.

I recompiled and redeployed to ropsten - and that all worked.

So at this point, I'm assuming that the project is being compiled using v 0.5.0 of Solidity - but is it?

Here's my big question right now: how can I tell - like during run time, what compiler version is actually being used on my project at any given time? Cause at this point, I'm still getting errors in my DApp - the HTML & JS files that are querying the contract I deployed - that seem to do with the compiler+solidity versions - which was the reason I updated truffle to version 5 in the first place, to solve these issued. (But that's another matter. One thing at a time.)

===========================================================================

UPDATE#2

This shows everything:

enter image description here

-I'm installing solc v. 0.5.3 directly into my project's folder (I've already done the Global install several times.)

-I get 2 warnings - I don't know what they mean - but it says it installed 14 packages from 5 contributors, which sounds pretty good.

-but then when I do solc version, it tells me I'm on version 0.4.24

I've literally spent all day trying to resolve this.

1

On your project root directory, there's a file named "truffle-config.js"

Inside this file, you can find a solc config, and uncomment version line, and then put your prefer version. (ex: 0.5.7)

compilers: {
    solc: {
       version: "0.5.7",    // Fetch exact version from solc-bin (default: truffle's version)
      // docker: true,        // Use "0.5.1" you've installed locally with docker (default: false)
      // settings: {          // See the solidity docs for advice about optimization and evmVersion
      //  optimizer: {
      //    enabled: false,
      //    runs: 200
      //  },
      //  evmVersion: "byzantium"
      // }
    }
  }

After this, just compile and truffle will download that version of solc automatically.

$ truffle compile 

Boom!

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.