Documentation
¶
Index ¶
- func CalcGasCost(gasLimit uint64, gasPrice *big.Int) *big.Int
- func IsValidAddress(iaddress interface{}) bool
- func IsZeroAddress(iaddress interface{}) bool
- func NewAccount(keyFileDir, keyPass string) (accounts.Account, error)
- func PublicKeyBytesToAddress(publicKey []byte) common.Address
- func SigRSV(isig interface{}) ([32]byte, [32]byte, uint8)
- func ToDecimal(ivalue interface{}, decimals int) decimal.Decimal
- func ToWei(iamount interface{}, decimals int) *big.Int
- type Authorizer
- type Blockchain
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcGasCost ¶
CalcGasCost calculate gas cost given gas limit (units) and gas price (wei)
func IsValidAddress ¶
func IsValidAddress(iaddress interface{}) bool
IsValidAddress validate hex address
func IsZeroAddress ¶
func IsZeroAddress(iaddress interface{}) bool
IsZeroAddress validate if it's a 0 address
func NewAccount ¶
NewAccount returns a new ethereum account as generated by `geth account new`
func PublicKeyBytesToAddress ¶
PublicKeyBytesToAddress ...
Types ¶
type Authorizer ¶
type Authorizer struct {
sync.Mutex // bind.TransactOpts is not thread safe
*bind.TransactOpts
}
Authorizer wraps ethereum transactopts
func NewAuthorizer ¶
func NewAuthorizer(opts *bind.TransactOpts) *Authorizer
NewAuthorizer returns a new transaction authorizer
func NewAuthorizerFromKeyFile ¶
func NewAuthorizerFromKeyFile(keyFile, keyPass string) (*Authorizer, error)
NewAuthorizerFromKeyFile returns an Authorizer object from a keyfile
func NewAuthorizerFromPK ¶
func NewAuthorizerFromPK(pk *ecdsa.PrivateKey) *Authorizer
NewAuthorizerFromPK returns an authorizer from a private key
type Blockchain ¶
type Blockchain interface {
// CodeAt returns the code of the given account. This is needed to differentiate
// between contract internal errors and the local chain being out of sync.
CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
// ContractCall executes an Ethereum contract call with the specified data as the
// input.
CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
// PendingCodeAt returns the code of the given account in the pending state.
PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error)
// PendingCallContract executes an Ethereum contract call against the pending state.
PendingCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error)
// PendingNonceAt retrieves the current pending nonce associated with an account.
PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
// SuggestGasPrice retrieves the currently suggested gas price to allow a timely
// execution of a transaction.
SuggestGasPrice(ctx context.Context) (*big.Int, error)
// EstimateGas tries to estimate the gas needed to execute a specific
// transaction based on the current pending state of the backend blockchain.
// There is no guarantee that this is the true gas limit requirement as other
// transactions may be added or removed by miners, but it should provide a basis
// for setting a reasonable default.
EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)
// SendTransaction injects the transaction into the pending pool for execution.
SendTransaction(ctx context.Context, tx *types.Transaction) error
// FilterLogs executes a log filter operation, blocking during execution and
// returning all the results in one batch.
//
// TODO(karalabe): Deprecate when the subscription one can return past data too.
FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)
// SubscribeFilterLogs creates a background log filtering operation, returning
// a subscription immediately, which can be used to stream the found events.
SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
}
Blockchain is a generalized interface for interacting with the ethereum blockchain
Click to show internal directories.
Click to hide internal directories.