Polkadot Apps
    Preparing search index...

    Function batchSubmitAndWatch

    • Batch multiple transactions into a single Substrate Utility batch and submit.

      Extracts .decodedCall from each transaction (handling Ink SDK AsyncTransaction wrappers), wraps them in Utility.batch_all (or batch/force_batch via the mode option), and submits via submitAndWatch with full lifecycle tracking.

      Parameters

      • calls: BatchableCall[]

        Array of transactions, AsyncTransactions, or raw decoded calls to batch.

      • api: BatchApi

        A typed API with tx.Utility.batch_all/batch/force_batch. Works with any chain that has the Utility pallet — no chain-specific imports required. All calls must target the same chain as this API. Do not mix decoded calls from different chains (e.g., Asset Hub and Bulletin) in a single batch.

      • signer: PolkadotSigner

        The signer to use. Can come from a wallet extension, Host API (getProductAccountSigner), or createDevSigner.

      • Optionaloptions: BatchSubmitOptions

        Optional BatchSubmitOptions (extends SubmitOptions with mode).

      Returns Promise<TxResult>

      The transaction result from the batch submission.

      If calls is empty.

      If an AsyncTransaction resolves without a .decodedCall property.

      If the batch transaction does not reach the target state within timeoutMs.

      If the on-chain dispatch fails.

      If the user rejects signing in their wallet.

      import { batchSubmitAndWatch } from "@polkadot-apps/tx";

      const tx1 = api.tx.Balances.transfer_keep_alive({ dest: addr1, value: 1_000n });
      const tx2 = api.tx.Balances.transfer_keep_alive({ dest: addr2, value: 2_000n });

      const result = await batchSubmitAndWatch([tx1, tx2], api, signer, {
      onStatus: (status) => console.log(status),
      });