With MultiContractCallHandler, you can execute multiple contract calls within a single transaction. To achieve this, you first prepare all the contract calls that you want to bundle:
You can also set call parameters, variable outputs, or external contracts for every contract call, as long as you don't execute it with call() or simulate().
Next, you provide the prepared calls to your MultiContractCallHandler and optionally configure transaction policies:
To get the output values of the bundled calls, you need to provide explicit type annotations when saving the result of call() or simulate() to a variable:
let (counter, array): (u64, [u64; 2]) = multi_call_handler.call().await?.value;
You can also interact with the FuelCallResponse by moving the type annotation to the invoked method:
let response = multi_call_handler.call::<(u64, [u64; 2])>().await?;
Icon InfoCircle
Note: The MultiContractCallHandler supports only one contract call that returns a heap type. Because of the way heap types are handled, this contract call needs to be at the last position, i.e., added last with add_call. This is a temporary limitation that we hope to lift soon. In the meantime, if you have multiple calls handling heap types, split them across multiple regular, single calls.