utils

package
v0.0.0-...-90f177f Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeToHex

func EncodeToHex(b []byte) string

func EncodeUintToHex

func EncodeUintToHex(i uint64) string

func Ether

func Ether(i uint64) *big.Int

Ether converts a value to the ether unit with 18 decimals

func ParseBigInt

func ParseBigInt(str string) *big.Int

func ParseHexBytes

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

func ParseUint64orHex

func ParseUint64orHex(str string) (uint64, error)

func ToBlockNumArg

func ToBlockNumArg(number *big.Int) string

ToBlockNumArg. Wrap blockNumber arg from big.Int to string

Types

type EtherUnit

type EtherUnit int
const (
	EtherUnitNoEther EtherUnit = iota
	EtherUnitWei
	EtherUnitKWei
	EtherUnitMWei
	EtherUnitGWei
	EtherUnitSzabo
	EtherUnitFinney
	EtherUnitEther
)

type Utils

type Utils struct{}

func NewUtils

func NewUtils() *Utils

func (*Utils) AbiEncodePacked

func (u *Utils) AbiEncodePacked(args ...interface{}) ([]byte, error)

Equal to solidity `abi.encodePacked(args)`

func (*Utils) DecodeParameters

func (u *Utils) DecodeParameters(parameters []string, data []byte) ([]interface{}, error)

func (*Utils) DifferentAddress

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

func (*Utils) EncodeFunctionSignature

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

func (*Utils) EncodeParameters

func (u *Utils) EncodeParameters(parameters []string, data []interface{}) ([]byte, error)

func (*Utils) FromDecimals

func (u *Utils) FromDecimals(wei *big.Int, decimals int64) *big.Float

func (*Utils) FromGWei

func (u *Utils) FromGWei(wei *big.Int) *big.Float

func (*Utils) FromWei

func (u *Utils) FromWei(wei *big.Int) *big.Float

func (*Utils) FromWeiFloat

func (u *Utils) FromWeiFloat(wei *big.Float) *big.Float

func (*Utils) FromWeiWithUnit

func (u *Utils) FromWeiWithUnit(wei *big.Int, unit EtherUnit) *big.Float

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) PackCode

func (u *Utils) PackCode(signature string, args []string, params []interface{}) []byte

func (*Utils) RoundNWei

func (u *Utils) RoundNWei(wei *big.Int, n int) (*big.Int, error)

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) ToGWei

func (u *Utils) ToGWei(val float64) *big.Int

func (*Utils) ToHex

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

func (*Utils) ToWei

func (u *Utils) ToWei(val string) *big.Int

func (*Utils) ToWeiInt

func (u *Utils) ToWeiInt(val int64, denominator int64) *big.Int

Jump to

Keyboard shortcuts

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