17

I'm using truffle development environment for prototype contract development and I need to change compiler setting (e.g. turn optimization on and off).

The documentation for the development environment does not say how to control the compiler settings. How do I do so?

2 Answers 2

21

The configurations for the compiler settings can be found in the advanced section of the documentation:

You will need to update your truffle.js configuration file to include the following:


module.exports = {
...
    solc: {
      settings: {
        optimizer: {
          enabled: true,
          runs: 1500
        }
      }
    }
}
4
  • weird, keyword search missed this a week ago. thanks! I tested the settings and gasUsed changed, so looks correct.
    – Paul S
    Commented Sep 7, 2017 at 17:21
  • 2
    ROFL didn't find it a week ago because you just added it. Thanks! github.com/trufflesuite/trufflesuite.github.io/commit/…
    – Paul S
    Commented Sep 7, 2017 at 17:27
  • Is there a way to compile only current directory?
    – sensei
    Commented May 22, 2018 at 9:55
  • @JohnMathilda ask that as a standalone question please.
    – Paul S
    Commented May 31, 2018 at 15:29
2

Documentation link in the chosen answer is no longer valid. Relevant section of the documentation can now be found here.

P.S. I can not comment. Had to leave this as an answer.

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.