import Tabs from ‘@theme/Tabs’;
import TabItem from ‘@theme/TabItem’;
import {CodeTabs, Language, Github} from "@site/components/codetabs"
This example presents 3 instances of complex cross-contract calls. Particularly, it shows:
- How to batch multiple method calls to a same contract.
- How to call multiple contracts in parallel, each returning a different type.
- Different ways of handling the responses in the callback.
Batch Actions
You can aggregate multiple actions directed towards one same contract into a batched transaction.
Methods called this way are executed sequentially, with the added benefit that, if one fails then
they all get reverted.
Getting the Last Response
In this case, the callback has access to the value returned by the last
action from the chain.
Calling Multiple Contracts
A contract can call multiple other contracts. This creates multiple transactions that execute
all in parallel. If one of them fails the rest ARE NOT REVERTED.
Getting All Responses
In this case, the callback has access to an array of responses, which have either the
value returned by each call, or an error message.
Multiple Calls – Same Result Type
This example is a particular case of the previous one (2. Calling Multiple Contracts).
It simply showcases a different way to check the results by directly accessing the promise_result
array.
In this case, we call multiple contracts that will return the same type:
Getting All Responses
In this case, the callback again has access to an array of responses, which we can iterate checking the
results.