Skip to main content

execute_batched

Function execute_batched 

Source
pub fn execute_batched<I>(
    cache: &mut EvmCache,
    calls: I,
) -> MulticallResult<Vec<Result>>
where I: IntoIterator<Item = (Address, Bytes, bool)>,
Expand description

Execute multiple calls in batches using Multicall3.

Splits large call sets into consecutive batches of at most MAX_BATCH_SIZE calls, running each via MulticallBatch::execute. Results are concatenated in input order. Requires Multicall3 to be deployed at MULTICALL3_ADDRESS on the forked chain.

As with a single batch, the all-or-nothing semantics are per-batch: a call added with allow_failure = true that reverts surfaces as success = false in its result, whereas a call with allow_failure = false that reverts makes that batch’s aggregate3 revert (returned here as an Err).

§Arguments

  • cache - The EvmCache to execute calls on
  • calls - Iterator of (target, calldata, allow_failure) tuples

§Returns

A vector of results in the same order as the input calls.

§Errors

Returns an error as soon as any chunk’s MulticallBatch::execute fails — i.e. that chunk’s aggregate3 reverted (a allow_failure = false call failed, or Multicall3 is not deployed) or its return data failed to decode. Results from earlier successful chunks are discarded.