0

Here is my withdraw dividend code :

  function WithdrawDividend(address) public {

    if (!_RestrictedFromDividend[address(msg.sender)]) {
        _SavedDividend[msg.sender] = _balances[address(this)].mul(_balances[address(msg.sender)]).div(100000000);  
        uint256 DividendsToBurn = _SavedDividend[msg.sender].mul(10).div(10000);
        uint256 DividendstoDividend = _SavedDividend[msg.sender].sub(DividendsToBurn);

        _balances[address(this)] = _balances[address(this)].sub(DividendstoDividend).sub(DividendsToBurn);
        _balances[msg.sender] = _balances[msg.sender].add(DividendstoDividend);
        _balances[address(0)] = _balances[address(0)].add(DividendsToBurn);

        _totalSupply = _totalSupply.sub(DividendsToBurn);
                _RestrictedFromDividend[address(msg.sender)] = true;
        ClaimTime[address(msg.sender)] = now;

        emit Transfer(address(this), msg.sender, DividendstoDividend);
        emit Transfer(address(this), address(0), DividendsToBurn);

    }
    else {
        emit Transfer(address(this), msg.sender, 0);
    }

}

I used to have it so that people had to put in their balance in a value section as well as their address but I couldn't figure out how to stop people from claiming dividends worth more than their balance, so I did this. But now I get a bad instruction error in the transaction and I don't see what is wrong. Everything seems perfect to me.

3
  • The bad instruction is for something else, which you have not posted here. Commented Jul 22, 2019 at 5:04
  • @goodvibration can I get a bit of clarification as to what you mean? It only occurred when I changed the code in question
    – manilpwn
    Commented Jul 22, 2019 at 7:11
  • Well, why don't you change it and stop it from occurring??? Or by the least, do some preliminary work to find out what's causing it (as you say, as a result of your changes), and post your findings here. Commented Jul 22, 2019 at 7:30

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.