Solc Compiler Versions – Resolving Source File Compiler Version Issues in Solc

compilerimportsolcversion-pragma

in my brownie project i have imported LinkTokenReceiver.sol contract which its pragma solidity is pragma solidity ^0.7.0;, which means that it requires compiler version equal or greater than 0.7.0, and when i compile with compiler version 0.8.7 (which is greater than 0.7.0) it throws this error

Source file requires different compiler version (current compiler is 0.8.7+commit.e28d00a7.Windows.msvc) – note that nightly builds are considered to be strictly less than the released version
–> C:/Users/Dell/.brownie/packages/smartcontractkit/[email protected]/contracts/src/v0.7/LinkTokenReceiver.sol:2:1:

2 | pragma solidity ^0.7.0;

can someone explain why and how to fix this ?

Best Answer

There are two ways

  • Update the source file to be compatible with a newer solidity versions, this is a manual process of updating the program, reading through the source code and understanding that nothing breaks when you bump up the compiler version
  • Use an older version compiler for your project as a general
Related Topic