util

package
v0.0.0-...-1333d63 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WEI    EthUnit = 1
	KWEI           = 3
	WWEI           = 4
	MWEI           = 6
	LWEI           = 8
	GWEI           = 9
	SZABO          = 12
	FINNEY         = 15
	ETHER          = 18
	KETHER         = 21
	METHER         = 24
	GETHER         = 27
)

Variables

This section is empty.

Functions

func CalcGasCost

func CalcGasCost(gasLimit uint64, gasPrice *big.Int) *big.Int

CalcGasCost calculate gas cost given gas limit (units) and gas price (wei)

func IsValidAddress

func IsValidAddress(iaddress interface{}) bool

IsValidAddress validate hex address

func IsZeroAddress

func IsZeroAddress(iaddress interface{}) bool

IsZeroAddress validate if it's a 0 address

func ToWei

func ToWei(iamount interface{}, unit EthUnit) *big.Int

ToWei decimals to wei

func WeiToDecimal

func WeiToDecimal(ivalue *big.Int, unit EthUnit) decimal.Decimal

ToDecimal wei to decimals

Types

type EthClient

type EthClient struct {
	*ethclient.Client
}

func NewEthClient

func NewEthClient(host string) *EthClient

func (*EthClient) CreateNewWallet

func (*EthClient) CreateNewWallet() (priv, pub []byte, addr string, e error)

func (*EthClient) GetBalance

func (client *EthClient) GetBalance(address common.Address) (decimal.Decimal, error)

func (*EthClient) GetTokenBalance

func (client *EthClient) GetTokenBalance(contractAddr common.Address, address common.Address, ethUnit EthUnit) (amount decimal.Decimal, err error)

func (*EthClient) Transfer

func (client *EthClient) Transfer(fromPri []byte, fromAddr, toAddr string, gasSpeedUp float64, amount decimal.Decimal) (txid string, maxGas decimal.Decimal, err error)

func (*EthClient) TransferToken

func (client *EthClient) TransferToken(contractAddr string, fromPri []byte, fromAddr, toAddr string, tokenUnit string, gasSpeedUp float64, amount decimal.Decimal) (string, decimal.Decimal, error)

type EthUnit

type EthUnit int

func EthUnitFromString

func EthUnitFromString(unit string) EthUnit

Jump to

Keyboard shortcuts

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