github.com/iotexproject/iotex-core@v1.14.1-rc1/tools/multisend/contracts/multisend.sol (about)

     1  pragma solidity ^0.4.24;
     2  contract Multisend {
     3      event Transfer(address recipient,uint amount);
     4      event Refund(uint refund);
     5      event Payload(string payload);
     6      function multiSend(address[] memory recipients, uint[] memory amounts,string memory payload) public payable{
     7          require(recipients.length <= 300, "number of recipients is larger than 300");
     8          require(recipients.length == amounts.length, "parameters not match");
     9          uint totalAmount = 0;
    10          for(uint i = 0; i < recipients.length; i++) {
    11              totalAmount+= amounts[i];
    12          }
    13          require(msg.value >= totalAmount, "not enough token");
    14          uint refund = msg.value - totalAmount;
    15          for(i = 0; i < recipients.length; i++) {
    16              recipients[i].transfer(amounts[i]);
    17              emit Transfer(recipients[i],amounts[i]);
    18          }
    19          if (refund>0) {
    20              msg.sender.transfer(refund);
    21              emit Refund(refund);
    22          }
    23          emit Payload(payload);
    24      }
    25  }