Documentation ¶
Index ¶
Constants ¶
const ( // NanoPACPerPAC is the number of NanoPAC in one PAC. NanoPACPerPAC = 1e9 // MaxNanoPAC is the maximum transaction amount allowed in NanoPAC. MaxNanoPAC = 42e6 * NanoPACPerPAC )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Amount ¶
type Amount int64
Amount represents the atomic unit in Pactus blockchain. Each unit equals to 1e-9 of a PAC.
func FromString ¶
FromString parses a string representing a value in PAC. It then uses NewAmount to create an Amount based on the parsed floating-point value. If the parsing of the string fails, it returns an error.
func NewAmount ¶
NewAmount creates an Amount from a floating-point value representing an amount in PAC. NewAmount returns an error if f is NaN or +-Infinity, but it does not check whether the amount is within the total amount of PAC producible, as it may not refer to an amount at a single moment in time.
NewAmount is specifically for converting PAC to NanoPAC. For creating a new Amount with an int64 value which denotes a quantity of NanoPAC, do a simple type conversion from type int64 to Amount.
func (Amount) Format ¶
Format formats a monetary amount counted in Pactus base units as a string for a given unit. The conversion will succeed for any unit, however, known units will be formatted with an appended label describing the units with SI notation, and "NanoPAC" for the base unit.
func (Amount) ToNanoPAC ¶
ToNanoPAC is equivalent to calling ToUnit with AmountNanoPAC. It returns the amount of NanoPAC or atomic unit as a 64-bit integer.
type Unit ¶
type Unit int
Unit describes a method of converting an Amount to something other than the base unit of a Pactus. The value of the Unit is the exponent component of the decadic multiple to convert from an amount in Pactus to an amount counted in units.