DappLib.sol

Overview

DappLib.sol is a Solidity library designed to facilitate the creation and management of decentralized application (dapp) configurations on the TON blockchain. The library provides utility functions to compose and derive the smart contract state initialization and addresses for DappConfig contracts. It primarily focuses on generating the correct TvmCell state initialization data and computing the unique address for a dapp configuration contract based on a given dapp identifier and contract code.

This file interacts closely with the DappConfig contract, enabling other parts of the system to instantiate or reference dapp configuration contracts deterministically by their unique dapp ID.


Library: DappLib

DappLib is a Solidity library that contains three main public functions:

Properties


Functions

calculateDappConfigAddress

function calculateDappConfigAddress(TvmCell code, uint256 dapp_id) public returns(address)

composeDappConfigStateInit

function composeDappConfigStateInit(TvmCell code, uint256 dapp_id) public returns(TvmCell)

buildDappConfigCode

function buildDappConfigCode(TvmCell originalCode, uint256 dapp_id) public returns (TvmCell)

Implementation Details


Interaction with Other Components


Visual Diagram

classDiagram
class DappLib {
+string versionLib
+calculateDappConfigAddress(code: TvmCell, dapp_id: uint256) address
+composeDappConfigStateInit(code: TvmCell, dapp_id: uint256) TvmCell
+buildDappConfigCode(originalCode: TvmCell, dapp_id: uint256) TvmCell
}
DappLib ..> DappConfig : uses

For further details on smart contract deployment and address derivation on the TON blockchain, refer to the topics on TON Addressing and StateInit and Smart Contract Salted Code.