eth

package
v0.0.0-...-baa49d7 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAddress

func GenerateAddress() (privKey, pubKey, address string, err error)

GenerateAddress generates a new Ethereum address, public key, and private key

func GenerateAddressFromPrivKey

func GenerateAddressFromPrivKey(privKey string) (pubKey, address string, err error)

GenerateAddressFromPrivKey generates a public key and address from a private key

func GenerateKeyFromSeed

func GenerateKeyFromSeed(seed string) (string, string, string, error)

GenerateKeyFromSeed generates a private key, public key, and address from a seed

func GetAccountInfo

func GetAccountInfo(privKey string) (*ecdsa.PrivateKey, *common.Address, error)

GetAccountInfo returns the private key and Ethereum address for a given private key

func NewEthClient

func NewEthClient(rpc string) (*ethclient.Client, error)

NewEthClient creates a new Ethereum client for HTTP connections

func NewEthWsClient

func NewEthWsClient(ws string) (*ethclient.Client, error)

NewEthWsClient creates a new Ethereum client for WebSocket connections

func WaitForTx

func WaitForTx(client *ethclient.Client, tx common.Hash) error

WaitForTx waits for a transaction to be mined

func WaitForTxReceipt

func WaitForTxReceipt(client *ethclient.Client, tx common.Hash) (*types.Receipt, error)

WaitForTxReceipt waits for a transaction receipt to be available

func WalletAddressFromCompressedPublicKey

func WalletAddressFromCompressedPublicKey(publicKeyStr string) (string, error)

WalletAddressFromCompressedPublicKey converts a compressed public key to an Ethereum address

Types

type Client

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

Client wraps an Ethereum client for convenience

func NewClient

func NewClient(eth *ethclient.Client) *Client

NewClient creates a new Client instance

func (*Client) NetworkID

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

NetworkID retrieves the network ID

func (*Client) PendingNonceAt

func (c *Client) PendingNonceAt(ctx context.Context, address common.Address) (uint64, error)

PendingNonceAt retrieves the nonce of an address

func (*Client) SendTransaction

func (c *Client) SendTransaction(ctx context.Context, tx *types.Transaction) error

SendTransaction sends a transaction to the network

func (*Client) SuggestGasPrice

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

SuggestGasPrice retrieves the suggested gas price

func (*Client) Transfer

func (c *Client) Transfer(senderPrivKey, receiverAddress string, amount, gasPrice *big.Int, gasLimit, nonce uint64) (string, error)

Transfer creates and sends a transaction from one address to another

Jump to

Keyboard shortcuts

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