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) {
_upgradeTo(_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.
Best Answer
Use
attach
to test an already deployed contract with some specific contract ABI. Assuming yourv1
contract is namedV1
, you may test the proxy contract withhardhat-waffle
like this:you can then use the
proxiedV1
object to callV1
's methods with theproxy
contract. For example if V1 is an ERC20Upgradeable contract with aninitialize
method (as per the UUPS patten):