What are the consequences of changing compiler versions in dependency contracts to the same version as the main contract?
I have one main contract that inherits some other contracts to interact with their methods and their attributes. So I do:
pragma solidity 0.8.7;
import "../dependencies/C1.sol"; // uses pragma solidity 0.6.12;
import "../dependencies/C2.sol"; // uses pragma solidity ^0.8.0;
contract MainC is C1, C2 {}
Dependency contracts are starting from pragma solidity 0.6.12;
and finishing with pragma solidity ^0.8.0;
. In order to solve ParserError
during the compile time I decided to assign to all dependency contracts the same solidity version pragma solidity 0.8.7;
.
Does it have effect on the functionality of the dependency contracts and is there a chance to receive an error in the future due the different solidity version than specified by the author?
I know that Chainlink contracts give the opportunity to use their smart-contracts with different versions of solidity. But some other projects (e.g. AAVE) don't.
I've visited How to handle multiple solidity versions and also How to import and compile contracts of different versions solidity, where it is said to use pragma solidity ^0.6.12;
in this case. But in the solidity docs for the version pragma it is mentioned:
A source file with the line above does not compile with a compiler earlier than version 0.5.2, and it also does not work on a compiler starting from version 0.6.0 (this second condition is added by using ^).
Whereas I need the version 0.8.7
and above due the Safe Math and native ability to perform explicit conversion from string
to bytes32
by using bytes32(<string>)
instead of writing own function.