- Deploy
UpgradableContract
and obtain the contract address0xContractAddress1
. - Deploy
ProxyContract
, passing0xContractAddress1
as a parameter to the constructor, and obtain the proxy contract address0xProxyContractAddress
.
- Design a new version of the contract,
UpgradableContractV2.sol
, which includes additional functionality such as retrieving the square of the stored integer value. - Deploy
UpgradableContractV2
and obtain the new contract address0xContractAddress2
. - Call the
upgrade
method of the proxy contract, passing0xContractAddress2
as the new implementation address:
ProxyContract.upgrade(0xContractAddress2)
Now, the proxy contract points to the new version of the contract, enabling users to interact with the updated functionality while maintaining the same proxy contract address.
This process allows for seamless updates to the contract's functionality without changing the contract address, enhancing flexibility and maintainability in decentralized applications.