eth

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccountNil = fmt.Errorf("Authorized calls can't be made when the account is nil")
	// ErrReceiptStatusFailed when receiving a failed transaction
	ErrReceiptStatusFailed = fmt.Errorf("receipt status is failed")
	// ErrReceiptNotRecieved when unable to retrieve a transaction
	ErrReceiptNotReceived = fmt.Errorf("receipt not available")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	ReceiptTimeout time.Duration
	// contains filtered or unexported fields
}

Client is an ethereum client to call Smart Contract methods.

func NewClient

func NewClient(client *ethclient.Client, account *accounts.Account, ks *ethkeystore.KeyStore) *Client

NewClient creates a Client instance. The account is not mandatory (it can be nil). If the account is nil, CallAuth will fail with ErrAccountNil.

func (*Client) Account

func (c *Client) Account() *accounts.Account

Account returns the underlying ethereum account

func (*Client) BalanceAt

func (c *Client) BalanceAt(addr common.Address) (*big.Int, error)

BalanceAt retieves information about the default account

func (*Client) Call

func (c *Client) Call(fn func(*ethclient.Client) error) error

Call performs a read only Smart Contract method call.

func (*Client) CallAuth

func (c *Client) CallAuth(gasLimit uint64,
	fn func(*ethclient.Client, *bind.TransactOpts) (*types.Transaction, error)) (*types.Transaction, error)

CallAuth performs a Smart Contract method call that requires authorization. This call requires a valid account with Ether that can be spend during the call.

func (*Client) CurrentBlock added in v0.0.8

func (c *Client) CurrentBlock() (*big.Int, error)

CurrentBlock returns the current block number in the blockchain

func (*Client) Deploy added in v0.0.8

func (c *Client) Deploy(name string,
	fn func(c *ethclient.Client, auth *bind.TransactOpts) (common.Address, *types.Transaction, interface{}, error)) (ContractData, error)

Deploy a smart contract. `name` is used to log deployment information. fn is a wrapper to the deploy function generated by abigen. In case of error, the returned `ContractData` may have some parameters filled depending on the kind of error that ocurred. successfull.

func (*Client) GetReceipt added in v0.0.8

func (c *Client) GetReceipt(tx *types.Transaction) (*types.Receipt, error)

GetReceipt will check if a transaction is confirmed and return immediately, waiting at most 1 second and returning error if the transaction is still pending.

func (*Client) WaitReceipt

func (c *Client) WaitReceipt(tx *types.Transaction) (*types.Receipt, error)

WaitReceipt will block until a transaction is confirmed. Internally it polls the state every 200 milliseconds.

type ContractData added in v0.0.8

type ContractData struct {
	Address common.Address
	Tx      *types.Transaction
	Receipt *types.Receipt
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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