class IconScoreBase(db: iconservice.database.db.IconScoreDatabase)

A base class of SCOREs. This class provides facilities and environments to SCORE to run.

__init__(db: iconservice.database.db.IconScoreDatabase) → None

A Python init function. Invoked when the contract is loaded at each node. Do not put state-changing works in here.


The current SCORE address

Returns:Address current address

Deprecated property

Use block_height and now() instead.


Current block height

Returns:current block height
call(addr_to: iconservice.base.address.Address, func_name: str, kw_dict: dict, amount: int = 0)

Calls an external function provided by another SCORE. func_name can be None if fallback calls

  • addr_toAddress the address of another SCORE
  • func_name – function name of another SCORE
  • kw_dict – arguments of the external function
  • amount – amount of ICX to transfer in loop

returning value of the external function

static create_interface_score(addr_to: iconservice.base.address.Address, interface_cls: Callable[[Address], 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


An instance used to access state DB

Returns:IconScoreDatabase db
fallback() → 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, it is not listed on the SCORE APIs also cannot be called.


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.
Returns:Icx instance of icx

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.
now() → int

Timestamp of current block in microseconds

Returns:timestamp in microseconds
on_install(**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(**kwargs) → None

Invoked when the contract is deployed for update. This is the place where you migrate old states.


Address of the account who deployed the contract

Returns:Address owner address
static revert(message: Optional[str] = None, code: int = 0)

Deprecated method

Use global function revert() instead.


Holds information of the transaction

Returns:Transaction transaction