Manually deploying UUPS proxy in Hardhat

I'm having trouble deploying a uups manually(without using the upgrades plugin) within a single hardhat script. Is there an implementation for that I can refer to?

To manually deploy a UUPS proxy, your script can look something like this:

  const MyContract = await ethers.getContractFactory('MyContract');
  const ERC1967Proxy = await ethers.getContractFactory('ERC1967Proxy');

  const impl = await MyContract.deploy();
  await impl.waitForDeployment();
  const proxy = await ERC1967Proxy.deploy(
    await impl.getAddress(),
    MyContract.interface.encodeFunctionData('initialize', ['Add your initializer arguments here']),
  );
  await proxy.waitForDeployment();

We recommend using the Upgrades plugin to check for upgrade safety though.

1 Like