Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BalanceBatcher ¶
type BalanceBatcher struct { // The number of addresses to query within a single call BalanceBatchSize int // The number of calls to run simultaneously, if the list of addresses is too large for a single call ThreadLimit int // contains filtered or unexported fields }
This struct can query the ETH balances of multiple addresses within a single call to an Execution Client. It is useful if you need to query the balance of many addresses, because batching them reduces RPC overhead.
func NewBalanceBatcher ¶
func NewBalanceBatcher(client IContractCaller, address common.Address, balanceBatchSize int, threadLimit int) (*BalanceBatcher, error)
Creates a new BalanceBatcher instance
func (*BalanceBatcher) GetEthBalances ¶
func (b *BalanceBatcher) GetEthBalances(addresses []common.Address, opts *bind.CallOpts) ([]*big.Int, error)
Retrieves the ETH balance for a list of addresses. The order of the resulting array corresponds to the order of the provided addresses.
type Call ¶
type Call struct { // The contract address of the target to run the call on Target common.Address `json:"target"` // Packed call data to be passed to the function as input CallData []byte `json:"callData"` // The name of the method being called (for debugging only) Method string `json:"-"` // Function to generate the call data PackFunc func() ([]byte, error) `json:"-"` // Function to generate the output from the response UnpackFunc func([]byte) error `json:"-"` }
A single contract call wrapper
type CallResponse ¶
type CallResponse struct { // Whether or not the particular call worked Status bool `json:"success"` // The return data for the call ReturnData []byte `json:"returnData"` }
The response from a contract call invocation
type IContractCaller ¶
type IContractCaller interface { // Calls a contract function, typically using eth_call CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) }
This is an Execution client binding that can call a contract function
type MultiCaller ¶
type MultiCaller struct {
// contains filtered or unexported fields
}
MultiCaller is capable of batching multiple arbitrary contract calls into one and executing them at the same time within a single `eth_call` to the client. It uses MakerDAO's Multicall v2 contract under the hood.
func NewMultiCaller ¶
func NewMultiCaller(client IContractCaller, multicallerAddress common.Address) (*MultiCaller, error)
Creates a new MultiCaller instance with the provided execution client and address of the multicaller contract
func (*MultiCaller) AddCall ¶
func (mc *MultiCaller) AddCall(contractAddress common.Address, abi *abi.ABI, output any, method string, args ...any)
Adds a contract call to the batch of calls to query during the next run
func (*MultiCaller) FlexibleCall ¶
Invokes all of the previously batched up contract calls in a single call. If requireSuccess is true, a single error will cause all of the calls to fail. If false, the calls can run independently and you will be given a list of resulting success or fail flags for each call. Upon completion, the internal list of batched up contract calls will be cleared.