<<  >> (p.277)
    Author Topic: [ETH] Ethereum - мировой компьютер  (Read 1889065 times)
    This is a self-moderated topic. If you do not want to be moderated by the person who started this topic, create a new topic. (1 post by 1+ user deleted.)
    t309
    Legendary
    *
    Offline Offline

    Activity: 1946
    Merit: 1000


    View Profile
    February 20, 2016, 11:24:48 PM
     #5521

    Если кто то хочет поиграться, или сделать свой, держите
    Quote
    contract DoubleTx{

        struct Participant {
            address etherAddress;
            uint PayAmount;
        }

        Participant[] public participants;

        uint public payoutIdx = 0;
        uint public collectedFees = 0;
        uint public balance = 0;
       uint public timeout = now + 1 weeks;

        address public owner;


       / simple single-sig function modifier
        modifier onlyowner { if (msg.sender == owner) _ }

       / this function is executed at initialization and sets the owner of the contract
        function DoubleTx() {
          collectedFees += msg.value;
            owner = msg.sender;
        }

       / fallback function - simple transactions trigger this
        function() {
            enter();
        }
       
        function enter() {
          //send more than 0.1 ether and less than 50, otherwise loss all
          if (msg.value >= 100 finney && msg.value <= 50 ether) {
              /update contract balance
               balance += msg.value;
       
                // add a new participant to array and calculate need balance to payout
               uint idx = participants.length;
               participants.length += 1;
               participants[idx].etherAddress = msg.sender;
               participants[idx].PayAmount = 2 * msg.value;
             
             uint NeedAmount = participants[payoutIdx].PayAmount;
             // if there are enough ether on the balance we can pay out to an earlier participant
              if (balance >= NeedAmount) {
                   participants[payoutIdx].etherAddress.send(NeedAmount);
       
                   balance -= NeedAmount;
                   payoutIdx += 1;
               }
          }
          else {
             collectedFees += msg.value;
                return;
          }
        }

       function NextPayout() {
            balance += msg.value;
          uint NeedAmount = participants[payoutIdx].PayAmount;

           if (balance >= NeedAmount) {
                participants[payoutIdx].etherAddress.send(NeedAmount);

                balance -= NeedAmount;
                payoutIdx += 1;
            }
        }

        function collectFees() onlyowner {
          collectedFees += msg.value;
            if (collectedFees == 0) return;

            owner.send(collectedFees);
            collectedFees = 0;
        }

        function collectBalance() onlyowner {
          balance += msg.value;
            if (balance == 0 && now > timeout) return;

            owner.send(balance);
            balance = 0;
        }

        function setOwner(address _owner) onlyowner {
          collectedFees += msg.value;
            owner = _owner;
        }
    }

    Контракт с подвохом, админ может снять весь баланс.
    Функция collectBalance() отправляет весь баланс кошелька на адресс создателя.
    В моем такого нет!

    Ти би добавил вторую пирамидку ту что 2% в дапси ато там кмсло совсем.

Page 276
Viewing Page: 277