Skip to content
Permalink
Browse files
token transfer optimization
computes the total fee to pay to the submitBatch caller and transfers the total ERC-20 amount in one call
  • Loading branch information
albertchon committed Aug 26, 2020
1 parent b7ba416 commit 1970c2d499fee41f63cf688a8dd58e5d7fc21a16
Showing 1 changed file with 3 additions and 1 deletion.
@@ -287,11 +287,13 @@ contract Peggy {

// Send transaction amounts to destinations
// Send transaction fees to msg.sender
uint256 totalFee;
{
for (uint256 i = 0; i < _amounts.length; i = i.add(1)) {
IERC20(tokenContract).transfer(_destinations[i], _amounts[i]);
IERC20(tokenContract).transfer(msg.sender, _fees[i]);
totalFee = totalFee.add(_fees[i]);
}
IERC20(tokenContract).transfer(msg.sender, totalFee);
}
}

0 comments on commit 1970c2d

Please sign in to comment.