DappRoot.abi.json
Overview
The DappRoot.abi.json file defines the Application Binary Interface (ABI) for the "DappRoot" smart contract. This ABI specifies the contract's functions, state fields, and headers, enabling interaction with the contract on a blockchain platform. The contract is designed to manage deployment and configuration of decentralized application (DApp) components, including code updates, configuration deployment, and lifecycle management.
The ABI version is 2 with a contract version of 2.4. It includes a header specifying pubkey, time, and expire fields, which are used for authentication and transaction timing. The contract maintains internal state fields such as a public key, timestamp, constructor flag, code storage mapping, and a flag indicating ownership status.
Contract Functions
The contract exposes several functions, each with specific responsibilities related to DApp management:
constructor()
Purpose: Initializes the contract instance.
Inputs: None.
Outputs: None.
Usage example: Invoked automatically on deployment to set up initial state.
setNewCode(id: uint8, code: cell)
Purpose: Updates or sets new code identified by an 8-bit unsigned integer
id.Parameters:
id: Identifier for the code segment to be stored or updated.code: A serialized code cell representing the smart contract code.
Outputs: None.
Usage example: Used when upgrading or adding new code modules for the DApp.
deployNewConfigCustom(authorityAddress: optional(address))
Purpose: Deploys a new custom configuration contract optionally associated with an authority address.
Parameters:
authorityAddress: Optional blockchain address that may have authority over the deployed config.
Outputs: None.
Usage example: Deploys configuration with special authority permissions or custom settings.
deployNewConfig(dapp_id: uint256, is_unlimit: bool, available_balance: int128, authorityAddress: optional(address))
Purpose: Deploys a new DApp configuration with specific parameters.
Parameters:
dapp_id: Unique 256-bit identifier for the DApp.
is_unlimit: Boolean flag indicating if the configuration is unlimited.available_balance: Integer representing the available balance allocated to this config.authorityAddress: Optional authority address for managing the config.
Outputs: None.
Usage example: Used to instantiate a new configuration with resource limits and authority controls.
deployNewConfigNode(dapp_id: uint256, is_unlimit: bool, available_balance: int128, authorityAddress: optional(address))
Purpose: Similar to
deployNewConfig, but likely specialized for node-specific configuration deployment.Parameters: Same as
deployNewConfig.Outputs: None.
Usage example: Deploys node-level configuration within the DApp ecosystem.
closeRoot()
Purpose: Closes or disables the root contract.
Inputs: None.
Outputs: None.
Usage example: Called when the root contract needs to be deactivated or ownership revoked.
getConfigAddr(dapp_id: uint256) → address
Purpose: Retrieves the address of the configuration contract associated with a specific DApp ID.
Parameters:
dapp_id: The unique identifier of the DApp.
Returns:
config: The blockchain address of the configuration contract.
Usage example: Used to query the deployed config contract address for a given DApp.
getDappConfigCode(dapp_id: uint256) → cell
Purpose: Retrieves the serialized code cell of the DApp configuration by DApp ID.
Parameters:
dapp_id: The unique identifier of the DApp.
Returns:
code: The code cell containing the DApp configuration.
Usage example: Used to fetch the current code implementation for a given DApp configuration.
Fields
The contract maintains the following state fields:
_pubkey(uint256, initialized): The public key associated with the contract, used for signature verification and ownership._timestamp(uint64): Stores the last recorded timestamp, possibly for timing or expiration logic._constructorFlag(bool): Indicates whether the constructor has been executed._codeStorage(mapuint8→cell): A mapping from code IDs to their respective code cells, enabling modular code storage._is_close_owner(bool): Flag indicating if the root contract ownership or operational state is closed.
Implementation Details and Algorithms
Code Management: The contract uses a map
_codeStorageto maintain multiple code segments indexed by an 8-bit identifier. This permits modular upgrades or additions of code without redeploying the entire contract.Deployment Logic: Functions like
deployNewConfig,deployNewConfigNode, anddeployNewConfigCustomallow flexible deployment of configuration contracts with varying parameters, including resource limits and optional authority addresses.Access Control: The presence of
_pubkeyand optional authorityAddress parameters suggests the contract enforces permission checks based on cryptographic keys and addresses.Lifecycle Control: The
closeRootfunction and_is_close_ownerflag imply a controlled shutdown or deactivation mechanism for the root contract.
Interaction with Other System Components
The
DappRootcontract acts as a central coordinator for deploying and managing configurations of DApps within the system.It likely interacts with configuration contracts deployed via
deployNewConfigand related functions, which represent individual or node-specific DApp settings.External actors interact with this contract by calling its functions to update code, deploy configurations, query addresses, or close the contract.
The use of
optional(address)types indicates dynamic relationships with authority contracts or addresses, enabling modular delegation and control.
Visual Diagram
flowchart TD
A[DappRoot Contract]
A -->|constructor()| Init
A -->|setNewCode()| CodeStorage
A -->|deployNewConfigCustom()| ConfigCustom
A -->|deployNewConfig()| Config
A -->|deployNewConfigNode()| ConfigNode
A -->|closeRoot()| CloseState
A -->|getConfigAddr()| QueryConfigAddr
A -->|getDappConfigCode()| QueryConfigCode
subgraph State Fields
CodeStorage["_codeStorage (map<uint8, cell>)"]
PubKey["_pubkey (uint256)"]
Timestamp["_timestamp (uint64)"]
ConstructorFlag["_constructorFlag (bool)"]
CloseOwner["_is_close_owner (bool)"]
end
Init --> PubKey
Init --> ConstructorFlag
CloseState --> CloseOwner
This diagram illustrates the main functions of the contract and their relation to the key state fields. Functions such as setNewCode update the _codeStorage, while deployment functions create new configuration contracts. Lifecycle functions update ownership and closure status. Query functions access stored data for external use.