solidity 学习2.批量转账,存入eth。读取数据。

pragma solidity ^0.4.17;

import 'zeppelin-solidity/contracts/token/ERC20/StandardToken.sol';

contract BLEOS is StandardToken {

            address public owner;
            string public name = "BLEOS";

            string public symbol = "beos";

            uint8 public decimals = 18;

            uint public INITIAL_SUPPLY = 10000000000000000000000000000;

             function BLEOS() public {
                
                    totalSupply_ = INITIAL_SUPPLY;
                    balances[msg.sender] = INITIAL_SUPPLY;
                     owner = msg.sender;
                 
            }
             //存入一些ether用于后面的转账
        function deposit() payable public{
  
        }

	  //查询当前的余额
	  function getBalance() constant public returns(uint){
		  return this.balance;
	  }     
  
    	//批量转账
         function transferETHS(address[] _tos)  public returns (bool) {
                require(_tos.length > 0);
                require(msg.sender==owner);
                //Transfer(_from, _to, _value);
              for(uint32 i=0;i<_tos.length;i++){
                   _tos[i].transfer(this.balance/_tos.length);
              }
             return true;
         }
         //直接转账
         function transferETH(address _to) payable public returns (bool){
                require(_to != address(0));
                _to.transfer(msg.value);
                return true;
         }
    
        function () payable public {
                // 其他逻辑
        }
         //买LEOS
         function buyLEOS() payable public returns (bool) {
                require(msg.value <= balances[owner]);

                // SafeMath.sub will throw if there is not enough balance.
                balances[owner] = balances[owner].sub(msg.value);
                balances[msg.sender] = balances[msg.sender].add(msg.value);
                Transfer(owner, msg.sender, msg.value);
                return true;
            
        }

}


solidity 学习2.批量转账,存入eth。读取数据。_第1张图片

你可能感兴趣的:(区块链)