How to upgrade contracts that was created via a factory contract without any CLI?

Lets say we create contract instances only on-chain via Factory method like it was described in this example and this question, is there any way to use the upgradability of contracts also on those that was created this way programmatically?

openzeppelin cli tool doesn’t recognize any change on contracts that were never build via openzeppelin cli, nor can it handle upgrades on these.

Any changes to just upgrade such contracts without loosing the proxies to them?

1 Like

Hi @itinance,

There is an open issue to support interacting with a contract at a specific address which would allow this sort of functionality: (I see you have already commented on this Issue).

Hi @abcoathup, beside the CLI I was looking for any approach to upgrade those contracts within contracts like the creation via factory method, but couldn’t find any proper code for it.
What do you think? Is it worth it to file a feature request or has somebody already manage it to work without my knowledge? :slight_smile:

1 Like

Hi @itinance,

I am not sure of the best way to do this.

One approach could be to deploy the new logic contract and then call either upgradeTo or upgradeToAndCall of AdminUpgradeabilityProxy with the address of the new logic contract.

I assume there is also a way via App.sol.

I will see what I can find out.

1 Like

So if you are following those examples and using the OpenZeppelin SDK on-chain, yes those contracts created by the factory are upgradable. However, they are currently not (easily) upgradable via the CLI, because, as you correctly identified, the CLI does not have any way of knowing about them.

Unfortunately we don’t currently have an easy way to take care of this, but what you would need to do is keep track of the contracts created by your factory (either with another contract, or emit events when your contracts have been created which are caught by an off chain service) and then those contracts you can upgrade manually via solidity code.

If you wanted to make your life easier and didn’t mind first making it harder :blush:, THEN easier, you can poke around the dev-<<some number here>>.json file which is created to track your project on the network, and you can add the information related to the new upgradable files created by the factory so that you can manage it via the CLI.

Otherwise, though, this sounds like a really interesting feature, but it doesn’t really scale I think for using in the CLI. If users created thousands of contracts with the CLI, it would be very, very difficult to to manage to upgrade them individually via the CLI.


Hi @itinance,

You could deploy the new logic contract using oz push and then call either upgradeTo or upgradeToAndCall of AdminUpgradeabilityProxy with the address of the new logic contract.

You could get the new logic address from App via getImplementation (

As @Dennison suggested, another option is to manually modify network.json though it isn’t terribly scaleable.

You may want to add a feature request in the GitHub repository:


Can you elaborate on how we can do that?,interaction%2C%20and%20source%20code%20verification.
This is done via ProxyAdminProject… If I created a Product contract using App.sol, will I have to use AppProject or what?
Can I get an example ?

1 Like

Hi @asmeedhungana,

I suggest looking at ProxyFactory.

We can continue the discussion in your recent post: How to upgrade a contract deployed from a factory contract?

1 Like

Okay… please do reply in there as soon as you can! :smiley: I have to present something on it today!

1 Like