Documentation
¶
Index ¶
- Variables
- type Client
- func (mc *Client) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
- func (mc *Client) BatchCallContext(ctx context.Context, isPostToAll bool, b []rpc.BatchElem) error
- func (mc *Client) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
- func (mc *Client) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
- func (mc *Client) CallContext(ctx context.Context, isPostToAll bool, result interface{}, method string, ...) error
- func (mc *Client) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (mc *Client) Close()
- func (mc *Client) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
- func (mc *Client) EthClients() []*ethclient.Client
- func (mc *Client) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
- func (mc *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (mc *Client) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
- func (mc *Client) PendingBalanceAt(ctx context.Context, account common.Address) (*big.Int, error)
- func (mc *Client) PendingCallContract(ctx context.Context, msg ethereum.CallMsg) ([]byte, error)
- func (mc *Client) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
- func (mc *Client) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (mc *Client) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)
- func (mc *Client) TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error)
- type KubeConfig
- type Map
- type Option
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidTypeCast = errors.New("invalid type cast") ErrNoEthClient = errors.New("no eth client") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) BalanceAt ¶
func (mc *Client) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
BalanceAt returns the wei balance of the given account. The block number can be nil, in which case the balance is taken from the latest known block.
func (*Client) BatchCallContext ¶
BatchCall sends all given requests as a single batch and waits for the server to return a response for all of them. The wait duration is bounded by the context's deadline.
In contrast to CallContext, BatchCallContext only returns errors that have occurred while sending the request. Any error specific to a request is reported through the Error field of the corresponding BatchElem.
Note that batch calls may not be executed atomically on the server side.
`isPostToAll` is true means waiting until received all responsese of JSON-RPC calls and return error if failed to perform JSON-RPC call to all eth client. Otherwise, just waiting for the first successful response and return error if failed to perform JSON-RPC call to all eth client.
func (*Client) BlockByHash ¶
BlockByHash returns the given full block.
Note that loading full blocks requires two requests. Use HeaderByHash if you don't need all transactions or uncle headers.
func (*Client) BlockByNumber ¶
BlockByNumber returns a block from the current canonical chain. If number is nil, the latest known block is returned.
Note that loading full blocks requires two requests. Use HeaderByNumber if you don't need all transactions or uncle headers.
func (*Client) CallContext ¶
func (mc *Client) CallContext(ctx context.Context, isPostToAll bool, result interface{}, method string, args ...interface{}) error
CallContext performs a JSON-RPC call with the given arguments. If the context is canceled before the call has successfully returned, CallContext returns immediately.
The result must be a pointer so that package json can unmarshal into it. You can also pass nil, in which case the result is ignored.
`isPostToAll` is true means waiting until received all responsese of JSON-RPC calls and return error if failed to perform JSON-RPC call to all eth client. Otherwise, just waiting for the first successful response and return error if failed to perform JSON-RPC call to all eth client.
func (*Client) CallContract ¶
func (mc *Client) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
CallContract executes a message call transaction, which is directly executed in the VM of the node, but never mined into the blockchain.
blockNumber selects the block height at which the call runs. It can be nil, in which case the code is taken from the latest known block. Note that state from very old blocks might not be available.
func (*Client) CodeAt ¶
func (mc *Client) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
CodeAt returns the contract code of the given account. The block number can be nil, in which case the code is taken from the latest known block.
func (*Client) EthClients ¶
func (*Client) HeaderByHash ¶
HeaderByHash returns the block header with the given hash.
func (*Client) HeaderByNumber ¶
HeaderByNumber returns a block header from the current canonical chain. If number is nil, the latest known header is returned.
func (*Client) NonceAt ¶
func (mc *Client) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
NonceAt returns the account nonce of the given account. The block number can be nil, in which case the nonce is taken from the latest known block.
func (*Client) PendingBalanceAt ¶
PendingBalanceAt returns the wei balance of the given account in the pending state.
func (*Client) PendingCallContract ¶
PendingCallContract executes a message call transaction using the EVM. The state seen by the contract call is the pending state.
func (*Client) PendingNonceAt ¶
PendingNonceAt returns the account nonce of the given account in the pending state. This is the nonce that should be used for the next transaction.
func (*Client) SendTransaction ¶
SendTransaction injects a signed transaction into the pending pool for execution.
If the transaction was a contract creation use the TransactionReceipt method to get the contract address after the transaction has been mined.
func (*Client) SubscribeNewHead ¶ added in v1.1.1
func (mc *Client) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)
SubscribeNewHead subscribes to notifications about the current blockchain head on the given channel.
type KubeConfig ¶ added in v1.1.3
type Map ¶ added in v1.1.1
type Map struct {
// contains filtered or unexported fields
}
type Option ¶
Option represents a Client option
func ConsulDiscovery ¶ added in v1.1.1
ConsulDiscovery discovers the dynamic ethclient endpoints through consul server. TODO: should watch the change of endpoints
func K8sEndpointsDiscovery ¶ added in v1.1.3
func K8sEndpointsDiscovery(namespace, service, scheme string, kubeconfig *KubeConfig) Option
K8sEndpointsDiscovery discovers the dynamic ethclient endpoints in k8s cluster. There are two ways to access k8s cluster: 1. `kubeconfig` is nil means will build in-cluster config with service account token assigned to k8s pod. 2. `kubeconfig` is given means access k8s cluster with given apiserver address and KUBE-CONFIG file. TODO: should watch the change of endpoints