A base class of SCOREs. this class provides facilities and environments to SCORE to run.
__init__(self, db: iconservice.database.db.IconScoreDatabase) → None¶
A python init function. Invoked when the contract is loaded at each node.
on_install(self, **kwargs) → None¶
Invoked when the contract is deployed for the first time, and will not be called again on contract update or deletion afterward. This is the place where you initialize the state DB.
on_update(self, **kwargs) → None¶
Invoked when the contract is deployed for update This is the place where you migrate old states.
fallback(self) → None¶
fallback function can not be decorated with @external. (i.e., fallback function is not allowed to be called by external contract or user.) This fallback function is executed whenever the contract receives plain icx coins without data. If the fallback function is not decorated with @payable, the icx coin transfers to the contract will fail.
call(self, addr_to: iconservice.base.address.Address, func_name: str, kw_dict: dict, amount: int = 0)¶
Call external function provided by other IconScore with arguments without fallback
- addr_to –
Addressthe address of other IconScore
- func_name – function name provided by other IconScore
- kw_dict – Arguments of the external function
- amount – ICX value to enclose with. in loop.
returning value of the external function
- addr_to –
create_interface_score(self, addr_to: iconservice.base.address.Address, interface_cls: Callable[[Address, callable], T]) → T¶
Creates an object, through which you have an access to the designated SCORE’s external functions.
- addr_to – SCORE address
- interface_cls – interface class
An instance of given class
now(self) → int¶
Timestamp of current block in microseconds
Returns: timestamp in microseconds
Holds information of calling the SCORE
- msg.sender : Address of the account who called this function. If other contact called this function, msg.sender points to the caller contract’s address.
- msg.value : Amount of icx that the sender attempts to transfer to the current SCORE.
An object used to transfer icx coin
- icx.transfer(addr_to(address), amount(integer)) -> bool Transfers
designated amount of icx coin to
addr_to. If exception occurs during execution, the exception will be escalated. Returns True if coin transfer succeeds.
- icx.send(addr_to(address), amount(integer)) -> bool Sends designated
amount of icx coin to
addr_to. Basic behavior is same as transfer, the difference is that exception is caught inside the function. Returns True when coin transfer succeeded, False when failed.
Icxinstance of icx
- icx.transfer(addr_to(address), amount(integer)) -> bool Transfers designated amount of icx coin to
- Current block height
Returns: current block height