Documentation ¶
Index ¶
- Constants
- Variables
- func NewAddressFromHex(hex string) (addr common.Address, err error)
- type Block
- type ContractLogFilterer
- type Eth
- func (e *Eth) Log(msg string, ctx ...interface{})
- func (e *Eth) NewHandleNonceBackend(handleAddresses []common.Address) *Eth
- func (e *Eth) NewSession(key *ecdsa.PrivateKey) *Session
- func (e *Eth) UpdateSuggestedGasPrice(ctx context.Context) error
- func (e *Eth) WaitForTxReceipt(ctx context.Context, txHash common.Hash) (tr *types.Receipt, err error)
- type Key
- type Session
- type SliceLogFilterer
- type Transaction
- type TransactionStatus
- type Transactions
- type Transferer
Constants ¶
const ( // TransactionFailed is the status code of a transaction if execution failed. TransactionFailed = TransactionStatus(0) // TransactionSuccessful is the status code of a transaction if execution succeeded. TransactionSuccessful = TransactionStatus(1) )
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound is returned by API methods if the requested item does not exist.
Functions ¶
Types ¶
type Block ¶
type Block struct { Difficulty *big.Int ExtraData []byte GasLimit *big.Int GasUsed *big.Int Hash common.Hash Miner common.Address Number *big.Int Timestamp uint64 Transactions Transactions }
Block holds information about Ethereum block.
type ContractLogFilterer ¶
type ContractLogFilterer struct {
// contains filtered or unexported fields
}
ContractLogFilterer extends FilterLogs method of bind.BoundContract struct to allow filter multiple events
func NewContractLogFilterer ¶
func NewContractLogFilterer(address common.Address, abi abi.ABI, filterer bind.ContractFilterer) *ContractLogFilterer
NewContractLogFilterer creates a instance of ContractLogFilterer.
func (*ContractLogFilterer) FilterLogs ¶
func (c *ContractLogFilterer) FilterLogs(opts *bind.FilterOpts, names []string, query ...[]interface{}) (chan types.Log, event.Subscription, error)
FilterLogs filters contract logs for past blocks, returning the necessary channels to construct a strongly typed bound iterator on top of them.
type Eth ¶
Eth simplifies some operations with the Ethereum network
func (*Eth) NewHandleNonceBackend ¶
NewHandleNonceBackend returns new instance of Eth which internally handles nonce of the given addresses. It still calls PendingNonceAt of inner backend, but returns PendingNonceAt as a maximum of pending nonce in block-chain and internally stored nonce. It increments nonce for the given addresses after each successfully sent transaction (transaction may eventually fail in block-cain). Implementation is not thread-safe and should be used within one goroutine because otherwise invocations of PendingNonceAt and SendTransaction should be done atomically to have sequence of nonce without gaps (so that nonce would be equal to number of transactions sent).
func (*Eth) NewSession ¶
func (e *Eth) NewSession(key *ecdsa.PrivateKey) *Session
NewSession creates an instance of Sessionclear
func (*Eth) UpdateSuggestedGasPrice ¶
UpdateSuggestedGasPrice initializes suggested gas price from backend
type Key ¶
type Key struct { // Address is address associated with the PrivateKey (stored for simplicity) Address common.Address // PrivateKey represents a ECDSA private key. Pubkey/address can be derived from it. PrivateKey *ecdsa.PrivateKey }
Key is combination of public address and private key.
func NewKeyFromPrivateKey ¶
NewKeyFromPrivateKey creates Key from hex-string representation of private key.
func (*Key) AddressString ¶
AddressString returns string representation of address.
func (*Key) PrivateKeyString ¶
PrivateKeyString returns hex-string representation of private key.
func (*Key) PublicKeyString ¶
PublicKeyString returns hex-string representation of public key.
type Session ¶
type Session struct { *Eth TransactOpts bind.TransactOpts }
Session provides holds basic pre-configured parameters like backend, authorization, logging
func (*Session) IsEnoughFunds ¶
func (s *Session) IsEnoughFunds(ctx context.Context, gasLimit int64) (enough bool, minBalance *big.Int, err error)
IsEnoughFunds retrieves current account balance and checks if it's enough funds given gas limit. SetGasPrice needs to be called with non-nil parameter before calling this method.
type SliceLogFilterer ¶
SliceLogFilterer implements ethereum.SliceLogFilterer for log event slice.
func (SliceLogFilterer) FilterLogs ¶
func (logs SliceLogFilterer) FilterLogs(ctx context.Context, query ethereum.FilterQuery) (res []types.Log, err error)
FilterLogs implements ethereum.SliceLogFilterer.
func (SliceLogFilterer) SubscribeFilterLogs ¶
func (logs SliceLogFilterer) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
SubscribeFilterLogs implements ethereum.SliceLogFilterer.
type Transaction ¶
type Transaction struct { BlockNumber *big.Int From common.Address GasLimit *big.Int GasPrice *big.Int GasUsed *big.Int Hash common.Hash Input []byte Nonce uint64 To *common.Address // nil means contract creation TransactionIndex uint64 Value *big.Int ContractAddress *common.Address Status *TransactionStatus Logs []*types.Log }
Transaction holds information about Ethereum transaction.
func (*Transaction) String ¶
func (t *Transaction) String() string
type TransactionStatus ¶
type TransactionStatus uint
TransactionStatus is receipt status of transaction.
type Transferer ¶
type Transferer struct {
ContractTransactor bind.ContractTransactor
}
Transferer allows to make ethers transfer between accounts.
func (Transferer) SuggestGasLimit ¶
func (t Transferer) SuggestGasLimit(opts *bind.TransactOpts, to common.Address, input []byte) (gasLimit *big.Int, err error)
SuggestGasLimit returns suggested gas limit to make transfer.
func (Transferer) Transfer ¶
func (t Transferer) Transfer(opts *bind.TransactOpts, to common.Address, input []byte) (*types.Transaction, error)
Transfer transfers ethers to `to` account. `input` is optional and can be set to nil.