Why does brownie attempt to compile with the latest locally available version of solc even if I set a specific older version in the config file?


bernat:uniswap-v3-playground bernat$ brownie compile
Brownie v1.14.5 - Python development framework for Ethereum

Compiling contracts...
  Solc version: 0.7.5
  Optimizer: Enabled  Runs: 200
  EVM Version: Istanbul
Generating build data...
[... removed for conciseness ...]

Generating interface ABIs...
CompilerError: solc returned the following errors:

ParserError: Source file requires different compiler version (current compiler is 0.8.1+commit.df193b15.Darwin.appleclang) - note that nightly builds are considered to be strictly less than the released version
 --> /Users/bernat/.brownie/packages/OpenZeppelin/[email protected]/contracts/token/ERC721/IERC721Enumerable.sol:3:1:
3 | pragma solidity ^0.7.0;
  | ^^^^^^^^^^^^^^^^^^^^^^^

In this example it looks like it's trying to use 0.8.1 although at the start it acknowledges the version 0.7.5, which left me pretty confused. The only workaround I've been able to find is to delete all versions post 0.7.5.

2 Answers 2


In your brownie-config.yaml file, you'll be able to set a specific version of solidity. However, if a contract specifies a different version, you'll run into an error.

It looks like you're using openzeppelin's 3.4.1 version of their contracts. If you look into the package, you'll see they all use version 0.7 of solidity. You'll either have to:

  1. Remove the need for a specific verison of solidity in your brownie config
  2. Update to an openzeppelin package that uses v0.8 of solidity (may I suggest their 4.x version?)


Brownie can handle multiple imports, but solidity can't.

If I have a contract with v0.6 and it imports v0.8 - solidity will freak out

If I have a contract with v0.6 and a different contract with v0.8, solidity doesn't care since they are different, and brownie is smart enough to compile them both with their own compilers.


Finally found the root causes of this issue which, if I understood correctly, relates to the generation of interface ABIs at the end of the compile process.

Issue #1: No check for a set solc version https://github.com/eth-brownie/brownie/blob/master/brownie/project/compiler/solidity.py#L108 in the get_abi function, which gets called by when we compile the interfaces in _compile_interfaces https://github.com/eth-brownie/brownie/blob/master/brownie/project/main.py#L304

This means brownie will try to determine the optimal solidity version to use based on each interface's pragma config, no matter what's on your brownie-config.yml.

Issue #2: No check for commented out pragma lines, so if you have more than one pragma definition in the contract and the first one is commented out, Brownie will use that one. See https://github.com/eth-brownie/brownie/blob/master/brownie/project/sources.py#L214

So if you have an interface like:

// pragma solidity >=0.7.5;
pragma solidity ^0.6.11;

Brownie will compile the interface with solc 0.7.5 or greater, and fail with a message like:

interfaces/uniswap-v3/INonfungiblePositionManager.sol:6:1: ParserError: Source file requires different compiler version (current compiler is 0.7.6+commit.7338295f.Darwin.appleclang) - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.6.11;

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.