In hardhat multiple versions of a dependency can be installed as follows in the package.json(assuming yarn is being used):

"@openzeppelin/contracts": "^4.3.2",
"openzeppelin-contracts-solc-0.7": "yarn:@openzeppelin/[email protected]",

If you want to use v4.3.2 then you can import "@openzeppelin/contracts/..." and similarly if you want to use v3.4.2-solc-0.7 then you can import "openzeppelin-contracts-solc-0.7/..."

How can this be achieved in foundry?

1 Answer 1


If you want to install say the 2 versions of @openzeppelin/contracts stated in the question, they can be installed as follows:

# notice show openzeppelin-contracts-solc-0.7= is prepended to the dependency
# this will name the dependency "openzeppelin-contracts-solc-0.7" instead of the default name "openzeppelin-contracts"
forge install openzeppelin-contracts-solc-0.7=openzeppelin/[email protected]

# now install the latest version of openzeppelin-contracts as follows
forge install openzeppelin/openzeppelin-contracts

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.