eth

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: MIT Imports: 19 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 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 LogTopicHash

func LogTopicHash(fnsig string) common.Hash

LogTopicHash generates the log topic hash given the event function declaration signature

func PublicKeyBytesToAddress

func PublicKeyBytesToAddress(publicKey []byte) common.Address

PublicKeyBytesToAddress returns the public address derived from a public key

func SigRSV

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

SigRSV signatures R S V returned as arrays

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

type Address

type Address [20]byte

func NewAddress

func NewAddress(b []byte) *Address

func (*Address) String

func (addr *Address) String() string

type Handle

type Handle struct {
	// contains filtered or unexported fields
}

func NewServiceHandle

func NewServiceHandle(dsn string) (*Handle, error)

NewServiceHandle dsn demo http://127.0.0.1:8545 wss://mainnet.infura.io/ws/v3/xxxxxxxx https://mainnet.infura.io/v3/xxxxxxxx

func (*Handle) CreateSign

func (h *Handle) CreateSign(priKey []byte, data []byte) (signature string, err error)

CreateSign 签名

func (*Handle) CreateTxData

func (h *Handle) CreateTxData(priKey []byte, toAddr string, wei *big.Int) (rawTX string, err error)

CreateTxData 生成原始交易 - 简单

func (*Handle) CreateTxDataAdvanced

func (h *Handle) CreateTxDataAdvanced(priKey []byte, toAddr string, wei *big.Int, gasLimit uint64, gasPrice *big.Int, chainID *big.Int, data []byte) (rawTX string, err error)

CreateTxDataAdvanced 生成原始交易 - 高级

func (*Handle) GetBalance

func (h *Handle) GetBalance(address string) (*big.Int, error)

GetBalance 获取额度

func (*Handle) GetBlock

func (h *Handle) GetBlock(number *big.Int) (*types.Block, error)

GetBlock 查询区块 - number = nil 查询最新区块

func (*Handle) GetBlockHeader

func (h *Handle) GetBlockHeader(number *big.Int) (*types.Header, error)

GetBlockHeader 查询区块头 - number = nil 查询最新区块的头信息

func (*Handle) GetChainID

func (h *Handle) GetChainID() *big.Int

GetChainID get chainId

func (*Handle) GetClient

func (h *Handle) GetClient() *ethclient.Client

GetClient 获取连接

func (*Handle) IsContract

func (h *Handle) IsContract(address string) (bool, error)

IsContract 检测是否为合约地址

func (*Handle) IsValidAddress

func (h *Handle) IsValidAddress(address string) bool

IsValidAddress 校验地址

func (*Handle) SendRawTX

func (h *Handle) SendRawTX(rawTx string) (txHash string, err error)

SendRawTX 发送原始交易

func (*Handle) SetChainID

func (h *Handle) SetChainID(id int64)

SetChainID set chainId

func (*Handle) TransferUsePriKey

func (h *Handle) TransferUsePriKey(priKey []byte, toAddr string, wei *big.Int) (txHash string, err error)

TransferUsePriKey 交易 - 使用指定私钥

type PriKey

type PriKey struct {
	// contains filtered or unexported fields
}

func NewPriKey

func NewPriKey(b []byte) (*PriKey, error)

func NewPriKeyRandom

func NewPriKeyRandom() *PriKey

func (*PriKey) Address

func (pri *PriKey) Address() *Address

func (*PriKey) Base64

func (pri *PriKey) Base64() string

func (*PriKey) Bytes

func (pri *PriKey) Bytes() []byte

func (*PriKey) Hex

func (pri *PriKey) Hex() string

Jump to

Keyboard shortcuts

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