openzeppelin-upgrades icon indicating copy to clipboard operation
openzeppelin-upgrades copied to clipboard

Sending contract balance when deployProxy

Open NTTLuke opened this issue 3 years ago • 3 comments

Scenario

I want to integrate the OZ Upgrade plugin into my actual contract. My actual contract is able to receive eth balance during the deployment process. (payable ctor)

Goal

Adding a way for sending contract balance to deployProxy function.

References

I asked on OZ community forum and team suggested to open an issue. See : https://forum.openzeppelin.com/t/sending-contract-balance-when-deployproxy/25855

Code to reproduce

My actual contract

....omissis...

    const myContractFactory = await hre.ethers.getContractFactory("MyContract");
    const myContract= await myContractFactory .deploy({
      
     //note : after deploy my contract balance is 0.001 eth
      value: hre.ethers.utils.parseEther("0.001"),
    });

...omissis...

Updated Contract using OZProxy

....omissis...

     let balance = hre.ethers.utils.parseEther("0.0001");
    const myContractFactory = await hre.ethers.getContractFactory("MyContract");
    const myContract = await upgrades.deployProxy(myContractFactory,
        {
       //it doesn't work 
            value: balance,
            initializer: "setup"

        });

...omissis...

Thank you :)

NTTLuke avatar Mar 13 '22 11:03 NTTLuke

Wow!, I thought I was finally gonna get help here LOL

marxxt avatar Jul 04 '22 04:07 marxxt

Any updates on this? I would like to send a value when deploying a proxy.

waynehoover avatar May 11 '23 02:05 waynehoover

We think this would be good to add. Here is what we propose in terms of usage and behaviour. Let us know if you have comments.

Usage would be with a value option for the deployProxy, deployBeaconProxy, and platform.deployContract functions, similar to the example suggested in the description above.

This value would be used only when deploying the proxy.

An initializer is not required. But if an initializer is called when deploying the proxy, the value will be provided to the initializer and the initializer MUST be payable.

Note that the value would NOT be used when deploying the implementation contract, proxy admin contract, or when upgrading a proxy.

ericglau avatar Jun 08 '23 20:06 ericglau