3

I am currently using the 'Hardhat documentation' to use a correct solidity compiler version, but while precisely compiling my file.sol with pragma solidity ^0.6.0, I am still getting an error:

module.exports = {
  solidity: {
    version: "0.6.5",
    settings: {
      optimizer: {
        enabled: true,
        runs: 1000,
      },
    },
  },
};

Error message

"Source file requires different compiler version (current compiler is 0.8.17+commit.8df45f5f.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version"

It seems that HardHat can't download the compiler, can you help me plz?

1
  • 1
    Can you mark as answered if it was helpful ;) @Dingo Nov 20, 2022 at 20:39

2 Answers 2

3

Sometimes you may want to use a different compiler than the one provided. You can find all the different versions in the solc-bin repository https://binaries.soliditylang.org/

Currently, there are four ways supported to use a different version of the solidity compiler. Remote, Local, NodeModule and Embedded

You can change the compiler in your vscode settings or workspace settings you use.

enter image description here

Then select an specific version to use:

enter image description here

NOTE: May need install one of these extensions for Visual Studio Code:

Ethereum Solidity Language or Solidity and Hardhat support by the Hardhat team

0

It's recommended that Solidity version be locked and specified without the ^(carat) sign, as pragma solidity 0.6.5. This ensures that the specific compiler will always be used, using which code is tested most. It also prevents the code from exhibiting any unintended or unexpected behaviors.

1
  • Yes, that's right, as is well, thanks for the support and reinforcement. @Yongjian Nov 4, 2022 at 17:36

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.