model

package
v1.2.13 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Address    string `json:"address"`
	PrivateKey string `json:"privateKey"`
	PublicKey  string `json:"publicKey"`
	Mnemonic   string `json:"mnemonic"`
}

func NewAccount

func NewAccount() *Account

func (*Account) AccountByMnemonic

func (a *Account) AccountByMnemonic() (account *Account, err error)

func (*Account) AccountGenKeystore added in v1.2.13

func (a *Account) AccountGenKeystore(privateKey, pwd, path string) (address string, err error)

AccountGenKeystore

@Description: 生成keystore文件
@receiver a
@param privateKey
@param pwd
@return address
@return err

func (*Account) AccountInfoByMnemonic

func (a *Account) AccountInfoByMnemonic(mnemonic string) (account *Account, err error)

AccountInfoByMnemonic

@Description: get mnemonic account info
@receiver d
@param mnemonic
@return address
@return privateKey
@return publicKey
@return err

func (*Account) AccountWithPrivateKey

func (a *Account) AccountWithPrivateKey(privateKey string) (account *Account, err error)

type Chain

type Chain struct {
	RemoteRpcClient *ethclient.Client
	Timeout         int64

	ChainId *big.Int
	// contains filtered or unexported fields
}

func GetChain

func GetChain(rpcUrl string, timeout int64) (*Chain, error)

GetChain

@Description: get connect from cache
@param rpcUrl
@param timeout
@return *EthChain
@return error

func (*Chain) BuildTxSign

func (c *Chain) BuildTxSign(privateKey *ecdsa.PrivateKey, txNoSign *eTypes.Transaction) (*types.BuildTxResult, error)

func (*Chain) BuildTxUnSign

func (c *Chain) BuildTxUnSign(address string, transaction *types.Transaction) (*eTypes.Transaction, error)

BuildTxUnSign

@Description: the transaction no sign
@receiver c
@param privateKey
@param transaction
@return *eTypes.Transaction
@return error

func (*Chain) Close

func (c *Chain) Close()

func (*Chain) EstimateGasLimit

func (c *Chain) EstimateGasLimit(msg *types.CallMsg) (gas string, err error)

func (*Chain) Nonce

func (c *Chain) Nonce(spenderAddressHex string) (uint64, error)

func (*Chain) SendTx

func (c *Chain) SendTx(signedTx *eTypes.Transaction) error

type Token

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

func NewToken

func NewToken(chain *Chain) *Token

func (*Token) BalanceOf

func (t *Token) BalanceOf(address string) (balance string, err error)

func (*Token) EstimateGasLimit

func (t *Token) EstimateGasLimit(fromAddress, receiverAddress, gasPrice, amount string, data []byte) (string, error)

func (*Token) Transfer

func (t *Token) Transfer(privateKey, nonce, gasPrice, gasLimit, maxPriorityFeePerGas, value, to, data string) (hash string, err error)

type Transaction added in v1.2.2

type Transaction struct {
	Hash              string
	Protected         bool
	Nonce             uint64
	Data              []byte
	Size              uint64
	Value             decimal.Decimal
	GasPrice          decimal.Decimal
	Type              string
	ChainId           decimal.Decimal
	Gas               uint64
	Cost              decimal.Decimal
	GasFeeCap         decimal.Decimal
	GasTipCap         decimal.Decimal
	To                string
	From              string
	Time              uint64
	GasUsed           uint64
	CumulativeGasUsed uint64
	ReceiptStatus     uint64
	EffectiveGasPrice decimal.Decimal
	BlobGasUsed       uint64
	BlobGasPrice      decimal.Decimal
	TransactionIndex  uint
	ContractAddress   string
	// contains filtered or unexported fields
}

func NewTransaction added in v1.2.2

func NewTransaction(chain *Chain) *Transaction

func (*Transaction) BlockByNumber added in v1.2.4

func (t *Transaction) BlockByNumber(number uint64) (*types.Block, error)

BlockByNumber

@Description: 根据编号获取块
@receiver t
@param number 如果number<=0,则读取最新块
@return *types.Block
@return error

func (*Transaction) LatestBlockNumber added in v1.2.7

func (t *Transaction) LatestBlockNumber() (uint64, error)

LatestBlockNumber

@Description: 获取最新块高度
@receiver t
@return uint64
@return error

func (*Transaction) TxByBlockNumber added in v1.2.13

func (t *Transaction) TxByBlockNumber(number uint64) ([]Transaction, error)

TxByBlockNumber

@Description: 获取一个块的交易
@receiver t
@param number
@return []Transaction
@return error

func (*Transaction) TxByHash added in v1.2.13

func (t *Transaction) TxByHash(hash string) (*Transaction, error)

TxByHash

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

func (*Transaction) TxIsPending added in v1.2.13

func (t *Transaction) TxIsPending(hash string) (bool, error)

TxIsPending

@Description: is pendding
@receiver t
@param hash
@return bool
@return error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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