0

I am compiling a contract using the npm package solcjs. The package is at version 0.4.21 (npm view solc). However compilation fails because my pragma is set to ^0.4.21 while solcjs states current compiler is 0.4.19.

Please do you have any idea why solcjs doesn't use the latest version of the compiler? Is solcjs the right tool to compile and deploy manually contracts using web3.js? Thanks!

Contracts are being compiled as follows:

var compiledContract = solc.compile(source,1);
var abi = compiledContract.contracts[':Book'].interface;
var abiArray = JSON.parse(abi);
var bytecode = compiledContract.contracts[':Book'].bytecode;
  • How are you compiling the contracts? If you are using Truffle then the latest version supported is 0.4.19 – Matt Apr 4 '18 at 21:35
  • I compile with npm packages in my js file : var compiledContract = solc.compile(source,1); var abi = compiledContract.contracts[':Book'].interface; var abiArray = JSON.parse(abi); var bytecode = compiledContract.contracts[':Book'].bytecode; – Tholoz Apr 4 '18 at 21:49
  • Personal advice: switch to solc. It runs much faster, and supports a lot more compilation flags (like --optimize and --optimize-runs). – goodvibration Apr 4 '18 at 22:34
  • 1
    Since there have been problems verifying contracts compiled with newer versions of solc (0.4.20+), i strongly recommend to stay in 0.4.19. I also recomed using plain solc as @goodvibration said, as it has more options and runs faster. – Hari GTT Psicolabis Apr 4 '18 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.