Documentation ¶
Index ¶
- type EClient
- func (ec *EClient) BlockByHash(ctx context.Context, hash string) (*xycommon.RpcBlock, error)
- func (ec *EClient) BlockByNumber(ctx context.Context, number *big.Int) (*xycommon.RpcBlock, error)
- func (ec *EClient) BlockNumber(ctx context.Context) (uint64, error)
- func (ec *EClient) ChainID(ctx context.Context) (*big.Int, error)
- func (ec *EClient) Client() *rpc.Client
- func (ec *EClient) Close()
- func (ec *EClient) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]xycommon.RpcLog, error)
- func (ec *EClient) HeaderByNumber(ctx context.Context, number *big.Int) (*xycommon.RpcHeader, error)
- func (ec *EClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
- func (ec *EClient) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header, ct chan<- *xycommon.RpcBlock) (ethereum.Subscription, error)
- func (ec *EClient) TransactionReceipt(ctx context.Context, txHashStr string) (*xycommon.RpcReceipt, error)
- func (ec *EClient) TransactionSender(ctx context.Context, txHashStr, blockHashStr string, txIndex uint) (string, error)
- type RawClient
- func (ec *RawClient) BlockByHash(ctx context.Context, hash common.Hash) (*RpcBlock, error)
- func (ec *RawClient) BlockByNumber(ctx context.Context, number *big.Int) (*RpcBlock, error)
- func (ec *RawClient) BlockNumber(ctx context.Context) (uint64, error)
- func (ec *RawClient) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) (err error)
- func (ec *RawClient) ChainID(ctx context.Context) (*big.Int, error)
- func (ec *RawClient) Client() *rpc.Client
- func (ec *RawClient) Close()
- func (ec *RawClient) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]RpcLog, error)
- func (ec *RawClient) HeaderByNumber(ctx context.Context, number *big.Int) (*RpcHeader, error)
- func (ec *RawClient) IsContract(ctx context.Context, address common.Address) (ok bool, err error)
- func (ec *RawClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
- func (ec *RawClient) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)
- func (ec *RawClient) TransactionByHash(ctx context.Context, hash common.Hash) (tx *RpcTransaction, isPending bool, err error)
- func (ec *RawClient) TransactionReceipt(ctx context.Context, txHash common.Hash) (*RpcReceipt, error)
- func (ec *RawClient) TransactionSender(ctx context.Context, txHash common.Hash, blockHash common.Hash, txIndex uint) (common.Address, error)
- type RpcBlock
- type RpcHeader
- type RpcLog
- type RpcReceipt
- type RpcTransaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EClient ¶
type EClient struct {
// contains filtered or unexported fields
}
EClient defines typed wrappers for the Ethereum RPC API.
func (*EClient) 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 (*EClient) 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 (*EClient) BlockNumber ¶
BlockNumber returns the most recent block number
func (*EClient) FilterLogs ¶
func (ec *EClient) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]xycommon.RpcLog, error)
FilterLogs executes a filter query.
func (*EClient) HeaderByNumber ¶
func (*EClient) SubscribeFilterLogs ¶
func (ec *EClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
SubscribeFilterLogs subscribes to the results of a streaming filter query.
func (*EClient) SubscribeNewHead ¶
func (ec *EClient) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header, ct chan<- *xycommon.RpcBlock) (ethereum.Subscription, error)
SubscribeNewHead subscribes to notifications about the current blockchain head on the given channel.
func (*EClient) TransactionReceipt ¶
func (ec *EClient) TransactionReceipt(ctx context.Context, txHashStr string) (*xycommon.RpcReceipt, error)
TransactionReceipt returns the receipt of a transaction by transaction hash. Note that the receipt is not available for pending transactions.
func (*EClient) TransactionSender ¶
func (ec *EClient) TransactionSender(ctx context.Context, txHashStr, blockHashStr string, txIndex uint) (string, error)
TransactionSender returns the sender address of the given transaction. The transaction must be known to the remote node and included in the blockchain at the given block and index. The sender is the one derived by the protocol at the time of inclusion.
There is a fast-path for transactions retrieved by TransactionByHash and TransactionInBlock. Getting their sender address can be done without an RPC interaction.
type RawClient ¶
type RawClient struct {
// contains filtered or unexported fields
}
RawClient defines typed wrappers for the Ethereum RPC API.
func DialContext ¶
DialContext connects a client to the given URL with context.
func (*RawClient) 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 (*RawClient) 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 (*RawClient) BlockNumber ¶
BlockNumber returns the most recent block number
func (*RawClient) CallContext ¶
func (*RawClient) ChainID ¶
ChainID retrieves the current chain ID for transaction replay protection.
func (*RawClient) FilterLogs ¶
FilterLogs executes a filter query.
func (*RawClient) HeaderByNumber ¶
func (*RawClient) IsContract ¶
func (*RawClient) SubscribeFilterLogs ¶
func (ec *RawClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
SubscribeFilterLogs subscribes to the results of a streaming filter query.
func (*RawClient) SubscribeNewHead ¶
func (ec *RawClient) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)
SubscribeNewHead subscribes to notifications about the current blockchain head on the given channel.
func (*RawClient) TransactionByHash ¶
func (*RawClient) TransactionReceipt ¶
func (ec *RawClient) TransactionReceipt(ctx context.Context, txHash common.Hash) (*RpcReceipt, error)
TransactionReceipt returns the receipt of a transaction by transaction hash. Note that the receipt is not available for pending transactions.
func (*RawClient) TransactionSender ¶
func (ec *RawClient) TransactionSender(ctx context.Context, txHash common.Hash, blockHash common.Hash, txIndex uint) (common.Address, error)
TransactionSender returns the sender address of the given transaction. The transaction must be known to the remote node and included in the blockchain at the given block and index. The sender is the one derived by the protocol at the time of inclusion.
There is a fast-path for transactions retrieved by TransactionByHash and TransactionInBlock. Getting their sender address can be done without an RPC interaction.
type RpcBlock ¶
type RpcBlock struct { ParentHash common.Hash `json:"parentHash" gencodec:"required"` Coinbase common.Address `json:"miner"` Bloom types.Bloom `json:"logsBloom" gencodec:"required"` Number *hexutil.Big `json:"number" gencodec:"required"` GasLimit *hexutil.Big `json:"gasLimit" gencodec:"required"` GasUsed *hexutil.Big `json:"gasUsed" gencodec:"required"` Time hexutil.Uint64 `json:"timestamp"` TxHash common.Hash `json:"transactionsRoot" gencodec:"required"` Hash common.Hash `json:"hash"` Transactions []*RpcTransaction `json:"transactions"` TraceId string `json:"-"` }
type RpcHeader ¶
type RpcHeader struct { ParentHash common.Hash `json:"parentHash" gencodec:"required"` Coinbase common.Address `json:"miner"` Bloom types.Bloom `json:"logsBloom" gencodec:"required"` Number *hexutil.Big `json:"number" gencodec:"required"` GasLimit *hexutil.Big `json:"gasLimit" gencodec:"required"` GasUsed *hexutil.Big `json:"gasUsed" gencodec:"required"` Time hexutil.Uint64 `json:"timestamp"` TxHash common.Hash `json:"transactionsRoot" gencodec:"required"` Hash common.Hash `json:"hash"` }
type RpcLog ¶
type RpcLog struct { // Consensus fields: // address of the contract that generated the event Address common.Address `json:"address" gencodec:"required"` // list of topics provided by the contract. Topics []common.Hash `json:"topics" gencodec:"required"` // supplied by the contract, usually ABI-encoded Data hexutil.Bytes `json:"data" gencodec:"required"` // Derived fields. These fields are filled in by the node // but not secured by consensus. // block in which the transaction was included BlockNumber *hexutil.Big `json:"blockNumber"` // hash of the transaction TxHash common.Hash `json:"transactionHash" gencodec:"required"` // index of the transaction in the block TxIndex *hexutil.Big `json:"transactionIndex"` // hash of the block in which the transaction was included BlockHash common.Hash `json:"blockHash"` // index of the xylog in the block Index *hexutil.Big `json:"logIndex"` // The Removed field is true if this xylog was reverted due to a chain reorganisation. // You must pay attention to this field if you receive logs through a filter query. Removed bool `json:"removed"` }
type RpcReceipt ¶
type RpcReceipt struct { // Consensus fields: These fields are defined by the Yellow Paper Type *hexutil.Big `json:"type,omitempty"` PostState hexutil.Bytes `json:"root"` Status *hexutil.Big `json:"status"` CumulativeGasUsed *hexutil.Big `json:"cumulativeGasUsed" gencodec:"required"` Logs []*RpcLog `json:"logs" gencodec:"required"` // Implementation fields: These fields are added by geth when processing a transaction. TxHash common.Hash `json:"transactionHash" gencodec:"required"` ContractAddress *common.Address `json:"contractAddress"` GasUsed *hexutil.Big `json:"gasUsed" gencodec:"required"` EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"` // required, but tag omitted for backwards compatibility // Inclusion information: These fields provide information about the inclusion of the // transaction corresponding to this receipt. BlockHash common.Hash `json:"blockHash,omitempty"` BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` TransactionIndex *hexutil.Big `json:"transactionIndex"` }
RpcReceipt represents the results of a transaction.
type RpcTransaction ¶
type RpcTransaction struct { BlockHash common.Hash `json:"blockHash"` BlockNumber *hexutil.Big `json:"blockNumber"` TxIndex *hexutil.Big `json:"transactionIndex"` Type *hexutil.Big `json:"type"` Hash common.Hash `json:"hash"` ChainID *hexutil.Big `json:"chainId,omitempty"` From *common.Address `json:"from"` To *common.Address `json:"to"` Input string `json:"input"` Value *hexutil.Big `json:"value"` Gas hexutil.Uint64 `json:"gas"` GasPrice *hexutil.Big `json:"gasPrice"` MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"` MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"` MaxFeePerDataGas *hexutil.Big `json:"maxFeePerDataGas,omitempty"` }