bittensor.utils.balance#

Classes#

Balance

Represents the bittensor balance of the wallet, stored as rao (int).

Module Contents#

class bittensor.utils.balance.Balance(balance)#

Represents the bittensor balance of the wallet, stored as rao (int). This class provides a way to interact with balances in two different units: rao and tao. It provides methods to convert between these units, as well as to perform arithmetic and comparison operations.

Variables:
  • unit (str) – A string representing the symbol for the tao unit.

  • rao_unit (str) – A string representing the symbol for the rao unit.

  • rao (int) – An integer that stores the balance in rao units.

  • tao (float) – A float property that gives the balance in tao units.

Parameters:

balance (Union[int, float])

Initialize a Balance object. If balance is an int, it’s assumed to be in rao. If balance is a float, it’s assumed to be in tao.

Parameters:

balance (Union[int, float]) – The initial balance, in either rao (if an int) or tao (if a float).

__abs__()#
__add__(other)#
Parameters:

other (Union[int, float, Balance])

__eq__(other)#
Parameters:

other (Union[int, float, Balance])

__float__()#

Convert the Balance object to a float. The resulting value is in tao.

__floordiv__(other)#
Parameters:

other (Union[int, float, Balance])

__ge__(other)#
Parameters:

other (Union[int, float, Balance])

__gt__(other)#
Parameters:

other (Union[int, float, Balance])

__int__()#

Convert the Balance object to an int. The resulting value is in rao.

__le__(other)#
Parameters:

other (Union[int, float, Balance])

__lt__(other)#
Parameters:

other (Union[int, float, Balance])

__mul__(other)#
Parameters:

other (Union[int, float, Balance])

__ne__(other)#
Parameters:

other (Union[int, float, Balance])

__neg__()#
__nonzero__()#
Return type:

bool

__pos__()#
__radd__(other)#
Parameters:

other (Union[int, float, Balance])

__repr__()#
__rfloordiv__(other)#
Parameters:

other (Union[int, float, Balance])

__rich__()#
__rich_rao__()#
__rmul__(other)#
Parameters:

other (Union[int, float, Balance])

__rsub__(other)#
Parameters:

other (Union[int, float, Balance])

__rtruediv__(other)#
Parameters:

other (Union[int, float, Balance])

__str__()#

Returns the Balance object as a string in the format “symbolvalue”, where the value is in tao.

__str_rao__()#
__sub__(other)#
Parameters:

other (Union[int, float, Balance])

__truediv__(other)#
Parameters:

other (Union[int, float, Balance])

static from_float(amount)#

Given tao, return Balance() object with rao(int) and tao(float), where rao = int(tao*pow(10,9)) :param amount: The amount in tao. :type amount: float

Returns:

A Balance object representing the given amount.

Parameters:

amount (float)

static from_rao(amount)#

Given rao, return Balance object with rao(int) and tao(float), where rao = int(tao*pow(10,9))

Parameters:

amount (int) – The amount in rao.

Returns:

A Balance object representing the given amount.

static from_tao(amount)#

Given tao, return Balance object with rao(int) and tao(float), where rao = int(tao*pow(10,9))

Parameters:

amount (float) – The amount in tao.

Returns:

A Balance object representing the given amount.

rao: int#
rao_unit: str#
property tao#
unit: str#