client

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPublicKey  = errors.New("invalid public key")
	ErrInvalidPrivateKey = errors.New("invalid private key")
	ErrInvalidEthAmount  = errors.New("invalid Ethereum amount")
	ErrSignTx            = errors.New("fail to sign transaction")
	ErrUnknown           = errors.New("unknown error")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Client *ethclient.Client
	Config chain.Config
}

func MustNewClient

func MustNewClient(c chain.Config) *Client

func NewClient

func NewClient(c chain.Config) (*Client, error)

func (*Client) Balance

func (c *Client) Balance(ctx context.Context, walletAddress string) (*big.Int, error)

Balance get current balance in wei

func (*Client) EIP1559

func (c *Client) EIP1559()

func (*Client) EstimateGas

func (c *Client) EstimateGas(ctx context.Context, fromAddr, toAddr any, data []byte, ethValue *big.Int) (uint64, error)

EstimateGas get gas limit with call data fromAddress must not be empty toAddr could be empty ethValue could be nil or zero, unit is wei

func (*Client) EtherBalance

func (c *Client) EtherBalance(ctx context.Context, walletAddress string) (*decimal.Decimal, error)

EtherBalance get current balance in eth

func (*Client) GasPrice

func (c *Client) GasPrice(ctx context.Context) (*big.Int, error)

GasPrice get current gas price, unit is wei

func (*Client) Transfer

func (c *Client) Transfer(
	ctx context.Context,
	chainID int64,
	PrivateKey string,
	ToAddress string,
	amount string,
	gasLimit uint64,
	gasPrice *big.Int,
) (*types.Transaction, error)

Transfer ether to another account PrivateKey: ToAddress: amount: transfer volume

Jump to

Keyboard shortcuts

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