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?

Paul S
  • 4,271
  • 1
  • 22
  • 48

2 Answers2

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
        }
      }
    }
}
kuzdogan
  • 657
  • 5
  • 15
SteveJaxon
  • 2,528
  • 1
  • 10
  • 21
  • weird, keyword search missed this a week ago. thanks!

    I tested the settings and gasUsed changed, so looks correct.

    – Paul S Sep 07 '17 at 17:21
  • 2
    ROFL didn't find it a week ago because you just added it. Thanks! https://github.com/trufflesuite/trufflesuite.github.io/commit/11e6e6e058b3f73e2e4a9045dd9d359dbae2f13b#diff-c67a290807d69e02561f9334ef81f234 – Paul S Sep 07 '17 at 17:27
  • Is there a way to compile only current directory? – sensei May 22 '18 at 09:55
  • @JohnMathilda ask that as a standalone question please. – Paul S May 31 '18 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.