Documentation
¶
Index ¶
- Constants
- func BytesToI32(byteArray []byte) (int32, error)
- func BytesToU64(byteArray []byte) (uint64, error)
- func BytesToU256(bytes []byte) (*big.Int, error)
- func DecodeBase64(encoded string) ([]byte, error)
- func DoubleToMassaInt(amount float64) *big.Int
- func EncodeBase64(data []byte) string
- func FormatMassa(amount float64, decimals int) string
- func FromMAS(amount float64) *big.Int
- func FromNanoMAS(nanoMassa uint64) *big.Int
- func I32ToBytes(nb int) (bytes []byte)
- func MassaIntToDouble(amount *big.Int) float64
- func NanoToMas(nanoMasAmount uint64) (string, error)
- func ParseMassa(amount float64) uint64
- func ReverseBytes(bytes []byte) []byte
- func StringArrayToArrayOfByteArray(stringArray []string) [][]byte
- func ToBytes(str string) []byte
- func ToBytesWithPrefixLength(str string) []byte
- func ToMAS(amount *big.Int) float64
- func ToNanoMAS(amount *big.Int) uint64
- func ToString(entry []byte) string
- func ToStringArray(entry []byte) []string
- func U32ToBytes(nb int) (bytes []byte)
- func U64ToBytes(nb uint64) (bytes []byte)
- type NetworkType
Constants ¶
const ( BytesPerUint64 = 8 BytesPerUint32 = 4 )
const ( // DecimalScale is the number of decimal places in Massa (9 for nanoMassa) DecimalScale = 9 // DecimalFactor represents the maximum scale factor DecimalFactor = math.MaxFloat64 // NanoMassaPerMassa is the number of nanoMassa in 1 Massa (10^9) NanoMassaPerMassa = 1_000_000_000 )
Constants for Massa unit conversions
const MasDecimals = 9
Variables ¶
This section is empty.
Functions ¶
func BytesToI32 ¶
func BytesToU64 ¶
func BytesToU256 ¶
BytesToU256 decodes the given bytes, representing a 256-bit unsigned integer in big-endian format, into a big.Int. It constructs a new big.Int with the bytes interpreted in little-endian order. The function returns the resulting big.Int representing the 256-bit integer.
func DecodeBase64 ¶
Helper method to decode base64 to bytes
func DoubleToMassaInt ¶
DoubleToMassaInt converts a float64 Massa amount to nanoMassa as *big.Int This multiplies the amount by 10^9 to convert from Massa to nanoMassa
func FormatMassa ¶
FormatMassa formats a Massa amount (float64) as a string with specified decimal places
func FromMAS ¶
FromMAS converts Massa (as float64) to nanoMassa (as *big.Int) Example: FromMAS(1.5) returns 1500000000 nanoMassa
func FromNanoMAS ¶
FromNanoMAS converts nanoMassa (as uint64) to *big.Int This is useful when working with uint64 amounts
func MassaIntToDouble ¶
MassaIntToDouble converts nanoMassa (*big.Int) to Massa as float64 This is an alias for ToMAS for consistency with naming conventions
func ParseMassa ¶
ParseMassa parses a float64 amount and returns nanoMassa as uint64
func ReverseBytes ¶
ReverseBytes creates and returns a new byte slice with reversed order.
func StringArrayToArrayOfByteArray ¶
this function encodes a string array to an array of byte arrays.
func ToBytesWithPrefixLength ¶
func ToMAS ¶
ToMAS converts nanoMassa (as *big.Int) to Massa (as float64) Example: ToMAS(1500000000) returns 1.5 Massa
func ToNanoMAS ¶
ToNanoMAS converts *big.Int to nanoMassa (as uint64) Returns 0 if amount is nil or exceeds uint64 range
func ToStringArray ¶
Types ¶
type NetworkType ¶
type NetworkType int64
const ( MAINNET NetworkType = 77658377 BUILDNET NetworkType = 77658366 SECURENET NetworkType = 77658383 LABNET NetworkType = 77658376 SANDBOX NetworkType = 77 )
func (NetworkType) Serialize ¶
func (nt NetworkType) Serialize() []byte
Serialize serializes the NetworkType into an 8-byte big-endian byte slice.