Batch Processing
The MetaTxGateway contract allows multiple meta-transactions to be executed in a single blockchain transaction. This reduces gas costs, improves user experience, and enables complex workflows to be performed atomically.
Overview
Batch processing in MetaTxGateway enables:
Atomic execution of multiple operations in a single transaction
Gas cost optimization by reducing per-transaction overhead
Simplified workflows for users and relayers
How It Works
The user signs a batch of meta-transactions (array of
MetaTransactionstructs) using EIP-712.The relayer submits the batch to
executeMetaTransactions.Each transaction in the batch is executed in order.
If a transaction fails, it does not revert the entire batch; each transaction's success is tracked individually.
Unused native tokens (ETH/BNB) are refunded to the user if some transactions fail.
Example: Batch Execution
function executeMetaTransactions(
address from,
MetaTransaction[] calldata metaTxs,
bytes calldata signature,
uint256 nonce,
uint256 deadline
) external payable nonReentrant whenNotPaused returns (bool[] memory successes)metaTxs: Array of transactions to execute.signature: EIP-712 signature for the batch.Returns: Array of booleans indicating success/failure for each transaction.
MetaTransaction Struct
Batch Execution Flow
Relayer collects meta-transactions from the user.
User signs the batch using EIP-712.
Relayer calls
executeMetaTransactionswith the batch and signature.Contract verifies signature, nonce, and deadline.
Each transaction is executed in order.
Success/failure for each transaction is returned.
Unused native tokens are refunded to the user.
Relayer deducts user credits from GasCreditVault to cover gas fees.
Example (JavaScript)
Notes
All meta-transactions in the batch must be signed together.
The batch does not revert if one transaction fails; each result is reported individually.
There are no advanced execution modes (all-or-nothing, partial, etc.) in the current contract.
Related Topics:
Last updated