BatchTransaction() API you will need an existing account to pay for the associated transaction fee for both the batch transaction itself and each inner transaction.
Transaction Properties
Transaction Integrity
- Each inner transaction within a batch is treated as a self-contained transaction.
- If an inner transaction fails, preceding transactions that succeeded will still incur fees, even though their effects are not committed.
- Inner transactions are individually signed regular transactions.
Transaction Fees
- The cost to run a batch transaction includes fees for the outer batch transaction and also fees for each inner transaction.
- Outer and inner transactions are charged separately and may have different payers.
- Inner transactions that are processed will be charged the regular fees for their transaction type, even if the batch fails.
- Batch transaction fees are charged regardless of whether the transaction succeeds or fails.
Transaction Signing Requirements
- The account paying for the batch transaction fee is required to sign the batch transaction.
- Each inner transaction must be signed by its required signatories.
- The batch transaction must be signed by all
batchKeykeys specified in the included transactions.
Limits on Batch Size
- The maximum number of transactions in a batch is limited to 50 transactions.
- The maximum size of the batch transaction must not exceed 6KB, including all inner transactions.
- All inner transactions must execute within the standard transaction valid duration (typically 3 minutes).
Methods
| Method | Type | Requirement |
|---|---|---|
setInnerTransactions(<transactions>) | List<Transaction> | Optional |
addInnterTransaction(<transaction>) | Transaction | Optional |
setBatchKey(<key>) | Key | Required |
BatchKey Mechanism
ThebatchKey that is set during the creation of an inner transaction is a required signature for the encompassing batch transaction. This key ensures only authorized users can submit the batch and keeps all transactions together. When you set a batchKey, the system automatically marks the transaction as part of a batch by setting nodeAccountId to 0.0.0, which helps the network process it correctly.
Batchify Helper Method
Thebatchify() method is the recommended way to prepare transactions for inclusion in a batch. This helper method simplifies the process by handling multiple steps in a single call, reducing code complexity and potential errors.Get transaction values
| Method | Type | Description |
|---|---|---|
getInnerTransactions() | List<Transaction> | Returns the list of transactions in the batch |
getInnerTransactionIds() | List<TransactionId> | Returns the generated IDs of the inner transactions |
getBatchKey() | Key | Returns the batch key on an inner transaction |