How to update multiple instances of the same contract?


I’ve been playing around with ZeppelinOS and love it!

One thing I’m trying to do is have a factory contract that deploys new instances of a contract, I’m currently doing it using App.sol:

address instance = app.create("myProject", "Instance", app.owner(), data);

However, it seems that each instance stores it’s own address to the contract code. Therefore each contract would need to be updated individually with a new version of the contract.

Is there any way to easily update multiple instances of the same contract?


Hello @dmihal! Good question! I’m not sure, maybe @jcarpanelli would know?


Hello @dmihal! If you are using the command-line interface and you want to upgrade a group of instances that point to the same implementation, just running zos update InstanceName -n some_network (after running a zos push -n some_network to redeploy the implementation) should do the trick, as zos will look for all the instances that match the provided name.

If you are using the programmatic API (i.e., zos-lib), you won’t be able to upgrade them all in one method call, but you can iterate through the list of instances and upgrade one at a time. If you want to access rapidly to a list of instances, I suggest you to take a look at this.

Finally, the same goes when trying to update your instances through solidity; you will have to iterate through them and call your custom function (whether using zos-lib to wrap your contract or truffle/web3) that is in charge of upgrading them.


Thanks @jcarpanelli! Using the CLI is fine, I’ll try that out!