multicall

package
v0.55.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Address

func Address(chainID uint64) types.Address

Address returns the address of the multicall contract for the given chain ID.

Types

type AggregatedCallables

type AggregatedCallables struct {
	// contains filtered or unexported fields
}

AggregatedCallables aggregates multiple Callables into a single call or transaction.

The AggregatedCallables will call the multicall contract to aggregate the calls. If only a single call is aggregated, the call will be called directly.

The AggregatedCallables will decode the result of the multicall contract and decode the result of the individual calls if they implement the Decoder interface.

There is a special case for Callables that returns a zero address as their address. In this case, the Callable will not be included in the aggregated call, but the AggregatedCallables will try to decode the result of the Callable providing nil as the call result. This is useful mostly for testing purposes.

To decode a result, a slice or a pointer to a slice must be provided. If the slice is empty, a new slice will be created with the same length as the number of calls. If the slice is not empty, the result will be decoded into the existing slice elements.

If the slice contains nil interfaces (e.g. nil values in []any), the corresponding slice elements will be skipped.

To avoid decoding a result, provide nil as the result argument.

func AggregateCallables

func AggregateCallables(calls ...contract.Callable) *AggregatedCallables

AggregateCallables creates a new AggregatedCallables instance.

func (*AggregatedCallables) AllowFail

func (a *AggregatedCallables) AllowFail() *AggregatedCallables

AllowFail allows the aggregated call to partially fail. If a call fails, the rest of the calls will still be executed.

func (*AggregatedCallables) NewCall

func (a *AggregatedCallables) NewCall(client rpc.RPC, chainID uint64) contract.SelfCaller

NewCall creates a new SelfCaller instance.

func (*AggregatedCallables) NewTransaction

func (a *AggregatedCallables) NewTransaction(client rpc.RPC, chainID uint64) contract.SelfTransactableCaller

NewTransaction creates a new SelfTransactableCaller instance.

type Call

type Call struct {
	Target    types.Address `abi:"target"`
	CallData  []byte        `abi:"callData"`
	AllowFail bool          `abi:"allowFailure"`
}

type Multicall

type Multicall struct {
	// contains filtered or unexported fields
}

func NewMulticall

func NewMulticall(client rpc.RPC) *Multicall

func (*Multicall) Aggregate3

func (m *Multicall) Aggregate3(chainID uint64, calls []Call) contract.TypedSelfTransactableCaller[[]Result]

type Result

type Result struct {
	Success bool   `abi:"success"`
	Data    []byte `abi:"returnData"`
}

Jump to

Keyboard shortcuts

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