How to use Ownable with upgradeable contract?

Thanks a lot for the Box.sol example above!

this shows what’s required to move to upgradeable contracts with the OpenZeppelin themself:

  1. change imports (point to @openzeppelin/contracts-ethereum-package) for all contract imports
  2. derive Box from both Initializable and ownableUpgradeSafe (in that order) - I guess this is to make both Box and Ownable upgradeable
  3. call base class initialize implementation functions - for which I have to look at the source (implementation) of the respective OpenZeppelin contract inherited (OwnableUpgradeSafe in this case)

FWIW, I spent quite some time with the docs: I could find 1. there, but the infos 2. and 3. I didn’t find (only here in your answer).

With 3.: as a app developer using OZ contracts, am I supposed to read the implementation to figure out the right functions to call in the base class (inside initialize). Eg in my case, with AccessControlUpgradeSafe, I am supposed to call __Context_init_unchained and __AccessControl_init_unchained … I guess)

IOW: please add this information to the docs.

1 Like