Possibilities of upgrading a contract which was not initially designed to be upgradeable

Hello,

If I create a smart contract, V1, and I deploy this not upgradeable contract. Now that I have a V2,

  1. In what ways can I use OZ to upgrade the V1?
  2. Can I use proxy upgradeability method to make this V1 upgrade?

Aside: I will love if this can be figured this out without the data migration concept. The V1 or the V2 are both factoryLogic contracts which can deploy other contracts, so they have a solidity mapping and struct which keeps track of the contracts they deployed.

2 Likes

Hi @Etienereum,

If I understand correctly, you have a factory contract that is deploying V1 contracts. You now want to add functionality in a V2.

You can create a new factory contract that will deploy V2 contracts so all contracts from the factory going forward will be the latest version.

For existing V1 contracts, unless they were designed to be upgraded (which it sounds like they are not), then you would need to migrate from V1 to V2 versions, but this involves deploying a new V2 contract and migrating the state from V1 to V2 and getting your users to use V2.

You may possibly be able to wrap V1 in another contract to provide some functionality of V2 but it depends on the type of contract and your use case.

Are you able to give more detail on what the contracts do?

Proxy upgradeability can only be used if the contract was deployed as a proxy from the beginning.

If you can, please share the source code for your factory contract or at least more details about the mapping. You may be able to deploy a V2 factory contract that knows to consult the V1 contract for any data that it may be missing, and it may even be able to migrate that data on demand.

1 Like