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).
-
unit: str
-
rao_unit: str
-
rao: int
-
property tao
-
__int__()[source]
Convert the Balance object to an int. The resulting value is in rao.
-
__float__()[source]
Convert the Balance object to a float. The resulting value is in tao.
-
__str__()[source]
Returns the Balance object as a string in the format “symbolvalue”, where the value is in tao.
-
__rich__()[source]
-
__str_rao__()[source]
-
__rich_rao__()[source]
-
__repr__()[source]
-
__eq__(other)[source]
- Parameters:
other (Union[int, float, Balance])
-
__ne__(other)[source]
- Parameters:
other (Union[int, float, Balance])
-
__gt__(other)[source]
- Parameters:
other (Union[int, float, Balance])
-
__lt__(other)[source]
- Parameters:
other (Union[int, float, Balance])
-
__le__(other)[source]
- Parameters:
other (Union[int, float, Balance])
-
__ge__(other)[source]
- Parameters:
other (Union[int, float, Balance])
-
__add__(other)[source]
- Parameters:
other (Union[int, float, Balance])
-
__radd__(other)[source]
- Parameters:
other (Union[int, float, Balance])
-
__sub__(other)[source]
- Parameters:
other (Union[int, float, Balance])
-
__rsub__(other)[source]
- Parameters:
other (Union[int, float, Balance])
-
__mul__(other)[source]
- Parameters:
other (Union[int, float, Balance])
-
__rmul__(other)[source]
- Parameters:
other (Union[int, float, Balance])
-
__truediv__(other)[source]
- Parameters:
other (Union[int, float, Balance])
-
__rtruediv__(other)[source]
- Parameters:
other (Union[int, float, Balance])
-
__floordiv__(other)[source]
- Parameters:
other (Union[int, float, Balance])
-
__rfloordiv__(other)[source]
- Parameters:
other (Union[int, float, Balance])
-
__nonzero__()[source]
- Return type:
bool
-
__neg__()[source]
-
__pos__()[source]
-
__abs__()[source]
-
static from_float(amount)[source]
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_tao(amount)[source]
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.
-
static from_rao(amount)[source]
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.