Batched transactions
Last updated
Last updated
Authereum supported batched transactions right out of the box. This means that you can send an array of transactions and they will all get processed in 1 single transaction. Authereum batched transactions are also atomic meaning that all transactions in the batch must succeed, otherwise if any of the batched transactions fails then they are all cancelled.
For example, a common series of transaction is an approve
and transfer
call with ERC20 tokens. With batched transactions you can approve and transfer in a single transaction. If the approve call fails then the transfer call won't happen since the transaction before it failed. If the approve succeeds but the transfer fails then approve call is reverted and cancelled. If the approve succeeds and transfer succeeds then the entire transaction is successful.
In order to estimate the gas for a batched transaction, you can call estimateGasBatch
on the provider. This will return an array of numbers that represent the estimated gas, one for each transaction in the batch.
To learn how to implement batched transactions with the web3 provider, check out the documentation link below: