Documentation ¶
Index ¶
- type BaseBlockchain
- func (b *BaseBlockchain) BuildSendERC20Tx(opts TxOpts, amount *big.Int, to ethereum.Address, ...) (*types.Transaction, error)
- func (b *BaseBlockchain) BuildSendETHTx(opts TxOpts, to ethereum.Address) (*types.Transaction, error)
- func (b *BaseBlockchain) BuildTx(context context.Context, opts TxOpts, contract *Contract, method string, ...) (*types.Transaction, error)
- func (b *BaseBlockchain) Call(timeOut time.Duration, opts CallOpts, contract *Contract, result interface{}, ...) error
- func (b *BaseBlockchain) CurrentBlock() (uint64, error)
- func (b *BaseBlockchain) GetCallOpts(block uint64) CallOpts
- func (b *BaseBlockchain) GetLogs(param ether.FilterQuery) ([]types.Log, error)
- func (b *BaseBlockchain) GetMinedNonce(operator string) (uint64, error)
- func (b *BaseBlockchain) GetNextNonce(operator string) (*big.Int, error)
- func (b *BaseBlockchain) GetTxOpts(op string, nonce *big.Int, gasPrice *big.Int, value *big.Int) (TxOpts, error)
- func (b *BaseBlockchain) MustGetOperator(name string) *Operator
- func (b *BaseBlockchain) MustRegisterOperator(name string, op *Operator)
- func (b *BaseBlockchain) OperatorAddresses() map[string]ethereum.Address
- func (b *BaseBlockchain) PackERC20Data(method string, params ...interface{}) ([]byte, error)
- func (b *BaseBlockchain) RecommendedGasPriceFromNode() (*big.Int, error)
- func (b *BaseBlockchain) SignAndBroadcast(tx *types.Transaction, from string) (*types.Transaction, error)
- func (b *BaseBlockchain) TransactionByHash(ctx context.Context, hash ethereum.Hash) (tx *RPCTransaction, isPending bool, err error)
- func (b *BaseBlockchain) TxStatus(hash ethereum.Hash) (string, uint64, error)
- type Broadcaster
- type CallOpts
- type Contract
- type ContractCaller
- type EthereumSigner
- type NonceCorpus
- type Operator
- type RPCTransaction
- type Signer
- type TxOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseBlockchain ¶
type BaseBlockchain struct {
// contains filtered or unexported fields
}
func NewBaseBlockchain ¶
func NewBaseBlockchain( rpcClient *rpc.Client, client *ethclient.Client, operators map[string]*Operator, broadcaster *Broadcaster, contractcaller *ContractCaller) *BaseBlockchain
func (*BaseBlockchain) BuildSendERC20Tx ¶
func (*BaseBlockchain) BuildSendETHTx ¶
func (b *BaseBlockchain) BuildSendETHTx(opts TxOpts, to ethereum.Address) (*types.Transaction, error)
func (*BaseBlockchain) BuildTx ¶
func (b *BaseBlockchain) BuildTx(context context.Context, opts TxOpts, contract *Contract, method string, params ...interface{}) (*types.Transaction, error)
func (*BaseBlockchain) CurrentBlock ¶
func (b *BaseBlockchain) CurrentBlock() (uint64, error)
func (*BaseBlockchain) GetCallOpts ¶
func (b *BaseBlockchain) GetCallOpts(block uint64) CallOpts
func (*BaseBlockchain) GetLogs ¶
func (b *BaseBlockchain) GetLogs(param ether.FilterQuery) ([]types.Log, error)
func (*BaseBlockchain) GetMinedNonce ¶
func (b *BaseBlockchain) GetMinedNonce(operator string) (uint64, error)
func (*BaseBlockchain) GetNextNonce ¶
func (b *BaseBlockchain) GetNextNonce(operator string) (*big.Int, error)
func (*BaseBlockchain) MustGetOperator ¶
func (b *BaseBlockchain) MustGetOperator(name string) *Operator
MustGetOperator returns the operator if avail, panic if the operator can't be found
func (*BaseBlockchain) MustRegisterOperator ¶
func (b *BaseBlockchain) MustRegisterOperator(name string, op *Operator)
func (*BaseBlockchain) OperatorAddresses ¶
func (b *BaseBlockchain) OperatorAddresses() map[string]ethereum.Address
func (*BaseBlockchain) PackERC20Data ¶
func (b *BaseBlockchain) PackERC20Data(method string, params ...interface{}) ([]byte, error)
func (*BaseBlockchain) RecommendedGasPriceFromNode ¶
func (b *BaseBlockchain) RecommendedGasPriceFromNode() (*big.Int, error)
func (*BaseBlockchain) SignAndBroadcast ¶
func (b *BaseBlockchain) SignAndBroadcast(tx *types.Transaction, from string) (*types.Transaction, error)
func (*BaseBlockchain) TransactionByHash ¶
func (b *BaseBlockchain) TransactionByHash(ctx context.Context, hash ethereum.Hash) (tx *RPCTransaction, isPending bool, err error)
type Broadcaster ¶
type Broadcaster struct {
// contains filtered or unexported fields
}
Broadcaster takes a signed tx and try to broadcast it to all nodes that it manages as fast as possible. It returns a map of failures and a bool indicating that the tx is broadcasted to at least 1 node
func NewBroadcaster ¶
func NewBroadcaster(clients map[string]*ethclient.Client) *Broadcaster
func (Broadcaster) Broadcast ¶
func (b Broadcaster) Broadcast(tx *types.Transaction) (map[string]error, bool)
type ContractCaller ¶
type ContractCaller struct {
// contains filtered or unexported fields
}
func NewContractCaller ¶
func NewContractCaller(clients []*common.EthClient) *ContractCaller
type EthereumSigner ¶
type EthereumSigner struct {
// contains filtered or unexported fields
}
func NewEthereumSigner ¶
func NewEthereumSigner(keyPath string, passphrase string) *EthereumSigner
func (EthereumSigner) GetAddress ¶
func (es EthereumSigner) GetAddress() ethereum.Address
func (EthereumSigner) Sign ¶
func (es EthereumSigner) Sign(tx *types.Transaction) (*types.Transaction, error)
type NonceCorpus ¶
type NonceCorpus interface { GetAddress() ethereum.Address GetNextNonce(ethclient *ethclient.Client) (*big.Int, error) MinedNonce(ethclient *ethclient.Client) (*big.Int, error) }
NonceCorpus is the interface to keep track of transaction count of an ethereum account.
type Operator ¶
type Operator struct { Address ethereum.Address NonceCorpus NonceCorpus Signer Signer }
func NewOperator ¶
func NewOperator(signer Signer, nonce NonceCorpus) *Operator
type RPCTransaction ¶
type RPCTransaction struct {
// contains filtered or unexported fields
}
func (*RPCTransaction) BlockNumber ¶
func (tx *RPCTransaction) BlockNumber() *big.Int
func (*RPCTransaction) UnmarshalJSON ¶
func (tx *RPCTransaction) UnmarshalJSON(msg []byte) error
type Signer ¶
type Signer interface { GetAddress() ethereum.Address Sign(*types.Transaction) (*types.Transaction, error) }
Signer contains method to sign a Ethereum transaction.
type TxOpts ¶
type TxOpts struct { Operator *Operator // Ethereum account to send the transaction from Nonce *big.Int // Nonce to use for the transaction execution (nil = use pending state) Value *big.Int // Funds to transfer along along the transaction (nil = 0 = no funds) GasPrice *big.Int // Gas price to use for the transaction execution (nil = gas price oracle) GasLimit uint64 // Gas limit to set for the transaction execution (0 = estimate) }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.