Hi @deepan_chakkravarthy_bfbe I believe the best environment to deploy proxy contracts is Hardhat. You can start a new Hardhat project (See this tutorial for more details on how to do that). Then install the following dependencies:
And make your Smart Contract Initializable. The code below is based on the Pizza.sol contract:
// SPDX-License-Identifier: MIT
pragmasolidity^0.8.10;// Open Zeppelin libraries for controlling upgradability and access.
import"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";import"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";import"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";contractPizzaisInitializable,UUPSUpgradeable,OwnableUpgradeable{uint256publicslices;///@dev no constructor in upgradable contracts. Instead we have initializers
///@param _sliceCount initial number of slices for the pizza
functioninitialize(uint256_sliceCount)publicinitializer{slices=_sliceCount;///@dev as there is no constructor, we need to initialise the OwnableUpgradeable explicitly
__Ownable_init();}///@dev required by the OZ UUPS module
function_authorizeUpgrade(address)internaloverrideonlyOwner{}///@dev decrements the slices when called
functioneatSlice()external{require(slices>1,"no slices left");slices-=1;}}
To deploy this contract along with its upgradable proxy, create a deployment script deploy.js:
Hi @deepan_chakkravarthy_bfbe I believe the best environment to deploy proxy contracts is
Hardhat
. You can start a newHardhat
project (See this tutorial for more details on how to do that). Then install the following dependencies:You can change your
hardhat.config.js
file to include the dependencies:And make your Smart Contract Initializable. The code below is based on the Pizza.sol contract:
To deploy this contract along with its upgradable proxy, create a deployment script
deploy.js
:And proceed to deploy the contract: