transaction

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTransactionReverted = errors.New("transaction reverted")
)

Functions

func IsSynced added in v0.5.0

func IsSynced(ctx context.Context, backend Backend, maxDelay time.Duration) (bool, error)

func WaitSynced added in v0.5.0

func WaitSynced(ctx context.Context, backend Backend, maxDelay time.Duration) error

Types

type Backend

type Backend interface {
	bind.ContractBackend
	TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
	TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error)
	BlockNumber(ctx context.Context) (uint64, error)
	HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
	BalanceAt(ctx context.Context, address common.Address, block *big.Int) (*big.Int, error)
}

Backend is the minimum of blockchain backend functions we need.

type Service

type Service interface {
	// Send creates a transaction based on the request and sends it.
	Send(ctx context.Context, request *TxRequest) (txHash common.Hash, err error)
	// WaitForReceipt waits until either the transaction with the given hash has been mined or the context is cancelled.
	WaitForReceipt(ctx context.Context, txHash common.Hash) (receipt *types.Receipt, err error)
}

Service is the service to send transactions. It takes care of gas price, gas limit and nonce management.

func NewService

func NewService(logger logging.Logger, backend Backend, signer crypto.Signer) (Service, error)

NewService creates a new transaction service.

type TxRequest

type TxRequest struct {
	To       common.Address // recipient of the transaction
	Data     []byte         // transaction data
	GasPrice *big.Int       // gas price or nil if suggested gas price should be used
	GasLimit uint64         // gas limit or 0 if it should be estimated
	Value    *big.Int       // amount of wei to send
}

TxRequest describes a request for a transaction that can be executed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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