eth

package
v0.0.0-...-f44809f Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: LGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PRIORITY_FEE_INCREASE_BOUNDARY = 200
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Contract

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

func NewContract

func NewContract(abiString string, contractAddr ...string) (*Contract, error)

func (*Contract) Address

func (c *Contract) Address() common.Address

func (*Contract) AllMethods

func (c *Contract) AllMethods() []string

func (*Contract) Call

func (c *Contract) Call(methodName string, args ...interface{}) (interface{}, error)

func (*Contract) CallAtWithMultiReturns

func (c *Contract) CallAtWithMultiReturns(blockNumber *big.Int, methodName string, args ...interface{}) ([]interface{}, error)

func (*Contract) CallWithFromAndValue

func (c *Contract) CallWithFromAndValue(
	methodName string,
	from common.Address,
	value *big.Int,
	args ...interface{},
) ([]interface{}, error)

func (*Contract) CallWithMultiReturns

func (c *Contract) CallWithMultiReturns(methodName string, args ...interface{}) ([]interface{}, error)

func (*Contract) EncodeABI

func (c *Contract) EncodeABI(methodName string, args ...interface{}) ([]byte, error)

func (*Contract) Methods

func (c *Contract) Methods(methodName string) abi.Method

type EstimateFee

type EstimateFee struct {
	BaseFee              *big.Int
	MaxFeePerGas         *big.Int
	MaxPriorityFeePerGas *big.Int
}

type Eth

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

Eth is the eth namespace

func NewEth

func NewEth(c *rpc.Client) *Eth

Create a eth instance

func (*Eth) Accounts

func (e *Eth) Accounts() ([]common.Address, error)

Get accounts from rpc providers

func (*Eth) Address

func (e *Eth) Address() common.Address

Get current default account address

func (*Eth) Call

func (e *Eth) Call(msg *types.CallMsg, block *big.Int) (string, error)

Do Call functions

func (*Eth) ChainID

func (e *Eth) ChainID() (*big.Int, error)

Get currnet network chainId from provider

func (*Eth) DecodeParameters

func (e *Eth) DecodeParameters(parameters []string, data []byte) ([]interface{}, error)

func (*Eth) EcSign

func (e *Eth) EcSign(hashData []byte) ([]byte, error)

EcSign signs raw hash message

func (*Eth) EncodeParameters

func (e *Eth) EncodeParameters(parameters []string, data []interface{}) ([]byte, error)

func (*Eth) EstimateFee

func (e *Eth) EstimateFee() (*EstimateFee, error)

func (*Eth) EstimateGas

func (e *Eth) EstimateGas(msg *types.CallMsg) (uint64, error)

Estimate gas for excuting transaction

func (*Eth) EstimateGasContract

func (e *Eth) EstimateGasContract(bin []byte) (uint64, error)

Estimate gas for deploying contract

func (*Eth) EstimatePriorityFee

func (e *Eth) EstimatePriorityFee(historicalBlocks int, blockNumber *big.Int, feeHistoryPercentile []float64) (*big.Int, error)

Estimate priority gas fee

func (*Eth) FeeHistory

func (e *Eth) FeeHistory(historicalBlocks int, blockNumber *big.Int, feeHistoryPercentile []float64) (*types.FeeHistory, error)

Get fee history for EIP1559 blocks

func (*Eth) GasPrice

func (e *Eth) GasPrice() (uint64, error)

Get gas price for Non-EIP1559 tx

func (*Eth) GetBalance

func (e *Eth) GetBalance(addr common.Address, blockNumber *big.Int) (*big.Int, error)

Get ether balance of account

func (*Eth) GetBlocByNumber

func (e *Eth) GetBlocByNumber(number *big.Int, full bool) (*eTypes.Block, error)

Get block header by block number

func (*Eth) GetBlockByHash

func (e *Eth) GetBlockByHash(hash common.Hash, full bool) (*eTypes.Block, error)

Get block by block hash

func (*Eth) GetBlockHeaderByNumber

func (e *Eth) GetBlockHeaderByNumber(number *big.Int, full bool) (*eTypes.Header, error)

Get block header by block number

func (*Eth) GetBlockNumber

func (e *Eth) GetBlockNumber() (uint64, error)

Get current block height

func (*Eth) GetChainId

func (e *Eth) GetChainId() *big.Int

func (*Eth) GetLogs

func (e *Eth) GetLogs(fliter *types.Fliter) ([]*types.Event, error)

Get past event logs with fliter

func (*Eth) GetNonce

func (e *Eth) GetNonce(addr common.Address, blockNumber *big.Int) (uint64, error)

Get nonce of account

func (*Eth) GetPrivateKey

func (e *Eth) GetPrivateKey() *ecdsa.PrivateKey

func (*Eth) GetTransactionByHash

func (e *Eth) GetTransactionByHash(hash common.Hash) (*eTypes.Transaction, error)

Get transaction by transaction hash

func (*Eth) GetTransactionReceipt

func (e *Eth) GetTransactionReceipt(hash common.Hash) (*eTypes.Receipt, error)

Get transaction receipt by transaction hash

func (*Eth) NewContract

func (e *Eth) NewContract(abiString string, contractAddr ...string) (*Contract, error)

func (*Eth) NewEIP1559Tx

func (e *Eth) NewEIP1559Tx(
	to common.Address,
	amount *big.Int,
	gasLimit uint64,
	gasTipCap *big.Int,
	gasFeeCap *big.Int,
	data []byte,
	nonce uint64,
) (*eTypes.Transaction, error)

func (*Eth) SendRawEIP1559Transaction

func (e *Eth) SendRawEIP1559Transaction(
	to common.Address,
	amount *big.Int,
	nonce uint64,
	gasLimit uint64,
	gasTipCap *big.Int,
	gasFeeCap *big.Int,
	data []byte,
) (common.Hash, error)

func (*Eth) SendRawTransaction

func (e *Eth) SendRawTransaction(
	to common.Address,
	amount *big.Int,
	nonce uint64,
	gasLimit uint64,
	gasPrice *big.Int,
	data []byte,
) (common.Hash, error)

func (*Eth) SendTransaction

func (e *Eth) SendTransaction(txn *eTypes.Transaction) (common.Hash, error)

Send transaction

func (*Eth) SetAccount

func (e *Eth) SetAccount(privateKey string) error

Setup default ethereum account with privateKey (hex format)

func (*Eth) SetChainId

func (e *Eth) SetChainId(chainId int64)

Setup current network chainId

func (*Eth) SetTxPollTimeout

func (e *Eth) SetTxPollTimeout(timeout int)

Setup timeout for polling confirmation from txs (unit second)

func (*Eth) SignText

func (e *Eth) SignText(data []byte) ([]byte, error)

SignText signs raw text message keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).

func (*Eth) SignTypedData

func (e *Eth) SignTypedData(data apitypes.TypedData) ([]byte, error)

SignTypedData signs EIP-712 conformant typed data hash = keccak256("\x19${byteVersion}${domainSeparator}${hashStruct(message)}") It returns - the signature, - and/or any error

func (*Eth) SuggestGasTipCap

func (e *Eth) SuggestGasTipCap() (*big.Int, error)

func (*Eth) SyncSendEIP1559RawTransaction

func (e *Eth) SyncSendEIP1559RawTransaction(
	to common.Address,
	amount *big.Int,
	nonce uint64,
	gasLimit uint64,
	gasTipCap *big.Int,
	gasFeeCap *big.Int,
	data []byte,
) (*eTypes.Receipt, error)

func (*Eth) SyncSendRawTransaction

func (e *Eth) SyncSendRawTransaction(
	to common.Address,
	amount *big.Int,
	nonce uint64,
	gasLimit uint64,
	gasPrice *big.Int,
	data []byte,
) (*eTypes.Receipt, error)

Jump to

Keyboard shortcuts

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