Documentation ¶
Index ¶
- func Add(numLike ...any) *big.Int
- func Address(addressLike any) common.Address
- func AddressSlice(addressLikeArr any) (addresses []common.Address)
- func BigInt(numLike any) *big.Int
- func BigIntSlice(bigLikeArr any) (bigInts []*big.Int)
- func CheckRpcConn(rpcLike ...string) (reliableRpcList, badRpcList []string, reliableClients []*ethclient.Client, ...)
- func CheckRpcSpeed(rpcLike ...string) (rpcSpeedMap map[string]time.Duration)
- func Div(numLike0, numLike1 any) *big.Int
- func Gt(numLike0, numLike1 any, isAbs ...bool) bool
- func Gte(numLike0, numLike1 any, isAbs ...bool) bool
- func Hash(hashLike any) common.Hash
- func HashSlice(hashLikeArr any) (hashes []common.Hash)
- func Int64(numLike any) int64
- func Is0b(s string) bool
- func Is0o(s string) bool
- func Is0x(s string) bool
- func Lt(numLike0, numLike1 any, isAbs ...bool) bool
- func Lte(numLike0, numLike1 any, isAbs ...bool) bool
- func Mul(numLike ...any) *big.Int
- func MulDiv(numLike0, numLike1, numLike2 any) *big.Int
- func RandBytes(len int) []byte
- func Sub(numBase any, numLike ...any) *big.Int
- func Sum(numLike ...any) *big.Int
- func TypeSlice[T any](arr any) []T
- func Uint64(numLike any) uint64
- type AddressTopicLogsMap
- type Clientx
- func (c *Clientx) BalanceAt(account, blockNumber any) (balance *big.Int)
- func (c *Clientx) BlockByHash(hash any, notFoundBlocks ...uint64) (block *types.Block, err error)
- func (c *Clientx) BlockByNumber(blockNumber any, notFoundBlocks ...uint64) (block *types.Block, err error)
- func (c *Clientx) BlockNumber() (blockNumber uint64)
- func (c *Clientx) ChainID() (chainID *big.Int)
- func (c *Clientx) Close()
- func (c *Clientx) CodeAt(account, blockNumber any) (code []byte)
- func (c *Clientx) FeeHistory(blockCount uint64, lastBlock any, rewardPercentiles []float64) (feeHistory *ethereum.FeeHistory)
- func (c *Clientx) FilterLogs(q ethereum.FilterQuery) (logs []types.Log)
- func (c *Clientx) HeaderByHash(hash any, notFoundBlocks ...uint64) (header *types.Header, err error)
- func (c *Clientx) HeaderByNumber(blockNumber any, notFoundBlocks ...uint64) (header *types.Header, err error)
- func (c *Clientx) NetworkID() (networkID *big.Int)
- func (c *Clientx) NewMust(constructor any, addressLike any, maxErrNum ...int) func(f any, args ...any) []any
- func (c *Clientx) NewScanner(topics [][]common.Hash, addresses []common.Address, ...) *Scanner
- func (c *Clientx) NonceAt(account, blockNumber any) (nonce uint64)
- func (c *Clientx) PendingBalanceAt(account any) (balance *big.Int)
- func (c *Clientx) PendingCodeAt(account any) (code []byte)
- func (c *Clientx) PendingNonceAt(account any) (nonce uint64)
- func (c *Clientx) PendingStorageAt(account, keyHash any) (storage []byte)
- func (c *Clientx) PendingTransactionCount() (count uint)
- func (c *Clientx) StorageAt(account, keyHash, blockNumber any) (storage []byte)
- func (c *Clientx) SuggestGasPrice() (gasPrice *big.Int)
- func (c *Clientx) SuggestGasTipCap() (gasTipCap *big.Int)
- func (c *Clientx) TransactionByHash(hash any, notFoundBlocks ...uint64) (tx *types.Transaction, isPending bool, err error)
- func (c *Clientx) TransactionCount(blockHash any, notFoundBlocks ...uint64) (count uint, err error)
- func (c *Clientx) TransactionInBlock(blockHash any, index uint, notFoundBlocks ...uint64) (tx *types.Transaction, err error)
- func (c *Clientx) TransactionReceipt(txHash any, notFoundBlocks ...uint64) (receipt *types.Receipt, err error)
- func (c *Clientx) TransactionSender(tx *types.Transaction, blockHash any, index uint, notFoundBlocks ...uint64) (sender common.Address, err error)
- func (c *Clientx) WaitDeployed(tx *types.Transaction, confirmBlocks uint64, notFoundBlocks ...uint64) (common.Address, error)
- func (c *Clientx) WaitMined(tx *types.Transaction, confirmBlocks uint64, notFoundBlocks ...uint64) (*types.Receipt, error)
- type Iterator
- type Scanner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddressSlice ¶
AddressSlice parse any to []common.Address
func BigIntSlice ¶
BigIntSlice parse any to []*big.Int
func CheckRpcConn ¶
func CheckRpcConn(rpcLike ...string) (reliableRpcList, badRpcList []string, reliableClients []*ethclient.Client, reliableRpcMap map[*ethclient.Client]string)
CheckRpcConn returns what rpcs are reliable and what rpcs are bad example:
- CheckRpcConn("https://bsc-dataseed1.defibit.io", "https://bsc-dataseed4.binance.org")
- CheckRpcConn("https://bsc-dataseed1.defibit.io\t29599361\t1.263s\t\t\nConnect Wallet\nhttps://bsc-dataseed4.binance.org") // auto resolve rpc list
func CheckRpcSpeed ¶
CheckRpcSpeed returns the rpc speed list example:
- CheckRpcSpeed("https://bsc-dataseed1.defibit.io", "https://bsc-dataseed4.binance.org")
- CheckRpcSpeed("https://bsc-dataseed1.defibit.io\t29599361\t1.263s\t\t\nConnect Wallet\nhttps://bsc-dataseed4.binance.org")
Types ¶
type AddressTopicLogsMap ¶
type Clientx ¶
type Clientx struct { *Iterator[*ethclient.Client] Ctx context.Context RpcMap map[*ethclient.Client]string NotFoundBlocks uint64 AutoBlockNumber uint64 }
Clientx defines typed wrappers for the Ethereum RPC API of a set of the Ethereum Clients.
func NewClientx ¶
func NewClientx(rpcList []string, weights []int, notFoundBlocks uint64, limiter ...*rate.Limiter) *Clientx
NewClientx connects clients to the given URLs, to provide a reliable Ethereum RPC API call, includes a timer to regularly update block height(AutoBlockNumber). If weight <= 1, the weight is always 1. Note: If len(weightList) == 0, then default weight = 1 will be active.
func (*Clientx) BalanceAt ¶
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 (*Clientx) 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 (*Clientx) BlockByNumber ¶
func (c *Clientx) BlockByNumber(blockNumber any, notFoundBlocks ...uint64) (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 (*Clientx) BlockNumber ¶
BlockNumber returns the most recent block number
func (*Clientx) CodeAt ¶
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 (*Clientx) FeeHistory ¶
func (c *Clientx) FeeHistory(blockCount uint64, lastBlock any, rewardPercentiles []float64) (feeHistory *ethereum.FeeHistory)
FeeHistory retrieves the fee market history.
func (*Clientx) FilterLogs ¶
FilterLogs executes a filter query.
func (*Clientx) HeaderByHash ¶
func (c *Clientx) HeaderByHash(hash any, notFoundBlocks ...uint64) (header *types.Header, err error)
HeaderByHash returns the block header with the given hash.
func (*Clientx) HeaderByNumber ¶
func (c *Clientx) HeaderByNumber(blockNumber any, notFoundBlocks ...uint64) (header *types.Header, err error)
HeaderByNumber returns a block header from the current canonical chain. If number is nil, the latest known header is returned.
func (*Clientx) NewScanner ¶
func (c *Clientx) NewScanner(topics [][]common.Hash, addresses []common.Address, intervalBlocks, overrideBlocks, delayBlocks uint64) *Scanner
NewScanner returns the next Ethereum Client.
func (*Clientx) NonceAt ¶
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 (*Clientx) PendingBalanceAt ¶
PendingBalanceAt returns the wei balance of the given account in the pending state.
func (*Clientx) PendingCodeAt ¶
PendingCodeAt returns the contract code of the given account in the pending state.
func (*Clientx) 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 (*Clientx) PendingStorageAt ¶
PendingStorageAt returns the value of key in the contract storage of the given account in the pending state.
func (*Clientx) PendingTransactionCount ¶
PendingTransactionCount returns the total number of transactions in the pending state.
func (*Clientx) StorageAt ¶
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 (*Clientx) SuggestGasPrice ¶
SuggestGasPrice retrieves the currently suggested gas price to allow a timely execution of a transaction.
func (*Clientx) SuggestGasTipCap ¶
SuggestGasTipCap retrieves the currently suggested gas tip cap after 1559 to allow a timely execution of a transaction.
func (*Clientx) TransactionByHash ¶
func (c *Clientx) TransactionByHash(hash any, notFoundBlocks ...uint64) (tx *types.Transaction, isPending bool, err error)
TransactionByHash returns the transaction with the given hash.
func (*Clientx) TransactionCount ¶
TransactionCount returns the total number of transactions in the given block.
func (*Clientx) TransactionInBlock ¶
func (c *Clientx) TransactionInBlock(blockHash any, index uint, notFoundBlocks ...uint64) (tx *types.Transaction, err error)
TransactionInBlock returns a single transaction at index in the given block.
func (*Clientx) TransactionReceipt ¶
func (c *Clientx) TransactionReceipt(txHash any, notFoundBlocks ...uint64) (receipt *types.Receipt, err error)
TransactionReceipt returns the receipt of a transaction by transaction hash. Note that the receipt is not available for pending transactions.
func (*Clientx) TransactionSender ¶
func (c *Clientx) TransactionSender(tx *types.Transaction, blockHash any, index uint, notFoundBlocks ...uint64) (sender common.Address, err 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.
func (*Clientx) WaitDeployed ¶
func (c *Clientx) WaitDeployed(tx *types.Transaction, confirmBlocks uint64, notFoundBlocks ...uint64) (common.Address, error)
WaitDeployed waits for a contract deployment transaction and returns the on-chain contract address when it is mined. It stops waiting when Ctx is canceled.
func (*Clientx) WaitMined ¶
func (c *Clientx) WaitMined(tx *types.Transaction, confirmBlocks uint64, notFoundBlocks ...uint64) (*types.Receipt, error)
WaitMined waits for tx to be mined on the blockchain. It stops waiting when the context is canceled. ethereum/go-ethereum@v1.11.6/accounts/abi/bind/util.go:32