bittensor.utils.balance#
Classes#
Represents the bittensor balance of the wallet, stored as rao (int). |
|
Represents a fixed point |
Functions#
|
Helper function to check and convert the amount type to a Balance object. |
|
|
|
Helper function to create a Balance object from an int (Rao) |
|
Helper function to create a Balance object from a float (Tao) |
Module Contents#
- class bittensor.utils.balance.Balance(balance)[source]#
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:
- Parameters:
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).
- static from_float(amount, netuid=0)[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 :param netuid: The subnet uid for set currency unit. Defaults to 0. :type netuid: int
- static from_rao(amount, netuid=0)[source]#
Given rao, return Balance object with rao(
int
) and tao(float
), where rao = int(tao*pow(10,9))
- static from_tao(amount, netuid=0)[source]#
Given tao, return Balance object with rao(
int
) and tao(float
), where rao = int(tao*pow(10,9))
- property tao#
- class bittensor.utils.balance.FixedPoint[source]#
Bases:
TypedDict
Represents a fixed point
U64F64
number. Wherebits
is a U128 representation of the fixed point number.This matches the type of the Alpha shares.
Initialize self. See help(type(self)) for accurate signature.
- bittensor.utils.balance.check_and_convert_to_balance(amount)[source]#
Helper function to check and convert the amount type to a Balance object. This is used to support backwards compatibility while also providing a deprecation notice.
- bittensor.utils.balance.fixed_to_float(fixed, frac_bits=64, total_bits=128)[source]#
- Parameters:
fixed (Union[FixedPoint, scalecodec.ScaleType])
frac_bits (int)
total_bits (int)
- Return type: