1

I have a function that in first call just counts values and in next calls transfer some amount of ETH. It's like:

function() public {
  ...
  if (val !=0) {
    address1.transfer(val.mul(part1).div(100));
    address2.transfer(val.mul(part2).div(100));
    address3.transfer(val.mul(part3).div(100));
    address4.transfer(val.mul(part4).div(100));
    address5.transfer(val.mul(part5).div(100));
    address6.transfer(val.mul(part6).div(100));
  }
 val = msg.value;
}

The first call requires 368,351 of gas and the second call cannot be sent because of

Gas estimation errored with the following message (see below). 
The transaction execution will likely fail. Do you want to force sending? 
gas required exceeds allowance (7007659) or always failing transaction

If I delete 5 transfers then it works. As I know transfer requires only 2100 of gas so I have a question: is it possible that 6 transfers increase gas requiements so high or I have a mistake anywhere in my code?

2

Transfer may fail because there is not enough ether on sender contract's balance, or because recipient is a smart contract that does not accept payments, or needs more than 2300 gas in order to process incoming ether transfers.

Assuming that part1 + part2 + ... + part6 ≤ 100 I would guess, that at least one of your destination addresses is a smart contract and there are some problems with it.

|improve this answer|||||
  • Thanks for your answer! Every out of 6 addresses is a smart-contract with a payable fallback function. Sender's contract has to have enough ether too... – Aleksandr Apr 29 '19 at 16:47
  • OK, then we have only one option left: one of these fallback functions needs more than 2300 gas. – Mikhail Vladimirov Apr 29 '19 at 17:20
  • Ah, yes. There was a stupid mistake. One of smart-contracts was looping this transaction. – Aleksandr Apr 30 '19 at 8:09

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.