client

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: MIT Imports: 16 Imported by: 0

README

Transactions

The transaction tracker keeps track of all transactions made. It can help with nonce management a bit, but the intent is that the onus of keeping track of which nonce to use is on the caller. The tracker will provide info to help with those decisions, but not automatically determine nonces.

Documentation

Overview

Package client manages connections and interactions with the EVM chain

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EtherToWei

func EtherToWei(eth *big.Float) *big.Int

EtherToWei converts an ETH amount to wei

func PrivateKeyString

func PrivateKeyString(privateKey *ecdsa.PrivateKey) string

PrivateKeyString easy converter of a private key to its hex format

func PrivateKeyToAddress

func PrivateKeyToAddress(privateKey *ecdsa.PrivateKey) (common.Address, error)

PrivateKeyToAddress is a handy converter for an ecdsa private key to a usable eth address

func WeiToEther

func WeiToEther(wei *big.Int) *big.Float

WeiToEther converts a wei amount to eth

func WeiToGwei

func WeiToGwei(wei *big.Int) *big.Float

WeiToGwei converts Wei amounts to GWei

Types

type Wallet

type Wallet struct {
	EthClient *ethclient.Client
	// contains filtered or unexported fields
}

client wraps the standard Ethereum client

func NewWallet

func NewWallet(privateKey *ecdsa.PrivateKey, wsURL string) (*Wallet, error)

NewWallet produces a new wallet to manage transactions on the specified chain

func (*Wallet) Balance

func (w *Wallet) Balance() (*big.Int, error)

Balance retrieves the current balance of the wallet

func (*Wallet) BalanceAt

func (w *Wallet) BalanceAt(address common.Address) (*big.Int, error)

BalanceAt wraps balance at

func (*Wallet) BlockByNumber added in v0.0.2

func (w *Wallet) BlockByNumber(blockNumber *big.Int) (*types.Block, error)

BlockByNumber wraps ether block by number. Input nil for latest block

func (*Wallet) ConfirmTx added in v0.0.2

func (w *Wallet) ConfirmTx(
	confirmedChan chan struct{},
	errChan chan error,
	transaction *types.Transaction,
)

ConfirmTx attempts to confirm a tx on chain, sending a struct on the confirmed chan when it does

func (*Wallet) ConfirmTxWait added in v0.0.2

func (w *Wallet) ConfirmTxWait(ctx context.Context, transaction *types.Transaction) error

ConfirmTxWait confirms the transaction, waiting until the tx confirms until it returns

func (*Wallet) SendTransaction

func (w *Wallet) SendTransaction(
	timeBeforeResending time.Duration,
	reSendTipMultiplier *big.Float,
	toAddress common.Address,
	additionalTip *big.Int,
	amount *big.Float,
)

SendTransaction sends an eth transaction, and confirms it gets on chain. timeBeforeResending determines how long to wait for the transaction to be confirmed before attempting a re-send reSendTipMultiplier multiplies the gas tip when replacing the old transaction

func (*Wallet) SubscribeNewBlocks

func (w *Wallet) SubscribeNewBlocks(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)

SubscribeNewBlocks wraps SubscribeNewHead

func (*Wallet) TransactionOpts added in v0.0.2

func (w *Wallet) TransactionOpts() (*bind.TransactOpts, error)

TransactionOpts for deploying contracts. Warning: increases nonce

Jump to

Keyboard shortcuts

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