Documentation ¶
Index ¶
Constants ¶
const ( // AtomsPerCent is the number of atomic units in one coin cent. // TODO, relocate the coin related item to chain's params AtomsPerCent = 1e6 // AtomsPerCoin is the number of atomic units in one coin. // TODO, relocate the coin related item to chain's params AtomsPerCoin = 1e8 // MaxAmount is the maximum transaction amount allowed in atoms. // TODO, relocate the coin related item to chain's params MaxAmount = 21e6 * AtomsPerCoin )
Variables ¶
This section is empty.
Functions ¶
func NewAmount ¶
NewAmount creates an Amount from a floating point value representing some value in the currency. NewAmount errors if f is NaN or +-Infinity, but does not check that the amount is within the total amount of coins producible as f may not refer to an amount at a single moment in time.
NewAmount is for specifically for converting qitmeer to Atoms (atomic units). For creating a new Amount with an int64 value which denotes a quantity of Atoms, do a simple type conversion from type int64 to Amount.
Types ¶
type Amount ¶
type Amount int64
Amount represents the base coin monetary unit (colloquially referred to as an `Atom'). A single Amount is equal to 1e-8 of a coin.
func (Amount) ToUnit ¶
func (a Amount) ToUnit(u AmountUnit) float64
ToUnit converts a monetary amount counted in coin base units to a floating point value representing an amount of coins.
type AmountUnit ¶
type AmountUnit int
AmountUnit describes a method of converting an Amount to something other than the base unit of a coin. The value of the AmountUnit is the exponent component of the decadic multiple to convert from an amount in coins to an amount counted in atomic units.
const ( AmountMegaCoin AmountUnit = 6 AmountKiloCoin AmountUnit = 3 AmountCoin AmountUnit = 0 AmountMilliCoin AmountUnit = -3 AmountMicroCoin AmountUnit = -6 AmountAtom AmountUnit = -8 )
These constants define various units used when describing a coin monetary amount.