utils

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 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 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 FormatEther

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

func FormatHex added in v0.0.10

func FormatHex(hex string) (string, error)

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)

Types

This section is empty.

Jump to

Keyboard shortcuts

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