bittensor.utils.balance#
Attributes#
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)#
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)#
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)#
Given rao, return Balance object with rao(
int
) and tao(float
), where rao = int(tao*pow(10,9))
- static from_tao(amount, netuid=0)#
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#
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)#
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)#
- Parameters:
fixed (Union[FixedPoint, scalecodec.ScaleType])
frac_bits (int)
total_bits (int)
- Return type:
- bittensor.utils.balance.rao(amount)#
Helper function to create a Balance object from an int (Rao)
- bittensor.utils.balance.tao(amount)#
Helper function to create a Balance object from a float (Tao)
- bittensor.utils.balance.units = ['τ', 'α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π', 'ρ', 'σ',...#