I'm trying to verify a contract I have compiled and deployed onto the network using Etherscan. The contract was compiled using truffle. How do I work out exactly which version of the solidity compiler to select on Etherscan?
I managed to find a hacky way of doing this. Note - I was looking for more than just the version of solc. I was looking for the actual build of the compiler that solc was using (ie the commit used, night build number etc) so that I could could select it on EtherScan.
I have truffle installed globally so I ran
which truffle which allowed me to eventually find (following symlinks) where truffle was stored on my mac:
From here it was easy to locate where the solc installation used by truffle is also stored. Relative to the previous path it would be in
At this point - if you just want the version of the solc package you can look in
If you want to go further and find the specific compiler version (like me) then take a look in
wrapper.js and look for the
var version variable declaration. It turns out this is a function which will return the compiler version name being used. Simply
console.log(version()); on the next line and when you next run
truffle test or
truffle compile the solidity compiler build will be output into your console. For me this looked like:
var version = soljson.cwrap('version', 'string', );
Remember to return the wrapper.js file to its original state after you have got the info you need.
Note: This is a very hacky way of doing it. There's probably a better way but it was the first method I stumbled on. Even then - it didn't even help me get the contract verified on Etherscan, anyway.
If you have npm installed with the -g flag, you can do this (omit the -g if you have it installed locally)
$ npm -g ls | grep solc
└─┬ [email protected]
That should be your version.