0

In my contract I have a function that allocates funds to a bunch of shareholders according to their respective shares. Not sure why it reverts. The strange thing is it used to work some 3 months ago and I just copied the code into a new contract which fails 8 out of 10 times. Both arrays have the same length.

address payable[] public team;
uint256[] public shares;

function dividends()public payable{
    uint256 total = address(this).balance;
    for (uint8 i = 0; i < team.length; i++) {
        team[i].transfer((total * (shares[i] * 100)) / 10000);
    } 
}
3
  • oh, thats the kind of function that confuse estimateGas haha. try bumping the gas limit up :)
    – Foxxxey
    Commented Oct 24, 2021 at 22:16
  • It doesn't seem to matter. I took it all the way up. Also fails in Javascript VM, in Remix
    – Eight Rice
    Commented Oct 24, 2021 at 22:33
  • do you have a failed transaction hash? also if you're sending ether to contracts check their fallback function
    – Foxxxey
    Commented Oct 25, 2021 at 0:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.