diff --git a/docs/build/tooling/hardhat/hardhat-zksync-upgradable.md b/docs/build/tooling/hardhat/hardhat-zksync-upgradable.md index 5a8fa75f7..f9ed39bd1 100644 --- a/docs/build/tooling/hardhat/hardhat-zksync-upgradable.md +++ b/docs/build/tooling/hardhat/hardhat-zksync-upgradable.md @@ -30,6 +30,17 @@ Examples are adopted for plugin version **>=1.0.0** Current version of the upgradable plugin does not support the latest version of the `@openzeppelin/upgrades-core` package. ::: +:::warning @openzeppelin/contracts and @openzeppelin/contracts-upgradeable versions + +The plugin is not yet compatible with the latest versions of OpenZeppelin (v5). In the meantime, please use the previous version (OpenZeppelin v4) by specifying it in your `package.json`. + +``` + "@openzeppelin/contracts": "^4.9.5", + "@openzeppelin/contracts-upgradeable": "^4.9.5", +``` + +::: + [@matterlabs/hardhat-zksync-upgradable](https://www.npmjs.com/package/@matterlabs/hardhat-zksync-upgradable) Add the latest version of this plugin to your project with the following command: @@ -212,15 +223,29 @@ npx hardhat run SCRIPT_FILE - This provider is configured in the hardhat config file, by stating the RPC url of the network to connect to. ::: -### Openzeppelin Version +Additionally, in the options section optionally include the folowing arguments to configure the deployment of the proxy and implementation with different deployment types and salts: -The plugin does not work with the latest versions due to a blocker on the `@matterlab/zksync-contracts` package.The solution is to change the development dependencies to the previous version in your `package.json`. +- `deploymentTypeImpl` +- `saltImpl` +- `deploymentTypeProxy` +- `saltProxy` ``` - "@openzeppelin/contracts": "^4.9.5", - "@openzeppelin/contracts-upgradeable": "^4.9.5", + const box = await hre.zkUpgrades.deployProxy(deployer.zkWallet, contract, [42], + { initializer: "initialize", + saltImpl: "0x4273795673417857416686492163276941983664248508133571812215241323", + deploymentTypeImpl: "create2", + saltProxy: "0x5273795673417857416686492163276941983664248508133571812215241323", + deploymentTypeProxy: "create2" + } +); ``` +:::info +Allowed values for the deployment type include `create`, `create2`, `createAccount`, and `create2Account`. If this parameter is omitted, the default value will be `create`. +If the salt parameters are omitted, the default value will be `0x0000000000000000000000000000000000000000000000000000000000000000`. +::: + ### Hardhat config ```typescript @@ -412,6 +437,27 @@ npx hardhat run SCRIPT_FILE ::: +Additionally, in the options section optionally include the `deploymentType` and `salt` arguments to configure deployment type and salt. + +``` +const beacon = await hre.zkUpgrades.deployBeacon(deployer.zkWallet, boxContract, { + deploymentType: 'create2', + salt: '0x5273795673417857416686492163276941983664248508133571812215241323' +}); +await beacon.waitForDeployment(); + +const box = await hre.zkUpgrades.deployBeaconProxy(deployer.zkWallet, await beacon.getAddress(), boxContract, [42], { + deploymentType: 'create2', + salt: '0x6273795673417857416686492163276941983664248508133571812215241323' +}); +await box.waitForDeployment(); +``` + +:::info +Allowed values for the deployment type include `create`, `create2`, `createAccount`, and `create2Account`. If this parameter is omitted, the default value will be `create`. +If the salt parameters are omitted, the default value will be `0x0000000000000000000000000000000000000000000000000000000000000000`. +::: + ## Implementation addresses check Once you deploy the proxy contract, all interactions with your implementation contract go through it. @@ -498,11 +544,22 @@ To upgrade the implementation of the transparent upgradeable contract, use the ` await hre.zkUpgrades.upgradeProxy(deployer.zkWallet, , BoxV2); ``` -`upgradeProxy` receives 3 arguments: +`upgradeProxy` receives 4 arguments: - A zkSync Era wallet. - The address of the previously deployed box proxy. - The artifact containing the new `Box2` implementation. +- Other options + +Optionally in the other options section include `deploymentType` and `salt` to configure deployment type and salt for deploy of the new implementation. + +``` +const myContractV2 = await deployer.loadArtifact('BoxV2'); +await hre.zkUpgrades.upgradeProxy(deployer.zkWallet, , BoxV2, { + deploymentType: 'create2', + salt: '0x6273795673417857416686492163276941983664248508133571812215241323' +}); +``` ## Upgrade UUPS proxy @@ -648,6 +705,16 @@ npx hardhat run SCRIPT_FILE ::: +Optionally in the other options section include `deploymentType` and `salt` to configure deployment type and salt for deploy of the new implementation. + +``` +const myContractV2 = await deployer.loadArtifact('contractV2'); +await hre.zkUpgrades.upgradeBeacon(deployer.zkWallet, , myContractV2 { + deploymentType: 'create2', + salt: '0x6273795673417857416686492163276941983664248508133571812215241323' +}); +``` + # Proxy verification ::: warning @@ -803,19 +870,19 @@ const config: HardhatUserConfig = { ## Command list -`yarn hardhat deploy-zksync:proxy --contract-name [] [--constructor-args ] [--deployment-type ] [--initializer ] [--no-compile]` +`yarn hardhat deploy-zksync:proxy --contract-name [] [--constructor-args ] [--initializer ] [--deployment-type-impl ] [--salt-impl ] [--deployment-type-proxy ] [--salt-proxy ] [--no-compile]` Automatically determine whether the deployment requires a Transparent or UUPS proxy, and deploy all necessary contracts accordingly. If the Transparent proxy is chosen, the deployment will include the implementation, admin, and proxy. Alternatively, selecting the UUPS proxy will result in deploying the implementation and proxy. -`yarn hardhat upgrade-zksync:proxy --contract-name --proxy-address [--deployment-type ] [--no-compile]` +`yarn hardhat upgrade-zksync:proxy --contract-name --proxy-address [--deployment-type ] [--salt ] [--no-compile]` Upgrade UUPS or Transparent implementation on the specified network. -`yarn hardhat deploy-zksync:beacon --contract-name [] [--constructor-args ] [--deployment-type ] [--initializer ] [--no-compile]` +`yarn hardhat deploy-zksync:beacon --contract-name [] [--constructor-args ] [--initializer ] [--deployment-type-impl ] [--salt-impl ] [--deployment-type-proxy ] [--salt-proxy ] [--no-compile]` Initiates the deployment of the specified implementation, beacon, and proxy on the specified network. -`yarn hardhat upgrade-zksync:beacon --contract-name --beacon-address [--deployment-type ] [--no-compile]` +`yarn hardhat upgrade-zksync:beacon --contract-name --beacon-address [--deployment-type ] [--salt ] [--no-compile]` Upgrade beacon implementation on the specified network. @@ -839,6 +906,17 @@ module.exports = [ - `--proxy-address ` - deployed proxy contract address, e.g. `yarn hardhat upgrade-zksync:proxy --contract-name BoxV2 --proxy-address 0x4bbeEB066eD09B7AEd07bF39EEe0460DFa261520`. - `--initializer ` - initializer method name present in the contract, e.g. `hardhat deploy-zksync:proxy --contract-name Contract --initializer store`. If this parameter is omitted, the default value will be `initialize`. - `--no-compile`- skip the compilation process, e.g. `hardhat deploy-zksync:beacon --contract-name Contract --no-compile`. -- `--deployment-type` - specify which deployer smart contract function will be called. Permissible values for this parameter include `create`, `create2`, `createAccount`, and `create2Account`. If this parameter is omitted, the default value will be `create`, e.g. `hardhat deploy-zksync:beacon --contract-name Greeter 'Hello' --deployment-type create2`. +- `--deployment-type-proxy` - specify which deployer smart contract function will be called for proxy, e.g. `hardhat deploy-zksync:beacon --contract-name Greeter 'Hello' --deployment-type-proxy create2`. +- `--deployment-type-impl` - specify which deployer smart contract function will be called for implementation, e.g. `hardhat deploy-zksync:beacon --contract-name Greeter 'Hello' --deployment-type-impl create2`. +- `--salt-proxy` - specify which salt will be used in deployment of the proxy, e.g. `hardhat deploy-zksync:beacon --contract-name Greeter 'Hello' --salt-proxy 0x42737956734178574166864921632769419836642485081335718122152413290`. +- `--salt-impl` - specify which salt will be used in deployment of the implementation, e.g. `hardhat deploy-zksync:beacon --contract-name Greeter 'Hello' --salt-impl 0x42737956734178574166864921632769419836642485081335718122152413290`. +- When utilizing the `upgrade-zksync:beacon` or `upgrade-zksync:proxy` tasks, specify the deployment type and salt using the `--deployment-type` and `--salt` arguments respectively. + +:::info +Allowed values for the deployment type include `create`, `create2`, `createAccount`, and `create2Account`. If this parameter is omitted, the default value will be `create`. +If the salt parameters are omitted, the default value will be `0x0000000000000000000000000000000000000000000000000000000000000000`. +::: +:::info The account used for deployment will be the one specified by the `deployerAccount` configuration within the `hardhat.config.ts` file. If no such configuration is present, the account with index `0` will be used. +:::