Does the CLI handle deploying multiple proxies with a shared implementation contract?

Hi,
I would like to deploy multiple proxies that share the same implementation contract (and also same ProxyAdmin) via openzeppelin cli, is it something supported out of the box?

Thanks

2 Likes

Hi @bugduino,

Yes. When deploying via the OpenZeppelin CLI in one project, the implementation contract should be deployed once and the ProxyAdmin should be shared.

You can try it out yourself.

I deployed MyContract twice as upgradeable, the implementation contract was deployed the first time and so was the ProxyAdmin.

$ npx oz deploy
Nothing to compile, all contracts are up to date.
? Choose the kind of deployment upgradeable
? Pick a network development
? Pick a contract to deploy MyContract
✓ Contract MyContract deployed
All implementations have been deployed
? Call a function to initialize the instance after creating it? No
✓ Setting everything up to create contract instances
✓ Instance created at 0xCfEB869F69431e42cdB54A4F4f105C19C080A601
To upgrade this instance run 'oz upgrade'
0xCfEB869F69431e42cdB54A4F4f105C19C080A601
$ npx oz deploy
Nothing to compile, all contracts are up to date.
? Choose the kind of deployment upgradeable
? Pick a network development
? Pick a contract to deploy MyContract
All implementations are up to date
? Call a function to initialize the instance after creating it? No
✓ Instance created at 0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B
To upgrade this instance run 'oz upgrade'
0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B

.openzeppelin/<dev>.json

...

"proxies": {
    "box/MyContract": [
      {
        "address": "0xCfEB869F69431e42cdB54A4F4f105C19C080A601",
        "version": "1.0.0",
        "implementation": "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab",
        "admin": "0x5b1869D9A4C187F2EAa108f3062412ecf0526b24",
        "kind": "Upgradeable"
      },
      {
        "address": "0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B",
        "version": "1.0.0",
        "implementation": "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab",
        "admin": "0x5b1869D9A4C187F2EAa108f3062412ecf0526b24",
        "kind": "Upgradeable"
      }
    ]
  },

...
1 Like

Didn’t know, that’s awesome!
Thanks @abcoathup

1 Like