I cannot use Transparent Proxy to upgrade the contract in v5

:1234: Code to reproduce

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

contract MyTransparentUpgradeableProxy is TransparentUpgradeableProxy {
    constructor(address _logic, address admin_, bytes memory _data) payable TransparentUpgradeableProxy(_logic, admin_, _data) {}

    function implementation() public view returns (address) {
        return _implementation();
    }

    function proxyAdmin() external returns (address) {
        return _proxyAdmin();
    }

    receive() external payable {}
}
    const IPorxyAbi = JSON.parse(fs.readFileSync('artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy.json', 'utf-8')).abi;

    let proxy = await deploy('CFD', {
        from: deployer,
        contract: 'MyTransparentUpgradeableProxy',
        args: [impl.address, deployer, cfdProxyData],
        log: true,
        skipIfAlreadyDeployed: true,
    });

    const IProxy = new ethers.Contract(proxy.address, IPorxyAbi);

    const signer = await ethers.provider.getSigner()
    await IProxy.connect(signer).upgradeToAndCall(impl.address, cfdProxyData);

:computer: Environment

  • hardhat:2.22.4
  • hardhat-deploy:0.12.4
  • openzeppelin/contracts:5.0.2

Please provide more info on what you have tried and what the error is. See:

Since you are upgrading a transparent proxy, ensure you are calling the upgrade through the proxy admin.

1 Like