Documentation ¶
Index ¶
- func Add(numLike ...any) *big.Int
- func Address(addressLike any, isPri ...bool) common.Address
- func AddressPtr(addressLike any, isPri ...bool) *common.Address
- func AddressSlice(addressLikeArr any) (addresses []common.Address)
- func BigInt(numLike any) *big.Int
- func BigIntSlice(bigLikeArr any) (bigInts []*big.Int)
- func CallMsg(fromAddress any, tx *types.Transaction) (callMsg ethereum.CallMsg)
- func CheckRpcLogged(rpcLike ...string) (reliableList []string, rpcSpeedMap map[string]time.Duration)
- func CheckRpcSpeed(rpcLike ...string) (reliableList []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 HashPtr(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 PrivateKey(priLike any) *ecdsa.PrivateKey
- func RandBytes(len int) []byte
- func Sub(numBase any, numLike ...any) *big.Int
- func Sum(numLike ...any) *big.Int
- func Type[T any](x any) T
- func Uint64(numLike any) uint64
- type Clientx
- func (c *Clientx) BalanceAt(account any, 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) CodeAt(account any, blockNumber ...any) (code []byte)
- func (c *Clientx) EstimateGas(msg ethereum.CallMsg, maxTry ...int) (gasLimit uint64, err error)
- 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) GetRPCs() (rpcList []string)
- 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) NewMustContract(constructor any, addressLike any, config ...*ClientxConfig) *MustContract
- func (c *Clientx) NewRawLogger(addresses []common.Address, topics [][]common.Hash, ...) *RawLogger
- func (c *Clientx) NextClient() *ethclient.Client
- func (c *Clientx) NonceAt(account any, 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) SendTransaction(tx *types.Transaction, maxTry ...int) (err error)
- func (c *Clientx) Shuffle() *Clientx
- func (c *Clientx) StorageAt(account, keyHash any, blockNumber ...any) (storage []byte)
- func (c *Clientx) SuggestGasPrice() (gasPrice *big.Int)
- func (c *Clientx) SuggestGasTipCap() (gasTipCap *big.Int)
- func (c *Clientx) TransactOpts(privateKeyLike any) *bind.TransactOpts
- 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) Transfer(privateKeyLike, to, amount any, options ...TransferOption) (tx *types.Transaction, err error)
- func (c *Clientx) TransferETH(privateKeyLike, to any, value ...any) (tx *types.Transaction, err error)
- func (c *Clientx) UpdateRPCs(newRPCs []string)
- 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 ClientxConfig
- type EventConfig
- type Iterator
- func (r *Iterator[T]) Add(item ...T)
- func (r *Iterator[T]) All() []T
- func (r *Iterator[T]) Len() int
- func (r *Iterator[T]) Limiter() *rate.Limiter
- func (r *Iterator[T]) NewCall(maxTry ...int) func(f any, args ...any) []any
- func (r *Iterator[T]) Remove(item ...T)
- func (r *Iterator[T]) Shuffle() *Iterator[T]
- func (r *Iterator[T]) UnwaitNext() T
- func (r *Iterator[T]) WaitNext() T
- type MustContract
- func (m *MustContract) Call(maxErrNum int, f any, args ...any) (ret []any, err error)
- func (m *MustContract) Read(f any, args ...any) []any
- func (m *MustContract) Read0(f any, args ...any) any
- func (m *MustContract) Subscribe(ch any, from any, index ...any) (sub event.Subscription, blockNumber chan uint64)
- func (m *MustContract) Write(f any, args ...any) (*types.Transaction, error)
- type RawLogger
- type TransferOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Address ¶
Address addressLike is non-nil Attention: str without 0x will be treated as hex, eg: "10" => 0x10.
func AddressSlice ¶
AddressSlice parse any to []common.Address, eg: []string to []common.Address
func BigIntSlice ¶
BigIntSlice parse any to []*big.Int, eg: []string to []*big.Int
func CallMsg ¶ added in v1.6.0
func CallMsg(fromAddress any, tx *types.Transaction) (callMsg ethereum.CallMsg)
CallMsg create ethereum.CallMsg from *types.Transaction
func CheckRpcLogged ¶ added in v1.5.7
func CheckRpcLogged(rpcLike ...string) (reliableList []string, rpcSpeedMap map[string]time.Duration)
CheckRpcLogged returns what rpcs are reliable for filter logs example:
- rpc list: CheckRpcLogged("https://bsc-dataseed1.defibit.io", "https://bsc-dataseed4.binance.org")
- auto resolve rpc list: CheckRpcLogged("https://bsc-dataseed1.defibit.io\t29599361\t1.263s\t\t\nConnect Wallet\nhttps://bsc-dataseed4.binance.org")
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")
func Hash ¶
Hash hashLike is non-nil Attention: str without 0x will be treated as hex, eg: "10" => 0x10.
func PrivateKey ¶ added in v1.6.0
func PrivateKey(priLike any) *ecdsa.PrivateKey
Types ¶
type Clientx ¶
type Clientx struct {
// contains filtered or unexported fields
}
Clientx defines typed wrappers for the Ethereum RPC API of a set of the Ethereum Clients.
func NewClientx ¶
func NewClientx(rpcList []string, weights []int, config *ClientxConfig, 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 NewSimpleClientx ¶ added in v1.6.0
NewSimpleClientx create *Clientx concurrency is the concurrency per seconds of any rpc, default 1/s see NewClientx
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) EstimateGas ¶ added in v1.6.0
EstimateGas estimate tx gasUsed with maxTry.
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) NewMustContract ¶ added in v1.6.6
func (c *Clientx) NewMustContract(constructor any, addressLike any, config ...*ClientxConfig) *MustContract
NewMustContract is safe contract caller
func (*Clientx) NewRawLogger ¶ added in v1.6.6
func (c *Clientx) NewRawLogger(addresses []common.Address, topics [][]common.Hash, eventConfig ...*ClientxConfig) *RawLogger
NewRawLogger returns the RawLogger EventConfig require IntervalBlocks + OverrideBlocks <= 2000, eg: 800,800 addresses []common.Address : optional, could be nil topics topics [][]common.Hash : optional, could be nil
func (*Clientx) NextClient ¶ added in v1.6.3
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) SendTransaction ¶ added in v1.6.0
func (c *Clientx) SendTransaction(tx *types.Transaction, maxTry ...int) (err error)
SendTransaction send Transaction with maxTry.
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) TransactOpts ¶ added in v1.6.0
func (c *Clientx) TransactOpts(privateKeyLike any) *bind.TransactOpts
TransactOpts create *bind.TransactOpts, and panic if privateKey err privateKeyLike eg: 0xf1...3, f1...3, []byte, *ecdsa.PrivateKey...
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) Transfer ¶ added in v1.6.0
func (c *Clientx) Transfer(privateKeyLike, to, amount any, options ...TransferOption) (tx *types.Transaction, err error)
Transfer build transaction and send TransferOption is optional. see more: github.com/ethereum/go-ethereum/internal/ethapi/transaction_args.go:284
func (*Clientx) TransferETH ¶ added in v1.7.5
func (*Clientx) UpdateRPCs ¶ added in v1.6.1
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
type ClientxConfig ¶ added in v1.6.9
type ClientxConfig struct { Event EventConfig // MustContract and RawLogger GasLimit uint64 // Clientx NotFundBlocks uint64 // Clientx GasTipAdditional *big.Int // Clientx MaxMustErrNumR int // MustContract MaxMustErrNumW int // MustContract }
func NewClientxConfig ¶ added in v1.6.9
func NewClientxConfig() *ClientxConfig
type EventConfig ¶ added in v1.6.6
type EventConfig struct {
IntervalBlocks, OverrideBlocks, DelayBlocks uint64
}
func (*EventConfig) Clone ¶ added in v1.7.15
func (e *EventConfig) Clone() *EventConfig
type Iterator ¶
type Iterator[T any] struct { // contains filtered or unexported fields }
func (*Iterator[T]) UnwaitNext ¶ added in v1.6.0
func (r *Iterator[T]) UnwaitNext() T
type MustContract ¶ added in v1.6.6
type MustContract struct {
// contains filtered or unexported fields
}
func (*MustContract) Call ¶ added in v1.6.6
Call fit unsafe action, eg: maybe write failed If READ: missing the first *bind.CallOpts is legal If WRITE: missing the first *bind.CallOpts or PrivateKey is illegal
func (*MustContract) Read ¶ added in v1.6.13
func (m *MustContract) Read(f any, args ...any) []any
Read from contract safely, return all(not include last error) Attention: missing the first param/*bind.CallOpts is legal
func (*MustContract) Read0 ¶ added in v1.6.13
func (m *MustContract) Read0(f any, args ...any) any
Read0 read from contract safely, return first Attention: missing the first param/*bind.CallOpts is legal
func (*MustContract) Subscribe ¶ added in v1.6.6
func (m *MustContract) Subscribe(ch any, from any, index ...any) (sub event.Subscription, blockNumber chan uint64)
Subscribe contract event eventName is from ch, so just pass ch!
func (*MustContract) Write ¶ added in v1.6.13
func (m *MustContract) Write(f any, args ...any) (*types.Transaction, error)
Write to contract Attention: missing the first *bind.CallOpts or PrivateKey is illegal
type RawLogger ¶ added in v1.6.14
type RawLogger struct {
// contains filtered or unexported fields
}
type TransferOption ¶ added in v1.6.0
type TransferOption struct { Data []byte // option AccessList types.AccessList // option Opts *bind.TransactOpts // option }