LicenseRoot.abi.json
Overview
The LicenseRoot.abi.json file defines the Application Binary Interface (ABI) for a smart contract that manages licenses and license owners within a system. This ABI specifies the contract's interface including its functions, fields, and their types, enabling interaction with the contract on a blockchain platform. The contract appears to handle deployment and management of different license types, including standard licenses and BM (presumably Business Model or another category) licenses, as well as managing ownership and code updates for licenses.
The ABI version is 2 and it uses version "2.4" of the contract interface specification. The contract expects a header containing pubkey, time, and expire fields for transaction or message validation.
Detailed Description of Functions
1. constructor
Purpose: Initializes the contract with essential parameters.
Inputs:
timeUnlock(uint32): A timestamp or duration related to unlocking functionality.license_number(uint256): The initial license number counter.license_number_bm(uint256): The initial license BM number counter.rootElection(address): Address associated with the root election contract or entity.rootBM(address): Address associated with the root BM contract or entity.
Outputs: None.
Usage: Called once when the contract is deployed to set initial state values.
2. deployLicense
Purpose: Deploys a new license contract instance.
Inputs:
pubkey(uint256): Public key identifying the license owner.
Outputs: None.
Usage: Used to create and register a new standard license associated with the provided public key.
3. deployLicenseOwner
Purpose: Deploys a license owner contract, optionally with privileged status.
Inputs:
pubkey(uint256): Public key identifying the license owner.isPrivileged(bool): Flag indicating if the license owner has privileged status.
Outputs: None.
Usage: Used to register a license owner, with the ability to mark them as privileged.
4. deployLicenseBM
Purpose: Deploys a new BM license contract instance.
Inputs:
pubkey(uint256): Public key identifying the BM license owner.
Outputs: None.
Usage: Similar to
deployLicense, but specifically for BM licenses.
5. deployLicenseBMOwner
Purpose: Deploys a BM license owner contract.
Inputs:
pubkey(uint256): Public key identifying the BM license owner.
Outputs: None.
Usage: Registers a BM license owner.
6. setNewCode
Purpose: Updates or sets new contract code for a specific component or contract type.
Inputs:
id(uint8): Identifier for the contract code type or version.code(cell): The new code in serialized cell format.
Outputs: None.
Usage: Enables code upgrades or patches to deployed contracts referencing this root.
7. getLastLicenseNum
Purpose: Retrieves the latest license numbers issued.
Inputs: None.
Outputs:
num(uint256): Last issued standard license number.numbm(uint256): Last issued BM license number.
Usage: Useful for clients or other contracts to query the current license counters.
8. getLicenseAddress
Purpose: Computes or retrieves the blockchain address of a license given its number.
Inputs:
num(uint256): License number.
Outputs:
license_address (
address): The address of the license contract.
Usage: Used to obtain the address of an existing license contract for interaction.
9. getLicenseBMAddress
Purpose: Computes or retrieves the blockchain address of a BM license given its number.
Inputs:
num(uint256): BM license number.
Outputs:
license_address (
address): The address of the BM license contract.
Usage: Similar to
getLicenseAddress, but for BM licenses.
10. getVersion
Purpose: Returns the version information of the contract.
Inputs: None.
Outputs:
value0(string): Primary version string (e.g., semantic version).value1(string): Secondary version or build metadata.
Usage: Allows external entities to verify the contract version.
Fields
Field Name | Type | Initialized | Description |
|---|---|---|---|
|
| Yes | Public key of the contract deployer or owner. |
|
| No | Timestamp related to contract state or deployment. |
|
| No | Flag indicating whether constructor has been called. |
|
| No | Mapping of contract code versions keyed by an identifier. |
|
| No | Unlock time parameter from constructor. |
|
| No | Counter for standard licenses issued. |
|
| No | Counter for BM licenses issued. |
|
| No | Address of the root election contract or manager. |
|
| No | Address of the root BM contract or manager. |
|
| No | Possibly number of licenses left or remaining quota. |
|
| No | Possibly number of BM licenses left or remaining quota. |
Implementation Details and Algorithms
The contract uses two distinct license counters (
_license_numberand_license_number_bm) to track issuance of standard licenses and BM licenses separately.License deployment functions (
deployLicense,deployLicenseOwner,deployLicenseBM,deployLicenseBMOwner) take a public key as input, which likely serves as the owner identifier for the deployed license contract.The
setNewCodefunction enables updating the contract code dynamically by storing serialized code cells keyed by an identifier, supporting upgradeability.License addresses are derived from license numbers, implying a deterministic address generation scheme common in blockchain smart contracts.
The use of a header with
pubkey,time, and expire suggests that calls to this contract include authentication and time-based validity checks.The
_constructorFlagboolean ensures that constructor logic is executed only once, preventing re-initialization.
Interactions with Other Parts of the System
The contract interacts with two root contracts or managers identified by
_rootElectionand_rootBMaddresses. These roots likely coordinate election and BM license-related activities respectively.Deployed license contracts and license owner contracts are likely separate entities created by this root, forming a hierarchical contract structure.
The contract serves as a central registry and factory for license-related contracts, facilitating license management workflows in the system.
The versioning mechanism (
getVersion) helps maintain compatibility and upgrade paths across system components.The code mapping (
_code) allows this root contract to manage or reference different code versions for dependent contracts, supporting modular upgrades.
Mermaid Diagram: LicenseRoot Contract Structure
classDiagram
class LicenseRoot {
+uint256 _pubkey
+uint64 _timestamp
+bool _constructorFlag
+map(uint8, cell) _code
+uint32 _timeUnlock
+uint256 _license_number
+uint256 _license_number_bm
+address _rootElection
+address _rootBM
+uint128 _licenseLeft
+uint128 _licenseBMLeft
+constructor(timeUnlock, license_number, license_number_bm, rootElection, rootBM)
+deployLicense(pubkey)
+deployLicenseOwner(pubkey, isPrivileged)
+deployLicenseBM(pubkey)
+deployLicenseBMOwner(pubkey)
+setNewCode(id, code)
+getLastLicenseNum() uint256 num, uint256 numbm
+getLicenseAddress(num) address
+getLicenseBMAddress(num) address
+getVersion() string value0, string value1
}
This class diagram illustrates the internal state fields and publicly accessible functions of the LicenseRoot contract, reflecting its role as a factory and manager for license-related entities.