So I am using some uniswapv3 contracts (which are pragma 0.7+) within another contract (which is pragma 0.5.0) and when compiling I have this error : ```These files import other files that use a different and incompatible version of Solidity:

  • contracts/Flashloan.sol (^0.5.0) imports contracts/ISwapRouter.sol (>=0.7.5) and contracts/IQuoter.sol (>=0.7.5)```

so I tried to change the pragma statement from uniswapV3 interfaces I am importing from 0.7.6 to 0.5.0 and I faced this error : contracts/ISwapRouter.sol:11:26: TypeError: Interfaces cannot inherit..

The main question is : How do you handle compiling a contract using solidity v0.5.0 while you use contract that are declared as 0.7+ ?

1 Answer 1


I wondered how could Uniswap compile its contract if Interfaces can't inherit from other Interfaces ? And I concluded that interfaces imports were added in later solidity versions.

The way I solved this problem was by changing interfaces pragma statement to match the main contract and instead of importing the interfaces and inheriting from it, I directly added them into the code.

This might not be the best way to fix this, but it worked. I am putting it out there as I didn't find an answer to this problem and had to figure it out myself.

If you have a better way to compile contracts which inherit/use contracts with other solidity versions than their own, please feel free to share, I would love to learn.

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.