ethclient

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

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
}

func Dial

func Dial(concurrentCount int, rawurls []string) (*Client, error)

Dial connect all rawurls if all rpc error, an error will return

func DialContext

func DialContext(ctx context.Context, concurrentCount int, rawurls []string) (*Client, error)

DialContext connect all rawurls if all rpc error, an error will return

func DialOptions added in v0.0.2

func DialOptions(ctx context.Context, concurrentCount int, rawurls []string, options ...rpc.ClientOption) (*Client, error)

func (*Client) BalanceAt

func (ec *Client) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (balance *big.Int, err 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

func (ec *Client) BlockByHash(ctx context.Context, hash common.Hash) (block *types.Block, err error)

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

func (ec *Client) BlockByNumber(ctx context.Context, number *big.Int) (block *types.Block, err error)

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) BlockNumber

func (ec *Client) BlockNumber(ctx context.Context) (blockNumber uint64, err error)

BlockNumber returns the most recent block number the block number may **not increase**, because of multi rpc

func (*Client) CallContract

func (ec *Client) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) (data []byte, err 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) CallContractAtHash

func (ec *Client) CallContractAtHash(ctx context.Context, msg ethereum.CallMsg, blockHash common.Hash) (data []byte, err error)

CallContractAtHash is almost the same as CallContract except that it selects the block by block hash instead of block height.

func (*Client) ChainID

func (ec *Client) ChainID(ctx context.Context) (chainId *big.Int, err error)

ChainID retrieves the current chain ID for transaction replay protection.

func (*Client) Client added in v0.0.3

func (ec *Client) Client() *rpc.Client

func (*Client) Clients

func (ec *Client) Clients() []*ethclient.Client

func (*Client) Close

func (ec *Client) Close()

func (*Client) CodeAt

func (ec *Client) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) (data []byte, err 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

func (ec *Client) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (gas uint64, err 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.

func (*Client) FeeHistory

func (ec *Client) FeeHistory(ctx context.Context, blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64) (history *ethereum.FeeHistory, err error)

FeeHistory retrieves the fee market history.

func (*Client) FilterLogs

func (ec *Client) FilterLogs(ctx context.Context, q ethereum.FilterQuery) (logs []types.Log, err error)

FilterLogs executes a filter query.

func (*Client) HeaderByHash

func (ec *Client) HeaderByHash(ctx context.Context, hash common.Hash) (header *types.Header, err error)

func (*Client) HeaderByNumber

func (ec *Client) HeaderByNumber(ctx context.Context, number *big.Int) (header *types.Header, err error)

func (*Client) NetworkID

func (ec *Client) NetworkID(ctx context.Context) (ver *big.Int, err error)

NetworkID returns the network ID for this client.

func (*Client) NonceAt

func (ec *Client) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (nonce uint64, err 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) PeerCount

func (ec *Client) PeerCount(ctx context.Context) (count uint64, err error)

func (*Client) PendingBalanceAt

func (ec *Client) PendingBalanceAt(ctx context.Context, account common.Address) (balance *big.Int, err error)

PendingBalanceAt returns the wei balance of the given account in the pending state.

func (*Client) PendingCallContract

func (ec *Client) PendingCallContract(ctx context.Context, msg ethereum.CallMsg) (data []byte, err error)

PendingCallContract executes a message call transaction using the EVM. The state seen by the contract call is the pending state.

func (*Client) PendingCodeAt

func (ec *Client) PendingCodeAt(ctx context.Context, account common.Address) (data []byte, err error)

PendingCodeAt returns the contract code of the given account in the pending state.

func (*Client) PendingNonceAt

func (ec *Client) PendingNonceAt(ctx context.Context, account common.Address) (nonce uint64, err error)

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) (data []byte, err error)

PendingStorageAt returns the value of key in the contract storage of the given account in the pending state.

func (*Client) PendingTransactionCount

func (ec *Client) PendingTransactionCount(ctx context.Context) (count uint, err error)

PendingTransactionCount returns the total number of transactions in the pending state.

func (*Client) RandClient

func (ec *Client) RandClient() *ethclient.Client

func (*Client) SendTransaction

func (ec *Client) SendTransaction(ctx context.Context, tx *types.Transaction) (err error)

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) StorageAt

func (ec *Client) StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) (data []byte, err 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) SuggestGasPrice

func (ec *Client) SuggestGasPrice(ctx context.Context) (gasPrice *big.Int, err error)

SuggestGasPrice retrieves the currently suggested gas price to allow a timely execution of a transaction.

func (*Client) SuggestGasTipCap

func (ec *Client) SuggestGasTipCap(ctx context.Context) (gasTipCap *big.Int, err error)

SuggestGasTipCap retrieves the currently suggested gas tip cap after 1559 to allow a timely execution of a transaction.

func (*Client) SyncProgress

func (ec *Client) SyncProgress(ctx context.Context) (progress *ethereum.SyncProgress, err error)

func (*Client) TransactionByHash

func (ec *Client) TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error)

func (*Client) TransactionCount

func (ec *Client) TransactionCount(ctx context.Context, blockHash common.Hash) (count uint, err error)

func (*Client) TransactionInBlock

func (ec *Client) TransactionInBlock(ctx context.Context, blockHash common.Hash, index uint) (tx *types.Transaction, err error)

func (*Client) TransactionReceipt

func (ec *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (receipt *types.Receipt, err error)

func (*Client) TransactionSender

func (ec *Client) TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (sender common.Address, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL