2

A new version of Solidity was added fairly recently, and one of the feature it adds is messages on require.

I would like to use them but I'm not sure how I can do that. I'm using Ganache and truffle, and I test my contracts with Remix.

Am I right to assume that Ganache does the compilation and execution of the code, and thus works with a specific version of Solidity? Or does it work with any version? If so, where does the new code come from? (It does everything locally)

Would it work with just changing the pragma or do I need to wait for a release of Ganache that supports the new version?

  • 1
    ganache doesn't do any compilation, you can check compile version truffle version then you can check compiler version as Solidity v0.4.21 (solc-js). – Kronos May 15 '18 at 8:34
  • @Kronos Thanks that's all I needed, you can write that as an answer and I'll accept it :) – Teleporting Goat May 15 '18 at 8:47
3

Ganache (testrpc) generates a block for each transaction. So every time, you send transactions, it generates new blocks. (But the ethereum mainnet generates new blocks every 15 secs, so you have to wait...) You can check the generated block number.

truffle(development)> web3.eth.blockNumber
web3.eth.blockNumber

truffle(development)> web3.eth.blockNumber
0
truffle(development)> web3.personal.unlockAccount("0x41401ae014f926be3d8583723144dc7138a6fb24")
true
truffle(development)> web3.eth.blockNumber
0
truffle(development)> 
truffle(development)> web3.eth.sendTransaction({from:"0x41401ae014f926be3d8583723144dc7138a6fb24",to:"0xfad23e5147ea907b6045efa97c5b208e1e510381",value: web3.toWei(0.1,"ether")})
truffle(development)> web3.eth.blockNumber
1
truffle(development)>

You can see the blockNumber hass increased. To get the compiler version, use truffle version then you see:

Truffle v4.1.7 (core: 4.1.7)
Solidity v0.4.23 (solc-js)

When truffle does not provide to change compiler version as Remix. You have to uninstall truffle and re-install different version to try in different compiler version. here you can download different version of truffle with solidity compiler.

  • 1
    I didn't have to uninstall and reinstall Truffle. I used npm install -g truffle and it updated both truffle and solc. – Teleporting Goat May 15 '18 at 9:06
  • I don't understand some of your sentences though, like the first one and "When truffle does not provide to change compiler version as Remix". – Teleporting Goat May 15 '18 at 9:08
  • sorry for misunderstanding. in Remix you can easily change compiler version using drop down UI, but truffle does not provide to do that. But as you said, updating truffle version works fine for normal use. – Kronos May 15 '18 at 9:10

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.