Unable to uprgade the contract via proxyAdmin

I have deployed a contract on the Sepolia network using a transparent proxy. However, when attempting to upgrade the contract, the transaction is reverting. I would appreciate any assistance or solutions to resolve this issue, and I am performing this on the foundry

Here's the code:

 VaultConfig vaultConfigImpl = new VaultConfig();
 TransparentUpgradeableProxy vaultConfigProxy =
  new TransparentUpgradeableProxy(address(vaultConfigImpl), address(proxyAdmin), "");
  vaultConfig = VaultConfig(vaultConfigProxy);
  vaultConfig.initialize(deployer);

Upgrading through the below code:

proxyAdmin.upgradeAndCall(ITransparentUpgradeableProxy(proxy),address(vaultConfigImpl), "");

any help would be appreciated

I am assuming, that you are using version 5 of Openzeppelin.

If yes, then you don't need to deploy a separate proxyAdmin contract.

The transparentUpgradeableProxy deploys a proxyAdmin from it's constructor itself. So instead of deploying proxyAdmin and passing it's address to proxy's constructor. You should pass your EOA address, which was supposed to be the owner of proxyAdmin.

Look at this constructor and you'll get the point

And then to fetch the proxyAdmin address, you can fetch the Event logs.

3 Likes

Thanks!, can you help with this query as well, Does this mean that each time I deploy a new transparent proxy contract, a new ProxyAdmin contract will also be created? I want one proxy admin for all of my contracts

The admin address is stored twice, first one is the immutable varible in the proxy contract itself, and the second one is for ERC1967 compatibility, which is stored in a specific storage slot.

Although this specific slot can be updated from the implementation, but this won't actually change the admin.

Every proxy will have it's own admin.

2 Likes