Where is the storage for an upgradeable contract?

@abcoathup I have a question. Assume the following

(a) Proxy A(this is where all the storage is) —implementation—> Contract A (this is where all the functions are).

So if I am upgrading Contract A {by implementing a Contract Av2} and adding new state memory item over here. Eg, address public funAddress; how does Proxy A refer to this storage variable when delegating function calls to Contract Av2. Just to complete the picture over here, I am adding a function which sets the funAddress, like function setFunAddress(address _funAddress) onlyOwner {} and then calling this function as soon as I deploy the new implementation.

The trick extends when I am doing another upgrade to Contract Av3. And in this round, I do not call any function at all.

What I am struggling with is that when Proxy A now delegates to Contract Av3, how will it know the value of the funAddress {which, I think, is sitting only in v2}.

Thank you.

1 Like

The storage is in the Proxy contract whilst the logic (including functions) is in the logic contract. Upgrading (pointing to a new logic contact) doesn’t change where the storage is.

Have a look at the following guide:

1 Like