Documentation ¶
Overview ¶
Package dececlient provides a client for the Ethereum RPC API.
Index ¶
- type Client
- func (ec *Client) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
- func (ec *Client) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
- func (ec *Client) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
- func (ec *Client) CallContract(ctx context.Context, msg dece.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (ec *Client) Close()
- func (ec *Client) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
- func (ec *Client) CommitTx(ctx context.Context, arg *txtool.GTx) error
- func (ec *Client) EstimateGas(ctx context.Context, msg dece.CallMsg) (uint64, error)
- func (ec *Client) FilterLogs(ctx context.Context, q dece.FilterQuery) ([]types.Log, error)
- func (ec *Client) GenContractTx(ctx context.Context, msg dece.CallMsg) (*txtool.GTxParam, error)
- func (ec *Client) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
- func (ec *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (ec *Client) NetworkID(ctx context.Context) (*big.Int, error)
- func (ec *Client) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
- func (ec *Client) PendingBalanceAt(ctx context.Context, account common.Address) (*big.Int, error)
- func (ec *Client) PendingCallContract(ctx context.Context, msg dece.CallMsg) ([]byte, error)
- func (ec *Client) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
- func (ec *Client) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
- func (ec *Client) PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error)
- func (ec *Client) PendingTransactionCount(ctx context.Context) (uint, error)
- func (ec *Client) StorageAt(ctx context.Context, account common.Address, key common.Hash, ...) ([]byte, error)
- func (ec *Client) SubscribeFilterLogs(ctx context.Context, q dece.FilterQuery, ch chan<- types.Log) (dece.Subscription, error)
- func (ec *Client) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (dece.Subscription, error)
- func (ec *Client) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- func (ec *Client) SyncProgress(ctx context.Context) (*dece.SyncProgress, error)
- func (ec *Client) TransactionCount(ctx context.Context, blockHash common.Hash) (uint, error)
- func (ec *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
- type RPCTransaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client defines typed wrappers for the Ethereum RPC API.
func (*Client) BalanceAt ¶
func (ec *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) BlockByHash ¶
BlockByHash returns the given full block.
Note that loading full blocks requires two requests. Use HeaderByHash if you don't need all transactions.
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 headers.
func (*Client) CallContract ¶
func (ec *Client) CallContract(ctx context.Context, msg dece.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 (ec *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) EstimateGas ¶
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.
func (*Client) FilterLogs ¶
FilterLogs executes a filter query.
func (*Client) GenContractTx ¶
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) NetworkID ¶
NetworkID returns the network ID (also known as the chain ID) for this chain.
func (*Client) NonceAt ¶
func (ec *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) PendingCodeAt ¶
PendingCodeAt returns the contract code of the given account in 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) PendingStorageAt ¶
func (ec *Client) PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error)
PendingStorageAt returns the value of key in the contract storage of the given account in the pending state.
func (*Client) PendingTransactionCount ¶
PendingTransactionCount returns the total number of transactions in the pending state.
func (*Client) StorageAt ¶
func (ec *Client) StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error)
StorageAt returns the value of key in the contract storage of the given account. The block number can be nil, in which case the value is taken from the latest known block.
func (*Client) SubscribeFilterLogs ¶
func (ec *Client) SubscribeFilterLogs(ctx context.Context, q dece.FilterQuery, ch chan<- types.Log) (dece.Subscription, error)
SubscribeFilterLogs subscribes to the results of a streaming filter query.
func (*Client) SubscribeNewHead ¶
func (ec *Client) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (dece.Subscription, error)
SubscribeNewHead subscribes to notifications about the current blockchain head on the given channel.
func (*Client) SuggestGasPrice ¶
SuggestGasPrice retrieves the currently suggested gas price to allow a timely execution of a transaction.
func (*Client) SyncProgress ¶
SyncProgress retrieves the current progress of the sync algorithm. If there's no sync currently running, it returns nil.
func (*Client) TransactionCount ¶
TransactionCount returns the total number of transactions in the given block.
type RPCTransaction ¶
type RPCTransaction struct { BlockHash common.Hash `json:"blockHash"` BlockNumber *hexutil.Big `json:"blockNumber"` From common.Address `json:"from"` Gas hexutil.Uint64 `json:"gas"` GasPrice *hexutil.Big `json:"gasPrice"` Hash common.Hash `json:"hash"` Input hexutil.Bytes `json:"input"` Nonce hexutil.Uint64 `json:"nonce"` To *common.Address `json:"to"` TransactionIndex hexutil.Uint `json:"transactionIndex"` Value *hexutil.Big `json:"value"` Stx *stx.T `json:"stx"` }