DappRoot.sol

Overview

DappRoot.sol defines the DappRoot smart contract, which serves as the primary management contract for decentralized application (DApp) configurations. Its core functionality includes:

This contract interacts closely with the DappConfig contract for individual DApp configuration instances and utilizes utilities from DappLib for composing and calculating code and addresses related to configurations.


Contract: DappRoot

State Variables

Variable

Type

Description

version

string constant

Version identifier of the contract ("1.0.0").

_codeStorage

mapping(uint8 => TvmCell)

Stores code templates indexed by configuration IDs.

_is_close_owner

bool

Flag indicating whether the owner has closed the root contract.


Constructor

constructor ()

Functions

setNewCode

function setNewCode(uint8 id, TvmCell code) public senderIs(address(this)) accept

ensureBalance

function ensureBalance() private pure

deployNewConfigCustom

function deployNewConfigCustom(optional(address) authorityAddress) public view internalMsg accept

deployNewConfig

function deployNewConfig(uint256 dapp_id, bool is_unlimit, int128 available_balance, optional(address) authorityAddress) public view onlyOwnerPubkey(tvm.pubkey()) accept

deployNewConfigNode

function deployNewConfigNode(uint256 dapp_id, bool is_unlimit, int128 available_balance, optional(address) authorityAddress) public view senderIs(address(this)) accept

deployConfig

function deployConfig(uint256 dapp_id, CreditConfig info, optional(address) authorityAddress) private view

closeRoot

function closeRoot() public onlyOwnerPubkey(tvm.pubkey()) accept

getConfigAddr

function getConfigAddr(uint256 dapp_id) external view returns(address config)

getDappConfigCode

function getDappConfigCode(uint256 dapp_id) external view returns(TvmCell code)

Important Types and Constants


Interactions with Other Components


Implementation Details and Algorithms


Diagram: Class Structure of DappRoot

classDiagram
class DappRoot {
-string version
-mapping(uint8 => TvmCell) _codeStorage
-bool _is_close_owner
+constructor()
+setNewCode()
+deployNewConfigCustom()
+deployNewConfig()
+deployNewConfigNode()
-deployConfig()
+closeRoot()
+getConfigAddr()
+getDappConfigCode()
-ensureBalance()
}
DappRoot ..|> Modifiers
DappRoot --> DappConfig : deploys >
DappRoot ..> DappLib : uses >

Usage Examples


For detailed information on the CreditConfig struct, DappConfig contract, and related utility functions, see DappConfig Contract and DappLib Library. For access control mechanisms, see Modifiers.