batch
Group multiple commands into a single transaction.
Syntax
Section titled “Syntax”batch <block>Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
block |
block |
Block of commands |
Examples
Section titled “Examples”# Batch approve + transfer into one transactionbatch ( exec @token(DAI) "approve(address,uint256)" 0x64c007ba4ab6184753dc1e8e7263e8d06831c5f6 1000e18 exec @token(DAI) "transfer(address,uint256)" 0x64c007ba4ab6184753dc1e8e7263e8d06831c5f6 1000e18)Error Captures on Batches
Section titled “Error Captures on Batches”Error captures on a batch catch the combined transaction revert:
set $token 0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb
batch ( exec $token "transfer(address,uint256)" @me 100e18) -!> Error(string) [$reason]
# Assertion only: assert the batch reverts with a specific errorbatch ( exec $token "transfer(address,uint256)" @me 100e18) -!> Unauthorized()
# Optional form with a boolean variable ($reverted = "true"/"false")batch ( exec $token "transfer(address,uint256)" @me 100e18) -?!> Unauthorized() $reverted- All commands in the batch are combined into a single atomic transaction
(EIP-5792
wallet_sendCallsfor EOAs, batched Safe transaction for Safes) - If any command in the batch reverts, the entire batch reverts
- Event captures (
->) on a batch apply to the combined transaction receipt - Error captures (
-!>/-?!>) on a batch catch the combined transaction revert - Inside a
sim:forkblock, the batch is simulated as an EIP-7702 transaction: a delegation to MetaMask’s EIP7702StatelessDeleGator is installed on the sender EOA (if not already delegated) and the calls execute atomically through it — mirroring how wallets fulfillwallet_sendCalls
See Also
Section titled “See Also”- exec — individual contract calls