I haven't worked with Truffle/Solidity for a while and I am trying to get my environment/toolchain configure correctly. I have some questions regarding the compiler config.
I was originally not setting the compiler config options in truffle-config.js
and recently set it to 5.5 which appears as if it caused Truffle to download a new Docker image, and compilation seems to have slowed down, or at least running the full test suite is quite a bit slower.
I am working on an a project and have been setting the pragma as
pragma solidity ^0.5.5;
My truffle config block:
// Configure your compilers
compilers: {
solc: {
version: "0.5.5", // 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: "petersburg"
}
}
}
}
And my solc output:
solc --version
solc, the solidity compiler commandline interface
Version: 0.5.12+commit.7709ece9.Darwin.appleclang
Does this look correct? Are there any obvious improvements?
Project repo: https://github.com/alanwilhelm/upgradeable_token
Best Answer
Truffle is not using
solc
.You can see what it IS using with
This is a little ambiguous, IMO.
In practice, what I like to do is specify exactly what compiler to use for top-level contracts and
^
for inherited contracts and libraries. That way, the toolchain will emit an error at the first sign of an inconsistency.For example:
and
That leaves no possibility of compiling, testing, deploying with inconsistent compiler versions and it will also save you a little time if you want to bump it up to a newer version at some point.
It will also force you to consistently select the right compiler when using tools like Remix. You'll be reminded - it's gotta be 0.5.5.
As an FYI, my understanding is that Truffle downloads
solcjs
the same way Remix does it, and this is why the installedsolc
compiler (standalone) is irrelevant to Truffle.Hope it helps.