0

I am unable to set balance to zero to all of the subscriber except the winner so that winners gets the complete pool prize and other gets zero balance.

Also how can I prevent a subcriber for a double entry so that one subscriber can take part only once.

function WeeklyW1() public  {


        // not very good random, but better than nothing at the moment.
        uint randWinAddr = uint(block.blockhash(block.number - 1)) % subscriberListW1.length;
        winner = subscriberListW1[randWinAddr];

        for (uint i=0; i<subscriberListW1.length; i++) {
        uint value = (_balances[subscriberListW1[i]] * (subscriberListW1.length)) * 20/100;     
        uint value1 = ((_balances[subscriberListW1[i]] * (subscriberListW1.length)) - value);

        _balances[winner] += value1 ;
        _balances[owner] += value;


        owner.transfer(address(value).balance);       
        winner.transfer(address(value1).balance);


}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.