Batched transactions.

Is there a work around for the scenario, where, in a batched transaction[bundled etheruem transaction] if one transaction fails, the remaining transactions are not executed?


Has anyone tried this? or Is there any literature you can point me to?

Dec 27, 2020, 1:32 PM
Replying to this post so that it finds more eyes. @Lauri_P , @mrrobot3_3 ,@tyler1111 any thoughts guys?
Dec 27, 2020, 5:28 PM
If you're using calls then check the return status before placing next transaction
Dec 27, 2020, 5:41 PM
Well you can use a contract for that
A contract with single function, which have all the transactions required. So if 1 fails, entire thing will be reverted
Dec 27, 2020, 5:50 PM
Thanks @mrrobot3_3

My question is, if there’s a workaround to handle failed transactions & still execute the entire batch?

1] The obvious workaround being, use higher gas fees. Say if there are 10 transactions batched, maybe use 168,000 as gas fees. You’d still save 42,000 on gas fees, and the transaction would still be lucrative for the miner to mine.


2] Any logical approach within the contract?


Below is an example function for batched transactions, I’m considering

function sendBatchedTransaction (
address[] memory _destination,
uint256[] memory _value,
bytes[] memory _data
)
private
{
for(uint256 i = 0; i < _data.length; i++) {
_destination[i].call.value(_value[i])(_data[i]);
}
}
Dec 27, 2020, 5:58 PM
No. If any statement fails, the whole transaction will fail. There is no way around that.
Dec 27, 2020, 6:05 PM
call/send returns false on failure while transfer throws an exception.
hence we use (bool success,) = ..call
and later check the return status.
Dec 27, 2020, 6:21 PM
The thing is, this will be one transaction with multiple internal transactions. The workaround would be to either a) manually do the transactions or b) have a server running that does that for you. If require(), assert() or whatever could be bypassed when working in one transaction, then ethereum would be not be where it is since each contract logically has to trust the other contracts.
Dec 28, 2020, 2:47 AM

© 2024 Draquery.com All rights reserved.