I'm using hardhat to compile my contracts. I am aware that hardhat is good at compiling contracts with different pragma versions, however, the contracts can't compile because they're importing contracts with different pragma versions. I was thinking of making an import.sol contract as a central source to import other contracts. What do you think?

2 Answers 2


I don't think that is possible, I didn't use hardHat before, but compiling contracts with different versions of solidity introduces compatibility issues between each contract code. an example of such issues is the abstract keyword that didn't exist in version 0.4 but does in other versions after that and its usage is mandatory on classes with virtual methods.

Your best choice is to modify the contracts to use the latest version of the compiler or a fixed version of your choice.


According to the documentation of Hardhat, you can use different solc versions. You just need to specify for each contract, or use override in the hardhat.config.js file.

About the compatibility issues, Solidity Compiler comes with a tool to "upgrade" your contract. I never used it before, but I think and I hope it helps. Link to doc.

Happy coding! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.