wallet

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: BSD-3-Clause Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SwarmTokenDecimals = 16
	LocalnetChainID    = 12345
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendClient

type BackendClient interface {
	ChainID(ctx context.Context) (*big.Int, error)
	CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
	PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
	SuggestGasPrice(ctx context.Context) (*big.Int, error)
	SuggestGasTipCap(ctx context.Context) (*big.Int, error)
	EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)
	SendTransaction(ctx context.Context, tx *types.Transaction) error
	BalanceAt(ctx context.Context, address common.Address, block *big.Int) (*big.Int, error)
}

type Key

type Key string

func GenerateKey

func GenerateKey() (Key, error)

func (Key) PrivateECDSA

func (k Key) PrivateECDSA() (*ecdsa.PrivateKey, error)

func (Key) PublicAddress

func (k Key) PublicAddress() (common.Address, error)

func (Key) PublicECDSA

func (k Key) PublicECDSA() (*ecdsa.PublicKey, error)

type Token

type Token struct {
	Contract common.Address
	Symbol   string
	Decimals int
}

func NativeCoinForChain

func NativeCoinForChain(cid int64) (Token, error)

func SwarmTokenForChain

func SwarmTokenForChain(cid int64) (Token, error)

type TokenInfoGetterFn

type TokenInfoGetterFn = func(cid int64) (Token, error)

type TokenWallet

type TokenWallet interface {
	Balance(
		ctx context.Context,
		addr common.Address,
		token Token,
	) (*big.Int, error)

	Transfer(
		ctx context.Context,
		toAddr common.Address,
		amount *big.Int,
		token Token,
	) error
}

type TransactionSender

type TransactionSender interface {
	Send(
		ctx context.Context,
		toAddr common.Address,
		amount *big.Int,
		callData []byte,
	) error
}

type Wallet

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

func New

func New(client BackendClient, key Key) *Wallet

func (*Wallet) BalanceERC20

func (w *Wallet) BalanceERC20(
	ctx context.Context,
	addr common.Address,
	token Token,
) (*big.Int, error)

func (*Wallet) BalanceNative

func (w *Wallet) BalanceNative(
	ctx context.Context,
	addr common.Address,
) (*big.Int, error)

func (*Wallet) ChainID

func (w *Wallet) ChainID(ctx context.Context) (int64, error)

func (*Wallet) ERC20

func (w *Wallet) ERC20() TokenWallet

func (*Wallet) Native

func (w *Wallet) Native() TokenWallet

func (*Wallet) PublicAddress

func (w *Wallet) PublicAddress() common.Address

func (*Wallet) TransferERC20

func (w *Wallet) TransferERC20(
	ctx context.Context,
	toAddr common.Address,
	amount *big.Int,
	token Token,
) error

func (*Wallet) TransferNative

func (w *Wallet) TransferNative(
	ctx context.Context,
	toAddr common.Address,
	amount *big.Int,
) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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