Testing Proxies with Hardhat

Hi, I have a smart contract that was inherited from UUPSUpgradeable smart contract. I am deploying it first as v1 and then deploying my proxy contract. Here is my proxy contract:

// SPDX-License-Identifier: MIT
pragma solidity 0.8.11;

import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract Proxy is UUPSUpgradeable, Ownable {

    constructor(address _impl) {
    function _authorizeUpgrade(address) internal override onlyOwner {}

I am giving the v1.address as constructor parameter to the proxy. Am I doing the right thing? If I am, how can I send tx to proxy to delegate? I am using hardhat for testing, as you can see in the title.

Hi @0fatih, keep in mind the differences between a proxy contract and an implementation contract -- generally you only need to write your implementation contract and that is the contract that should inherit UUPSUpgradable. You can use https://wizard.openzeppelin.com/ and select UUPS to see an example. The proxy contract (ERC1967Proxy for UUPS) can just be deployed directly.

To simplify the above, you can use OpenZeppelin Upgrades Plugins to help deploy both the implementation and proxy contracts (which also verifies that your implementation contract is upgrade safe).

Thanks for replying @ericglau! Can you share with me an example Proxy contract?

@ericglau I used OZ Upgrades Plugin and I saw what does looks like. Thank you very much!