OZ Upgrades Transfer Proxy Ownership Error with New ProxyAdmin

I'm currently deploying a transparent upgradeable proxy using hardhat deploy and OZ upgrades based on this comment. At the end of the deploy script, I'm transferring ownership of the ProxyAdmin to a guardian address:

  await proxy.connect(deployer).grantRole(DEFAULT_ADMIN_ROLE, guardian.address); //Give admin role to guardian
  await proxy.connect(guardian).revokeRole(DEFAULT_ADMIN_ROLE, deployer.address); //Revoke admin role from deployer
  await upgrades.admin.transferProxyAdminOwnership(guardian.address); //Give Proxy Admin Ownership to guardian

However, when I try to transfer admin ownership again for test purposes:

      await upgrades.admin.transferProxyAdminOwnership(alice.address);

I am getting the following error: 'Ownable: caller is not the owner'. I had a similar error when upgrading contracts with the new ProxyAdmin, but I fixed it using this solution. Unfortunately, I'm not sure how to apply that solution towards updating the ProxyAdmin. Any help is much appreciated!

1 Like

When you call upgrades.admin.transferProxyAdminOwnership(newOwner), that calls ProxyAdmin's transferOwnership(newOwner) to transfer the ownership of the ProxyAdmin contract itself, in your case from the deployer to guardian.address.

So to transfer the ownership a second time, you would need to use the guardian account to invoke the ProxyAdmin's transferOwnership(newOwner)

Gotcha. So in this case, I would have to directly use the instance of ProxyAdmin like:

      const proxyAdminInstance = await upgrades.admin.getInstance();
      await proxyAdminInstance.connect(guardian).transferOwnership(newOwner)

Instead of just calling upgrades.admin.transferProxyAdminOwnership(Alice.address) a second time. Is there not a way to specify a different "from account" (instead of deployer) in the upgrades transferProxyAdminOwnership itself?

Is there not a way to specify a different "from account" (instead of deployer) in the upgrades transferProxyAdminOwnership itself?

There isn't, but upgrades.transferProxyAdminOwnership is mainly doing the same thing as what you mentioned anyways.

1 Like