How do upgradeable contracts work?

I am having trouble understanding how OpenZeppelin manages upgrades, how is data from a previous contract version able to exist with an updated version? Is there any specific in-depth guide or visualization for this?

I have been trying to understand it by reading here among other places:


1 Like

Hi @Alex-dev,

The proxy is a simple contract that just delegates all calls to an implementation contract. A delegate call is similar to a regular call, except that all code is executed in the context of the caller, not of the callee.

Any reads or writes to the contract storage will read or write from the proxy’s own storage.

This allows us to decouple a contract’s state and code: the proxy holds the state, while the implementation contract provides the logic. And it also allows us to upgrade the code by just having the proxy delegate to a different implementation contract.

I suggest looking at the following in the documentation for further information:

It took me a little while to understand the concept. Feel free to ask all the questions that you need.

1 Like