utils

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyString   = &decError{"empty hex string"}
	ErrSyntax        = &decError{"invalid hex string"}
	ErrMissingPrefix = &decError{"hex string without 0x prefix"}
	ErrOddLength     = &decError{"hex string of odd length"}
	ErrEmptyNumber   = &decError{"hex string \"0x\""}
	ErrLeadingZero   = &decError{"hex number with leading zero digits"}
	ErrUint64Range   = &decError{"hex number > 64 bits"}
	ErrUintRange     = &decError{fmt.Sprintf("hex number > %d bits", uintBits)}
	ErrBig256Range   = &decError{"hex number > 256 bits"}
)

Functions

func ConvertHexToBigInt added in v0.1.0

func ConvertHexToBigInt(hexStr string) (*big.Int, error)

func ConvertToEtherDecimal added in v0.0.10

func ConvertToEtherDecimal(amount string, decimal int) (string, error)

func DecodeBig added in v0.0.10

func DecodeBig(input string) (*big.Int, error)

DecodeBig decodes a hex string with 0x prefix as a quantity. Numbers larger than 256 bits are not accepted.

func DivideLargeNumbers added in v0.0.10

func DivideLargeNumbers(numeratorStr, denominatorStr string, precision int) (string, error)

func EtherToWei added in v0.1.0

func EtherToWei(amountStr string) (*big.Int, error)

This function converts ether to wei

func FormatHex added in v0.0.10

func FormatHex(hex string) (string, error)

func FormatHexToEther added in v0.1.0

func FormatHexToEther(hex string, precision ...int) (string, error)

This util converts Hex value to ethers and return it as ether format in 18 decimals

func HexToDecimal

func HexToDecimal(hexStr string) (*big.Int, error)

func HexToString

func HexToString(hexStr string, precision ...int) (string, error)

func HexToText

func HexToText(hexString string) (string, error)

func MultiplyDecimal added in v0.0.10

func MultiplyDecimal(denominatorStr string, precision int) (string, error)

func ParseEther

func ParseEther(big string, precision ...int) (string, error)

This util converts ether value to wei in 18 decimals by default if the precision is not specified

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL