Multiple contract calls

With ContractMultiCallHandler, 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:

        let contract_methods = MyContract::new(contract_id, wallet.clone()).methods();

        let call_handler_1 = contract_methods.initialize_counter(42);
        let call_handler_2 = contract_methods.get_array([42; 2]);

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 ContractMultiCallHandler and optionally configure transaction parameters:

        let mut multi_call_handler = MultiContractCallHandler::new(wallet.clone());


Note: any transaction parameters configured on separate contract calls are disregarded in favor of the parameters provided to ContractMultiCallHandler.

Output values

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]) =;

You can also interact with the FuelCallResponse by moving the type annotation to the invoked method:

        let response =<(u64, [u64; 2])>().await?;