I am using truffle, and have a number of x.sol files in the contracts directory, different files require different versions of the compiler - how do i deal with that?

I think i SHOULD be able to do something like:

truffle compile Dai.sol 0.4.13
truffle compile MyContract.sol 0.5.0

Unfortunately it seems to always try to do the lot with whatever version is in the truffle config file. :(

  • You can compile them directly with solc. Feb 15, 2019 at 12:18

1 Answer 1


You can do it in either of the following ways:

  1. If you're writing all smart contracts at the same time, use latest version while writing all contracts.

  2. If you're adding a new smart contract with already available one, then either you rewrite your old smart contract according to the latest version or just set the solidity compiler version to lowest version which you want to support with the following code in the truffle-config.js file.

compilers: {
    solc: {
        version: <version>,  // ex:  "0.4.20". (Default: Truffle's installed solc)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.