helpers

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

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

Go to latest
Published: Aug 28, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

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) example gasLimit := uint64(21000) gasPrice := new(big.Int) gasPrice.SetString("2000000000", 10) gasCost := util.CalcGasCost(gasLimit, gasPrice) fmt.Println(gasCost) // 42000000000000

func EstimateGasLimit

func EstimateGasLimit(client *ethclient.Client, toAddress *common.Address, data []byte) uint64

func GenerateMnemonic

func GenerateMnemonic() string

Generate a mnemonic, user-friendly seed

func GetBytesFromFile

func GetBytesFromFile(file string) []byte

func IsContract

func IsContract(client *ethclient.Client, address string) bool

Checks if address is valid, and also checks if it is a smart contract or account.

func IsValidEthAddress

func IsValidEthAddress(address string) bool

func SigRSV

func SigRSV(isig interface{}) ([32]byte, [32]byte, uint8)

SigRSV signatures R S V returned as arrays sig := "0x789a80053e4927d0a898db8e065e948f5cf086e32f9ccaa54c1908e22ac430c62621578113ddbb62d509bf6049b8fb544ab06d36f916685a2eb8e57ffadde02301" r, s, v := util.SigRSV(sig) fmt.Println(hexutil.Encode(r[:])[2:]) // 789a80053e4927d0a898db8e065e948f5cf086e32f9ccaa54c1908e22ac430c6 fmt.Println(hexutil.Encode(s[:])[2:]) // 2621578113ddbb62d509bf6049b8fb544ab06d36f916685a2eb8e57ffadde023 fmt.Println(v) // 28

func SuggestGasPrice

func SuggestGasPrice(client *ethclient.Client) *big.Int

func ToDecimal

func ToDecimal(ivalue interface{}, decimals int) decimal.Decimal

ToDecimal wei to decimals

func ToWei

func ToWei(iamount interface{}, decimals int) *big.Int

ToWei decimals to wei

Types

This section is empty.

Jump to

Keyboard shortcuts

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