ethutil

package module
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 4 Imported by: 0

README

eth-util

ethereum生态的常用工具,如钱包生成、账户余额查询、转账等等

使用方式

具体使用方式,先看根目录的ethutil_test.go吧,后面有空了再写

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EthClient

type EthClient struct {
	RpcUrl string
	// contains filtered or unexported fields
}

func NewEthClient

func NewEthClient(rpcUrl string, timeout int64) *EthClient

NewEthClient

@Description: if rpcUrl and timeout is empty,you can‘t connect the node,but you can use the function about wallet
@param rpcUrl
@param timeout
@return *EthClient

func NewSimpleEthClient

func NewSimpleEthClient() *EthClient

NewSimpleEthClient

@Description: not support connect to the node
@return *EthClient

func (*EthClient) AccountByMnemonic

func (o *EthClient) AccountByMnemonic() (account *model.Account, err error)

func (*EthClient) AccountInfoByMnemonic

func (o *EthClient) AccountInfoByMnemonic(mnemonic string) (account *model.Account, err error)

AccountInfoByMnemonic

@Description:
@receiver o
@param mnemonic
@return account
@return err

func (*EthClient) AccountWithPrivateKey

func (o *EthClient) AccountWithPrivateKey(privateKey string) (account *model.Account, err error)

func (*EthClient) Chain

func (o *EthClient) Chain() (*model.Chain, error)

func (*EthClient) MetamaskSignLogin

func (o *EthClient) MetamaskSignLogin(message, privateKey string) (string, error)

MetamaskSignLogin

@Description: metamask sign login
@receiver o
@param message
@param privateKey
@return string
@return error

func (*EthClient) Nonce

func (o *EthClient) Nonce(address string) (nonce uint64, err error)

func (*EthClient) SignEip721

func (o *EthClient) SignEip721(privateKey string, typedData *apitypes.TypedData) (string, error)

SignEip721

@Description: eip721 sign
@receiver o
@param privateKey
@param typedData
@return string
@return error

func (*EthClient) TokenBalanceOf

func (o *EthClient) TokenBalanceOf(address string) (balance string, err error)

func (*EthClient) TokenEstimateGasLimit

func (o *EthClient) TokenEstimateGasLimit(fromAddress, receiverAddress, gasPrice, amount string, data []byte) (balance string, err error)

TokenEstimateGasLimit

@Description: 估算gas ,如果是合约地址,data肯定不得为空
@receiver o
@param fromAddress
@param receiverAddress
@param gasPrice
@param amount
@param data
@return balance
@return err

func (*EthClient) TokenTransfer

func (o *EthClient) TokenTransfer(privateKey, nonce, gasPrice, gasLimit, maxPriorityFeePerGas, value, to, data string) (hash string, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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