0

I googled and found that we shall use the following code to avoid paying too much to a contract recursively or consumed too much gas fee in one single transaciton.

function safeTransfer(address payable _base, uint value) internal {
    (bool success, ) = _base.call.value(value)("");
    require(success, "SafeTransfer");
}

In my use case, I am paying to 10 persons in one call.

I am wondering shall I just ignore if success=false. Because if the recipient is hostile, there is no reason for me to fail my entire transaction just because of him.

  • If you don't mind losing ether for that one hostile recipient, then you can ignore the value of success. – goodvibration May 16 at 7:26
  • @goodvibration are you saying that even if success=false the ether had been sent to the hostile recipient? – s k May 16 at 8:06
  • What do you think the require statement is for? – goodvibration May 16 at 8:24
  • Maybe I'm wrong, and it's just for signifying that the function has failed (if that is indeed the case, then I would just return success, but maybe the author had a different thought on it). – goodvibration May 16 at 8:26
  • @sk Where did you get this piece of code? Sometimes it is used as an alternative to send and transfer, but it has none of the advantages you say: it is not cheaper, it doesn't protect against re-entrancy attacks. – Ismael May 16 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.