utils

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnitWeiValue        = int64(1)  // wei
	UnitKWeiValue       = int64(3)  // Kwei (babbage)
	UnitMWeiValue       = int64(6)  // Mwei (lovelace)
	UnitGWeiValue       = int64(9)  // Gwei (shannon)
	UnitMicroEtherValue = int64(12) // microether (szabo)
	UnitMilliEtherValue = int64(15) // milliether (finney)
	UnitEtherValue      = int64(18) // ether
)

Reference: https://ethdocs.org/en/latest/ether.html

View Source
const (
	UnitWei        = "wei"
	UnitKWei       = "kwei"
	UnitMWei       = "mwei"
	UnitGWei       = "gwei"
	UnitMicroEther = "szabo"
	UnitMilliEther = "finney"
	UnitEther      = "ether"
)

Variables

Functions

func EncodeToHex

func EncodeToHex(b []byte) string

func EncodeUintToHex

func EncodeUintToHex(i uint64) string

func ParseBigInt

func ParseBigInt(str string) *big.Int

func ParseHexBytes

func ParseHexBytes(str string) ([]byte, error)

func ParseUint64orHex

func ParseUint64orHex(str string) (uint64, error)

Types

type Utils

type Utils struct{}

func NewUtils

func NewUtils() *Utils

func (*Utils) DifferentAddress

func (u *Utils) DifferentAddress(a, b common.Address) bool

func (*Utils) EncodeFunctionSignature

func (u *Utils) EncodeFunctionSignature(funcName string) []byte

func (*Utils) Equal

func (u *Utils) Equal(x, y *big.Int) bool

Equal returns if x equal y

func (*Utils) Greater

func (u *Utils) Greater(x, y *big.Int) bool

Greater returns if x greater than y

func (*Utils) HexToUint64

func (u *Utils) HexToUint64(str string) (uint64, error)

func (*Utils) LeftPadBytes

func (u *Utils) LeftPadBytes(slice []byte, l int) []byte

func (*Utils) Less

func (u *Utils) Less(x, y *big.Int) bool

Less returns if x less than y

func (*Utils) SameAddress

func (u *Utils) SameAddress(a, b common.Address) bool

func (*Utils) ToDecimals

func (u *Utils) ToDecimals(val uint64, decimals int64) *big.Int

func (*Utils) ToHex

func (u *Utils) ToHex(n *big.Int) string

func (*Utils) ToWei

func (u *Utils) ToWei(value uint64, ethUnit string) *big.Int

ToWei converts a value to the wei Exp:

ToWei(200, "gwei")
ToWei(200, UnitGWei)

Jump to

Keyboard shortcuts

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