Cannot change solc compiler version in VSCode

1.6k views Asked by At

I am getting this error in VSCode while trying to compile using brownie. I understand this error is from the pragma solidity version in one of my files being different from my compiler:

PS C:\Users\me\Documents\Code\Blockchain\brownie_fundme> brownie compile
INFO: Could not find files for the given pattern(s).
Brownie v1.18.1 - Python development framework for Ethereum

Compiling contracts...
  Solc version: 0.8.13
  Optimizer: Enabled  Runs: 200
  EVM Version: Istanbul
CompilerError: solc returned the following errors:

ParserError: Source file requires different compiler version (current compiler is 0.8.13+commit.abaa5c0e.Windows.msvc) - note that nightly builds are considered to be strictly less than the released version
 --> C:/Users/me/.brownie/packages/smartcontractkit/[email protected]/contracts/src/v0.6/vendor/SafeMathChainlink.sol:2:1:
  |
2 | pragma solidity ^0.6.0;
  | ^^^^^^^^^^^^^^^^^^^^^^^

I have attempted to change my compiler version using Juan Blanco's 'Solidity' VSCode extension to "Change global/workspace compiler version (Remote)", selecting version 0.6.0. (I confirmed this adds "solidity.compileUsingRemoteVersion": "v0.6.0+commit.6c089d02" to my settings.json).

But when I run brownie compile again I still get the same error:

"...ParserError: Source file requires different compiler version (current compiler is 0.8.13+commit.abaa5c0e.Windows.msvc)...", showing that my compiler version remains unchanged.

(I have the default compiler set to remote, and I also tried restarting any open terminals after making these changes.)

I had installed solcx with pip, and also have a .solcx folder in my "C:/Users/me" directory, which contains a folder "solc-v0.8.13". I tried deleting that folder and compiling again, but brownie automatically downloaded the same v0.8.13.

I'm stumped on how to change the global or workspace compiler version. Could the version of solc be getting overridden from somewhere other than my VSCode settings?

1

There are 1 answers

0
kj-crypto On BEST ANSWER

Add following brownie-config.yaml file to your project:

compiler:
  solc:
    version: 0.6.12

When you compile, brownie will download solc version from config.