License.abi.json
Overview
The License.abi.json file defines the Application Binary Interface (ABI) for a smart contract that manages licenses in a blockchain environment. This ABI specifies the available functions, their inputs and outputs, state variables (fields), and the versioning details relevant to the contract. The contract primarily handles license ownership, management, and token-related operations such as withdrawing tokens or adding balance. It includes mechanisms for license acceptance, rejection, deletion, and management of associated wallets and keys.
This ABI serves as the communication interface between off-chain clients and the on-chain contract, enabling clients to invoke contract methods and interpret the responses according to the specified types and structures.
ABI Metadata
ABI version: 2
Contract version: 2.4
Header fields:
pubkey,time, expire
The header fields are used to authenticate and timestamp transactions involving this contract, ensuring secure and time-bound operations.
Fields (State Variables)
Field Name | Type | Initialized | Description |
|---|---|---|---|
Yes | Public key associated with the contract instance | ||
| No | Timestamp of the last relevant contract event or state change | |
| No | Flag indicating if the constructor was successfully called | |
Yes | Unique identifier for the license | ||
| Yes | Root address related to the license context | |
| No | Optional public key of the license owner | |
| No | Optional address of the license owner | |
| No | Address representing a root election entity | |
|
| No | Optional backup wallet address associated with the license |
|
| No | Metric representing reputation time associated with the license |
|
| No | Flag indicating privileged status of the license |
|
| No | Mapping of code cells, potentially for different logic versions or modules |
| No | Timestamp marking the start of the license period | |
| No | Status flag indicating readiness of the license contract | |
| No | Timestamp of the last interaction or update to the license | |
| No | Timestamp indicating the last license-related action |
Functions
constructor(pubkey: uint256, walletCode: cell, rootElection: address, isPrivileged: bool)
Purpose: Initializes the license contract with key parameters including the public key, wallet code, root election address, and privilege status.
Inputs:
pubkey: Public key of the contract owner or issuer.walletCode: Serialized code cell representing the wallet logic.rootElection: Address of the root election authority.isPrivileged: Flag to indicate if the license has privileged status.
Outputs: None
Usage: This function is called once upon contract deployment to set initial parameters.
setOwnerAddress(owner: address)
Purpose: Sets or updates the owner's blockchain address.
Inputs:
owner: New owner address to be set.
Outputs: None
Usage: Used to change ownership or assign ownership to a specific blockchain address.
setOwnerPubkey(pubkey: uint256)
Purpose: Sets or updates the owner's public key.
Inputs:
pubkey: New public key to be assigned to the owner.
Outputs: None
Usage: Allows updating the cryptographic public key associated with the owner.
setLockToStake(lock: bool)
Purpose: Locks or unlocks the license for staking purposes.
Inputs:
lock: Boolean flag to enable (true) or disable (false) staking lock.
Outputs: None
Usage: Controls whether the license can be staked or is locked from staking.
removeBKWallet()
Purpose: Removes the backup wallet associated with the license.
Inputs: None
Outputs: None
Usage: Clears the backup wallet address, potentially for security or ownership transfer.
deleteWallet(reputationTime: uint128, isPrivileged: bool, last_touch: uint64)
Purpose: Deletes the wallet from the license contract with given parameters.
Inputs:
reputationTime: Reputation time metric used in deletion logic.isPrivileged: Indicates if the license is privileged at deletion.last_touch: Timestamp marking the last interaction before deletion.
Outputs: None
Usage: Used to remove or deactivate a wallet under certain conditions.
destroyLicense()
Purpose: Permanently destroys the license contract.
Inputs: None
Outputs: None
Usage: This function is called to invalidate and remove the license from the system.
addBKWallet(pubkey: uint256)
Purpose: Adds a backup wallet using a public key.
Inputs:
pubkey: Public key of the backup wallet to add.
Outputs: None
Usage: Sets a backup wallet for license recovery or secondary access.
notAcceptLicense(pubkey: uint256)
Purpose: Rejects acceptance of a license by a given public key.
Inputs:
pubkey: Public key rejecting the license.
Outputs: None
Usage: Used to explicitly refuse a license assignment or transaction.
acceptLicense(pubkey: uint256, last_touch: uint64)
Purpose: Accepts a license assignment with a public key and timestamp.
Inputs:
pubkey: Public key accepting the license.last_touch: Timestamp of the acceptance action.
Outputs: None
Usage: Confirms acceptance of the license by a specific key holder.
toWithdrawToken(value: uint128)
Purpose: Marks tokens for withdrawal from the license contract.
Inputs:
value: Amount of tokens to be withdrawn.
Outputs: None
Usage: Initiates a token withdrawal request.
withdrawToken(to: address, value: uint128)
Purpose: Transfers tokens from the license contract to a specified address.
Inputs:
to: Destination address for the tokens.value: Amount of tokens to transfer.
Outputs: None
Usage: Executes actual withdrawal of tokens to an external wallet.
toAddBalance(value: uint128)
Purpose: Adds balance (tokens) to the license contract.
Inputs:
value: Amount of tokens to add.
Outputs: None
Usage: Used to increase the token balance held by the license.
getDetails()
Purpose: Retrieves detailed information about the license.
Inputs: None
Outputs:
license_number: Unique license identifier.bkwallet: Optional backup wallet address.owner_pubkey: Optional owner public key.
owner_address: Optional owner address.reputationTime: Reputation time metric.license_start: Timestamp when the license started.
Usage: Provides comprehensive license state data for client queries.
getBK()
Purpose: Retrieves the backup wallet address.
Inputs: None
Outputs:
bkwallet: Optional backup wallet address.
Usage: Enables clients to fetch the backup wallet associated with the license.
getOwner()
Purpose: Retrieves the owner’s public key and address.
Inputs: None
Outputs:
owner_pubkey: Optional owner public key.
owner_address: Optional owner address.
Usage: Provides ownership data for verification or display.
getVersion()
Purpose: Returns the contract's version information.
Inputs: None
Outputs:
value0: First version string (e.g., major version).value1: Second version string (e.g., minor or patch version).
Usage: Allows clients to verify the contract version they are interacting with.
Important Implementation Details
The contract uses optional types (
optional(address),optional(uint256)) to represent fields that may or may not be set, allowing for flexible ownership and wallet management.Timestamps (e.g., _timestamp, _license_start, _last_touch) are stored as 64-bit unsigned integers representing Unix time, crucial for managing license validity and state transitions.
The
_codefield maps unsigned 8-bit integers to cell types, probably storing different parts of the contract’s executable logic or wallet code. This suggests modular or upgradeable contract design.The contract includes privileged status management (
_isPrivileged), which might affect permissions or behavior in the broader system.Functions related to token management (
toWithdrawToken,withdrawToken,toAddBalance) indicate integration with a token economy, possibly for license payments or staking.The
acceptLicenseandnotAcceptLicensefunctions facilitate explicit consent mechanisms, important for decentralized control and security.The design uses a constructor with several initialization parameters to tightly control contract instantiation.
Interactions with Other System Components
The contract interacts with wallet contracts or wallet code via the
walletCodeparameter during construction and the_codemap field, suggesting integration with wallet management subsystems.The presence of
rootElectionand _rootElection fields indicates interaction with a root election or governance contract or entity, potentially for license validation or governance decisions.Token withdrawal and balance functions imply cooperation with token contracts or token management layers in the system.
Owner and backup wallet management ensures the contract can interface with external addresses and public keys, facilitating user or system-level ownership transitions.
Time-related fields and reputation metrics suggest integration with reputation systems or time-based license validation mechanisms within the broader application.
Visual Diagram: Structure and Function Relationships
flowchart TD
constructor -->|initializes| LicenseContract
LicenseContract --> setOwnerAddress
LicenseContract --> setOwnerPubkey
LicenseContract --> setLockToStake
LicenseContract --> addBKWallet
LicenseContract --> removeBKWallet
LicenseContract --> acceptLicense
LicenseContract --> notAcceptLicense
LicenseContract --> deleteWallet
LicenseContract --> destroyLicense
LicenseContract --> toWithdrawToken
LicenseContract --> withdrawToken
LicenseContract --> toAddBalance
LicenseContract --> getDetails
LicenseContract --> getBK
LicenseContract --> getOwner
LicenseContract --> getVersion
Legend:
LicenseContractrepresents the contract instance managing all license-related state and actions.Arrows indicate available functions that operate on or modify the license state.
Usage Examples
Initializing the License Contract
contract.constructor(pubkey, walletCode, rootElectionAddress, isPrivileged);
Constructs the license contract with necessary keys, wallet logic, and privilege status.
Changing the Owner's Address
contract.setOwnerAddress(newOwnerAddress);
Updates the license ownership to a new blockchain address.
Accepting a License
contract.acceptLicense(userPubkey, currentTimestamp);
Records a user's acceptance of the license, including the time of acceptance.
Retrieving License Details
const details = contract.getDetails();
console.log(details.license_number, details.owner_address, details.reputationTime);
Fetches comprehensive license information for display or processing.
This ABI file is essential for interacting programmatically with the license smart contract and forms the contract's external interface for all operations related to license lifecycle, ownership, and token management. For deeper understanding of ABI usage and smart contract interactions, see Smart Contract ABI and Blockchain Token Management.