License.sol

Overview

License.sol defines the LicenseContract smart contract, which manages licensing functionality within a system involving blockkeeper wallets and elections. This contract handles license ownership, wallet association, reputation, license lifecycle (creation, update, and destruction), and token balance operations. It interacts closely with AckiNackiBlockKeeperNodeWallet wallets and a root election address, ensuring controlled access and state consistency via guarded functions and balance checks.

Contract: LicenseContract

Purpose

The LicenseContract manages an individual license's lifecycle and state, including ownership transfer, wallet linkage, reputation tracking, and token management. It provides mechanisms for adding/removing blockkeeper wallets, accepting or rejecting licenses, as well as withdrawing and adding token balances.


State Variables

Variable

Type

Description

version

string constant

Contract version identifier "1.0.0".

_license_number

uint256 static

Unique license identifier (immutable).

_root

address static

Root address reference (immutable).

_owner_pubkey

optional(uint256)

Public key of the license owner (optional).

_owner_address

optional(address)

Address of the license owner (optional).

_rootElection

address

Address of the root election contract.

_bkwallet

optional(address)

Address of the associated BlockKeeper wallet (optional).

_reputationTime

uint128

Reputation timestamp or counter for the license.

_isPrivileged

bool

Flag indicating if the license is privileged.

_code

mapping(uint8 => TvmCell)

Mapping for storing code cells indexed by code type.

_license_start

uint64

Timestamp for the license start.

is_ready

bool

Flag indicating readiness state of the license.

_last_touch

uint64

Last interaction block sequence number.

_licenseLastTouch

uint64

Last license-specific interaction block sequence number.


Constructor

constructor (
    uint256 pubkey,
    TvmCell walletCode,
    address rootElection,
    bool isPrivileged
) senderIs(_root) accept

Methods

setOwnerAddress

function setOwnerAddress(address owner) public onlyOwnerWalletOpt(_owner_address, _owner_pubkey) accept

setOwnerPubkey

function setOwnerPubkey(uint256 pubkey) public onlyOwnerWalletOpt(_owner_address, _owner_pubkey) accept

setLockToStake

function setLockToStake(bool lock) public onlyOwnerWalletOpt(_owner_address, _owner_pubkey) accept

removeBKWallet

function removeBKWallet() public onlyOwnerWalletOpt(_owner_address, _owner_pubkey) accept

deleteWallet

function deleteWallet(uint128 reputationTime, bool isPrivileged, uint64 last_touch) public

destroyLicense

function destroyLicense() public

addBKWallet

function addBKWallet(uint256 pubkey) public onlyOwnerWalletOpt(_owner_address, _owner_pubkey) accept

notAcceptLicense

function notAcceptLicense(uint256 pubkey) public view senderIs(calculatedWalletAddress) accept

acceptLicense

function acceptLicense(uint256 pubkey, uint64 last_touch) public senderIs(calculatedWalletAddress) accept

toWithdrawToken

function toWithdrawToken(uint128 value) public onlyOwnerWalletOpt(_owner_address, _owner_pubkey) accept

withdrawToken

function withdrawToken(address to, uint128 value) public onlyOwnerWalletOpt(_owner_address, _owner_pubkey) accept

toAddBalance

function toAddBalance(uint128 value) public onlyOwnerWalletOpt(_owner_address, _owner_pubkey) accept

receive()


Getters

getDetails

function getDetails() external view returns (
    uint256 license_number,
    optional(address) bkwallet,
    optional(uint256) owner_pubkey,
    optional(address) owner_address,
    uint128 reputationTime,
    uint64 license_start
)

getBK

function getBK() external view returns (optional(address) bkwallet)

getOwner

function getOwner() external view returns (optional(uint256) owner_pubkey, optional(address) owner_address)

getVersion

function getVersion() external pure returns(string, string)

Important Implementation Details


Interactions with Other Contracts


Visual Diagram

classDiagram
class LicenseContract {
-string version
-uint256 _license_number
-address _root
-optional(uint256) _owner_pubkey
-optional(address) _owner_address
-address _rootElection
-optional(address) _bkwallet
-uint128 _reputationTime
-bool _isPrivileged
-mapping(uint8 => TvmCell) _code
-uint64 _license_start
-bool is_ready
-uint64 _last_touch
-uint64 _licenseLastTouch
+constructor(pubkey, walletCode, rootElection, isPrivileged)
+setOwnerAddress(owner)
+setOwnerPubkey(pubkey)
+setLockToStake(lock)
+removeBKWallet()
+deleteWallet(reputationTime, isPrivileged, last_touch)
+destroyLicense()
+addBKWallet(pubkey)
+notAcceptLicense(pubkey)
+acceptLicense(pubkey, last_touch)
+toWithdrawToken(value)
+withdrawToken(to, value)
+toAddBalance(value)
+getDetails()
+getBK()
+getOwner()
+getVersion()
}
LicenseContract --> "1" AckiNackiBlockKeeperNodeWallet : interacts with
LicenseContract --> "1" BlockKeeperLib : uses for address calculation
LicenseContract --> "1" Modifiers : applies access controls

This diagram shows the LicenseContract class, its attributes, and methods, as well as its relationships with AckiNackiBlockKeeperNodeWallet, BlockKeeperLib, and Modifiers. The arrows indicate dependencies and interactions.


Notes on Usage

For more about smart contract access control and token handling, see Modifiers and Token Management. For wallet address calculations, refer to BlockKeeperLib.