replace_class_syscall
function. By using this function, you can update the class hash associated with a deployed contract, effectively upgrading its implementation. However, this will not modify the contract’s storage, so all the data stored in the contract will remain the same.
To illustrate this concept, let’s consider an example with two contracts: UpgradeableContract_V0
, and UpgradeableContract_V1
.
Start by deploying UpgradeableContract_V0
as the initial version. Next, send a transaction that invokes the upgrade
function, with the class hash of UpgradeableContract_V1
as parameter to upgrade the class hash of the deployed contract to the UpgradeableContract_V1
one. Then, call the version
method on the contract to see that the contract was upgraded to the V1 version.