eth

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 16 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)

func FormatAmount

func FormatAmount(amount *big.Int, decimals int) float64

格式化数量,根据少数位数

func IsContract

func IsContract(addr string) bool

若在该地址存储了字节码,该地址是智能合约 当地址上没有字节码时,我们知道它不是一个智能合约,它是一个标准的以太坊账户。

func IsValidAddress

func IsValidAddress(addr interface{}) bool

IsValidAddress validate hex address

func IsValidTxHash

func IsValidTxHash(txHash string) bool

func IsZeroAddress

func IsZeroAddress(addr interface{}) bool

IsZeroAddress validate if it's a 0 address

func NewClient

func NewClient() (*ethclient.Client, error)

func NewWssClient

func NewWssClient() (*ethclient.Client, error)

func SigRSV

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

SigRSV signatures R S V returned as arrays

func Sign

func Sign(privateKeyHex string, msg string) string

使用私钥对消息签名

func SignWithPrefix

func SignWithPrefix(privateKeyHex string, msg string) string

会对消息增加一个特定消息前缀,用于兼容metamask签名

func ToDecimal

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

ToDecimal wei to decimals

func ToWei

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

ToWei decimals to wei

func Verify

func Verify(fromAddr, signHex, msg string) bool

func VerifyWithPrefix

func VerifyWithPrefix(fromAddr, signHex, msg string) bool

Types

type LogTransfer

type LogTransfer struct {
	From  common.Address
	To    common.Address
	Value *big.Int
}

Jump to

Keyboard shortcuts

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