Upgrading from older version of OpenZeppelin Contracts and OpenZeppelin CLI?

PREFACE: Hello to Damien and the OpenZeppelin team. I haven’t seen you since we met at the Smackathon contest in Miami back in 2019. I hope you are doing well!

I’ve been away from Eth coding for a while. I’m starting up again. My old environment consisted of using Truffle for development along with the zos-cli environment and Basil. I see know that OpenZeppelin is at version 3.4.0. I did a fresh npm install of the OpenZeppelin library on my Ubntu 14.04 box using the command shown in the current docs:

npm install --global @openzeppelin/cli

But when I type *openzeppelin --version" at the command line I still see version 2.8.2:

$ openzeppelin --version
2.8.2

Is this a repository issue or npm issue? How do I get the latest 3.4.0 version of OpenZeppelin running on my PC?

Also, I see that the new vehicle for using OpenZeppelin is Truffle plugins. Can anyone tell me the quick-start steps to migrate from the old way of using OpenZeppelin (zos-cli) to the new method of using plugins? Are there any clean-up or uninstall operations I should do first to avoid conflicts? I am worried that I will end up using the old ZOS contract library by accident, and I see that there have been several important fixes, including the now fixed problem of ZOS returning a zero address when an error occurred:

My main question is what doc should I now follow to use the new toolkit to compile and deploy Solidity contracts using Truffle with the new ZOS plugins?

1 Like

Hi @robert.oschler,

Welcome :wave:

The most popular development tools are Truffle and Hardhat (formerly Buidler). (see: https://docs.openzeppelin.com/learn/developing-smart-contracts#setting-up-a-solidity-project)

Assuming you are already familiar with Truffle you could stick with that.

For creating upgradeable contracts we use Upgrades Plugins (rather than OpenZeppelin CLI as we halted development, see: Building for interoperability: why we’re focusing on Upgrades Plugins)

You may want to uninstall the global version of OpenZeppelin CLI. When you are doing openzeppelin --version you are getting the version of the OpenZeppelin CLI and not the version of OpenZeppelin Contracts that you have installed.

For an overview of writing upgradeable contracts with the plugins see: https://docs.openzeppelin.com/learn/upgrading-smart-contracts

There is also an OpenZeppelin Upgrades: Step by Step Tutorial for Truffle and OpenZeppelin Upgrades: Step by Step Tutorial for Hardhat.

When installing OpenZeppelin Contracts (the latest version is 3.4, see: https://blog.openzeppelin.com/openzeppelin-contracts-3-4/) there is a Solidity 0.6 and a Solidity 0.7 version, as well as upgradeable versions of both. When writing upgradeable contracts we need to use the Upgradeable version of OpenZeppelin Contracts, see: https://docs.openzeppelin.com/contracts/3.x/upgradeable


If you have an existing upgradeable project, then you can migrate from OpenZeppelin CLI to Upgrades Plugins using the following guide: https://docs.openzeppelin.com/upgrades-plugins/1.x/migrate-from-cli

Though depending on what version of OpenZeppelin Contracts you had previously used, you may not be able to upgrade versions due to changes with state variables.

If you are starting from scratch, then you can choose to use either Truffle or Hardhat and create a new project.

Feel free to ask any questions you need.

Thanks abcoathup. What document will help me best determine if my contracts are using state variables in a way that is incompatible with the newest versions? Are the compatibility issues related to changes in the way delegateCall is utilizing the smart contract memory locations when passing the state variables from the proxy to the proxied target?

1 Like

Hi @robert.oschler,

You can migrate to OpenZeppelin Upgrades Plugins to deploy and upgrade your upgradeable contracts.

For the avoidance of doubt, this is separate from the version of OpenZeppelin Contracts that you use in your implementation contract.

What version of OpenZeppelin Contracts (upgradeable) were you using previously?
If it was OpenZeppelin Contracts Ethereum Package 2.x then you won’t be able to upgrade your contract to use OpenZeppelin Contracts Upgradeable 3.x due to state layout changes.

1 Like