UpdateZeroContract.sol

Overview

UpdateZeroContract.sol defines a smart contract designed to allow for self-upgradeability by updating its own code on the TON blockchain. This contract provides a method to replace its current code with new code, ensuring that the upgrade is authorized via public key verification. The contract also includes a method to retrieve its version information.

Contract: UpdateZeroContract

Purpose

UpdateZeroContract serves as a base contract enabling code upgrades via the updateCode function. It includes a constructor that accepts the incoming message and a version getter for identification purposes.


Constructor

constructor()

Function: updateCode

function updateCode(TvmCell newcode, TvmCell cell) public view
TvmCell new_code = /* compiled new contract code cell */;
TvmCell upgrade_data = /* optional upgrade data cell */;
updateCode(new_code, upgrade_data);

Function: onCodeUpgrade

function onCodeUpgrade(TvmCell cell) private pure

Function: getVersion

function getVersion() external pure returns(string, string)
(string version, string name) = contract.getVersion();

Implementation Details


Interaction with Other Components


Visual Diagram of UpdateZeroContract Structure

classDiagram
class UpdateZeroContract {
+constructor()
+updateCode(newcode: TvmCell, cell: TvmCell)
-onCodeUpgrade(cell: TvmCell)
+getVersion() string[2]
}

This diagram illustrates the contract's methods, highlighting the public interface and the private upgrade hook.