ethereum

package
v0.0.0-...-967d326 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Homestead is an identifier to be used to specify
	// the sender we want to use homestead signature
	Homestead signerType = "Homestead"
	// EIP155 is an identifier to be used to specify
	// the sender we want to use EIP155
	EIP155 signerType = "EIP155"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Listener

type Listener struct {
	Notifications []blockchain.Notification
	// contains filtered or unexported fields
}

Listener is an implementation of blockchain.Listener

func (*Listener) AddNotification

func (l *Listener) AddNotification(notif blockchain.Notification)

AddNotification registers a new notification in the notification list

func (*Listener) GetBlock

func (l *Listener) GetBlock(n uint64) (*types.Block, error)

GetBlock returns the block at given height

func (*Listener) GetBlockNumber

func (l *Listener) GetBlockNumber() (uint64, error)

GetBlockNumber returns the latest value of the blocknumber

This is the value you want to use to fetch the latest known block

func (*Listener) ReadThroughNotify

func (l *Listener) ReadThroughNotify(block *types.Block)

ReadThroughNotify applies the Notifications on all the transaction of a given block

func (*Listener) Start

func (l *Listener) Start(fromBlockNumber uint64) error

Start runs the main routine of the Listener

type Sender

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

Sender can be provided a private key and use it to sign

It is responsible for adding

func NewSender

func NewSender(
	ctx context.Context,
	priv ecdsa.PrivateKey,
	client *ethclient.Client,
	signerT signerType,
	chainID *big.Int,
) *Sender

NewSender returns a Sender object

It does not include any specific logic aside deriving the adress from the private key

func (*Sender) RefreshNonce

func (s *Sender) RefreshNonce() error

RefreshNonce gets the next nonce to use from the client

It returns an error if the remote client could not be reached

func (*Sender) SendTransaction

func (s *Sender) SendTransaction(tx *Transaction)

SendTransaction sends a transaction on the blockchain

func (*Sender) SendTransactionData

func (s *Sender) SendTransactionData(to string, data []byte) error

SendTransactionData publish a simple transaction to ethereum

The function completely hides the responsibility to set the nonce, the gas price, the gasLimit and to sign the transaction to the user

func (*Sender) SetSigner

func (s *Sender) SetSigner(signerT signerType, chainID *big.Int) error

SetSigner fetches the chainID from the client and cache it in the object

It is necessary in order to

func (*Sender) Sign

func (s *Sender) Sign(tx *types.Transaction) error

Sign a transaction in place

func (*Sender) Start

func (s *Sender) Start()

Start the main routine of the sender

It sets the nonce and by the same occasion make sure that the remote node is accessible

func (*Sender) SuggestGasPrice

func (s *Sender) SuggestGasPrice() (*big.Int, error)

SuggestGasPrice returns an estimation of the gas price

Is a simple wrapper around geth's SuggestGasPrice

type Transaction

type Transaction types.Transaction

Transaction is a wrapper for geth transaction

func NewTransaction

func NewTransaction(nonce uint64, to string, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction

NewTransaction returns an ethereum transaction

func (*Transaction) GetData

func (t *Transaction) GetData() []byte

GetData returns the recipient of the transaction

func (*Transaction) GetTo

func (t *Transaction) GetTo() string

GetTo returns the recipient of the transaction

Jump to

Keyboard shortcuts

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