Jack Feng
Jack Feng

Reputation: 971

How to use older solc compilers with Truffle

I am trying to reproduce the DAO attack that happened on Ethereum, however, I was not able to compile the DAO code. The current stable version of truffle does not support specifying a solc version. I used the 5.0.0 beta 1 version for truffle, which supports specifying a solc version. When compiling the DAO code, I get this error.

TypeError: Error parsing E:/Desktop/MetaCoin/contracts/DAO.sol: solc.compileStandard is not a function
    at Object.parseImports (C:\Users\Administrator\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-compile\parser.js:49:1)
    at Object.getImports (C:\Users\Administrator\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-compile\profiler.js:332:1)
    at Promise.all.then.results (C:\Users\Administrator\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-compile\profiler.js:305:1)
    at <anonymous>

Any idea guys?

Upvotes: 1

Views: 3819

Answers (1)

Shane Fontaine
Shane Fontaine

Reputation: 2439

As of Truffle 5.0.0 beta -0, you can specify a solcjs version.

I have just tried it in my project and it works. Be sure to make the version number a string and use the following code:

module.exports = {
  networks: {
    ... etc ...
  },
  compilers: {
     solc: {
       version: <string>  // ex:  "0.4.20". (Default: Truffle's installed solc)
     }
  }
};

Upvotes: 3

Related Questions