Ethereum Asked on January 3, 2022
The OpenZeppelin version I’m using is Solidity 0.5.0 but I’m using 0.5.15 in my core contracts. Everything is compiling but I’m having some issues verifying the contract on Etherscan and submitting transactions. Is it kosher to inherit from a different Solidity version like this?
It is acceptable.
Some things to understand and clarify.
There is only one compiler version and it will apply to the top-level contract and all inherited contracts. A style I have found useful is
pragma
of the top-level contract to disambiguate the version and reduce confusion during review, test and verification (e.g. etherscan). It is useful to know, from the code, what version of the compiler must have been used to compile it.pragma
in the inherited contracts, because you will know the precise version will be determined at compile-time and it must be the version specified in the main contract.Ambiguous (convenient - unmodified openzeppelin contracts):
pragma solidity ^0.6.0;
contract Component {}
Unambiguous Top-level contract:
pragma solidity 0.6.6;
contract Main is Component {}
There is no doubt that Main
must be compiled with 0.6.6 and, by extension, so is Component
because inheritance is a source code roll-up and because it is part of Main.
The scheme works well for large systems with many contracts and components. As the developer, if you change your mind and want to go with a newer compiled (e.g. 0.6.10
) you will only change a few top-level contracts and run your tests.
Hope it helps.
Update
Some code auditors favour explicit pragmas at every level so it might be productive to follow the suggested scheme during development and then make the sub-modules precise, as well when polishing a candidate production release.
Answered by Rob Hitchens on January 3, 2022
If the contracts compile they should work without problems.
Usually both Solidity and OpenZeppelin try to maintain compatibility between minor version of the same release.
Answered by Ismael on January 3, 2022
1 Asked on February 13, 2021 by luca590
0 Asked on February 12, 2021 by user65561
1 Asked on February 12, 2021 by exaltedoil
1 Asked on February 6, 2021 by iameli
1 Asked on February 3, 2021 by krritik
0 Asked on February 1, 2021 by koukotsu
6 Asked on January 31, 2021 by user3280964
0 Asked on January 31, 2021 by angel-guastaferro
contract deployment contract design contract development solidity wallets
0 Asked on January 29, 2021 by itzi
1 Asked on January 29, 2021 by bob5421
2 Asked on January 28, 2021 by hillfias
arrays bytes32 contract debugging contract development web3js
1 Asked on January 24, 2021 by user938363
0 Asked on January 22, 2021 by deci
1 Asked on January 22, 2021
Get help from others!
Recent Answers
Recent Questions
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP