I'm trying to compile contract A(located in A.sol) that has a dependency on contract B(located in B.sol) using solc-js, where A has solidity version 0.8.0 and B version 0.7.6. The solcjs version that I'm using is 0.7.6 and so A fails to compile with error:

A.sol:4:1: ParserError: Source file requires different compiler version (current compiler is 0.7.6+commit.7338295f.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version

I'm using the following command to compile contract A:

solcjs --bin ./contracts/A.sol --optimize --optimize-runs 1000

Updating solc-js to version 0.8.0 now results in the same issue but now B fails to compile instead.

The issue appears to be that each file/contract should be compiled with their respective compilers, how can I make solc-js compile with the required versions?

1 Answer 1


in B.sol, just update the solidity version

from 0.7.6 to 0.8.0

  • That's not my question. Doing so will introduce breaking changes to contract B.
    – MShakeG
    Aug 6, 2022 at 10:01
  • Oh, yeah I understood. But at least I dont know any other way. But from 0.7.6 to 0.8.0 , will remove you errors. Aug 6, 2022 at 13:25

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.