evmutils

package module
v1.2.12 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 5 Imported by: 0

README

evm-utils

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

使用方式

具体使用方式,先看根目录的evmutils_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) BlockByNumber added in v1.2.4

func (o *EthClient) BlockByNumber(number uint64) (*types.Block, error)

BlockByNumber

@Description: 读取一个块
@receiver o
@param number 如果number<=0,则读取最新块
@return *types.Block
@return error

func (*EthClient) BlockReceiptsByNumber added in v1.2.12

func (o *EthClient) BlockReceiptsByNumber(number uint64) ([]*types.Receipt, error)

BlockReceiptsByNumber

@Description: 读取一个块所有交易的回执
@receiver o
@param number
@return []*types.Receipt
@return error

func (*EthClient) Chain

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

func (*EthClient) LatestBlockNumber added in v1.2.7

func (o *EthClient) LatestBlockNumber() (uint64, error)

LatestBlockNumber

@Description: 获取最新块
@receiver o
@return uint64
@return 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)

func (*EthClient) TxReceipt added in v1.2.12

func (o *EthClient) TxReceipt(hash string) (*types.Receipt, error)

TxReceipt

@Description: 根据hash获取交易回执
@receiver o
@param hash
@return *types.Receipt
@return error

func (*EthClient) TxReceiptByBlockNumber added in v1.2.12

func (o *EthClient) TxReceiptByBlockNumber(number uint64) ([]model.Transaction, error)

TxReceiptByBlockNumber

@Description: 获取一个块的所有交易
@receiver o
@param number
@return []model.Transaction
@return error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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