Guest User

Untitled

a guest
May 15th, 2018
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.60 KB | None | 0 0
  1. pragma solidity ^ 0.4 .18;
  2.  
  3. contract Token {
  4.     string public symbol = "";
  5.     string public name = "";
  6.     uint8 public constant decimals = 18;
  7.     uint256 _totalSupply = 0;
  8.     uint256 _BonusTokensPerETHdonated = 0;
  9.     uint256 _MaxDistribPublicSupply = 0;
  10.     uint256 _OwnerDistribSupply = 0;
  11.     uint256 _CurrentDistribPublicSupply = 0;
  12.     address _remainingTokensReceiverAddress = 0;
  13.     address owner = 0;
  14.     bool setupDone = false;
  15.     bool IsDistribRunning = false;
  16.     bool DistribStarted = false;
  17.  
  18.  
  19.     event Transfer(address indexed _from, address indexed _to, uint256 _value);
  20.     event Approval(address indexed _owner, address indexed _spender, uint256 _value);
  21.     event Burn(address indexed _owner, uint256 _value);
  22.  
  23.     mapping(address => uint256) balances;
  24.     mapping(address => mapping(address => uint256)) allowed;
  25.     mapping(address => bool) public claimedAlready;
  26.  
  27.     modifier onlyOwner() {
  28.         require(msg.sender == owner);
  29.         _;
  30.     }
  31.    
  32.  
  33.     function Token() public {
  34.         owner = msg.sender;
  35.     }
  36.    
  37.  
  38.     function SetupToken(string tokenName, string tokenSymbol, uint256 MaxDistribPublicSupply, uint256 OwnerDistribSupply) public {
  39.         if (msg.sender == owner && !setupDone) {
  40.             symbol = tokenSymbol;
  41.             name = tokenName;
  42.             _MaxDistribPublicSupply = MaxDistribPublicSupply * 1e18;
  43.             if (OwnerDistribSupply > 0) {
  44.                 _OwnerDistribSupply = OwnerDistribSupply * 1e18;
  45.                 _totalSupply = _OwnerDistribSupply;
  46.                 balances[owner] = _totalSupply;
  47.                 _CurrentDistribPublicSupply += _totalSupply;
  48.                 Transfer(this, owner, _totalSupply);
  49.             }
  50.  
  51.             setupDone = true;
  52.         }
  53.     }
  54.  
  55.  
  56.  
  57.     function StartDistrib() public returns(bool success) {
  58.         if (msg.sender == owner && !DistribStarted && setupDone) {
  59.             DistribStarted = true;
  60.             IsDistribRunning = true;
  61.         } else {
  62.             revert();
  63.         }
  64.         return true;
  65.     }
  66.  
  67.     function StopDistrib() public returns(bool success) {
  68.         if (msg.sender == owner && IsDistribRunning) {
  69.             if (_remainingTokensReceiverAddress != 0 && _MaxDistribPublicSupply > 0) {
  70.                 uint256 _remainingAmount = _MaxDistribPublicSupply - _CurrentDistribPublicSupply;
  71.                 if (_remainingAmount > 0) {
  72.                     balances[_remainingTokensReceiverAddress] += _remainingAmount;
  73.                     _totalSupply += _remainingAmount;
  74.                     Transfer(this, _remainingTokensReceiverAddress, _remainingAmount);
  75.                 }
  76.             }
  77.             DistribStarted = false;
  78.             IsDistribRunning = false;
  79.         } else {
  80.             revert();
  81.         }
  82.         return true;
  83.     }
  84.  
  85.     function distribution(address[] addresses, uint256 _amount) onlyOwner public {
  86.  
  87.         uint256 _remainingAmount = _MaxDistribPublicSupply - _CurrentDistribPublicSupply;
  88.         require(addresses.length <= 255);
  89.         require(_amount <= _remainingAmount);
  90.         _amount = _amount * 1e18;
  91.  
  92.         for (uint i = 0; i < addresses.length; i++) {
  93.             require(_amount <= _remainingAmount);
  94.             _CurrentDistribPublicSupply += _amount;
  95.             balances[msg.sender] += _amount;
  96.             _totalSupply += _amount;
  97.             Transfer(this, addresses[i], _amount);
  98.  
  99.         }
  100.  
  101.         if (_CurrentDistribPublicSupply >= _MaxDistribPublicSupply) {
  102.             DistribStarted = false;
  103.             IsDistribRunning = false;
  104.         }
  105.     }
  106.  
  107.     function distributeAmounts(address[] addresses, uint256[] amounts) onlyOwner public {
  108.  
  109.         uint256 _remainingAmount = _MaxDistribPublicSupply - _CurrentDistribPublicSupply;
  110.         uint256 _amount;
  111.  
  112.         require(addresses.length <= 255);
  113.         require(addresses.length == amounts.length);
  114.  
  115.         for (uint8 i = 0; i < addresses.length; i++) {
  116.             _amount = amounts[i] * 1e18;
  117.             require(_amount <= _remainingAmount);
  118.             _CurrentDistribPublicSupply += _amount;
  119.             balances[msg.sender] += _amount;
  120.             _totalSupply += _amount;
  121.             Transfer(this, addresses[i], _amount);
  122.  
  123.  
  124.             if (_CurrentDistribPublicSupply >= _MaxDistribPublicSupply) {
  125.                 DistribStarted = false;
  126.                 IsDistribRunning = false;
  127.             }
  128.         }
  129.     }
  130.  
  131.     function BurnTokens(uint256 amountInWei) public returns(bool success) {
  132.         uint256 amount = amountInWei * 1e18;
  133.         if (balances[msg.sender] >= amount) {
  134.             balances[msg.sender] -= amount;
  135.             _totalSupply -= amount;
  136.             Burn(msg.sender, amount);
  137.             Transfer(msg.sender, 0, amount);
  138.         } else {
  139.             revert();
  140.         }
  141.         return true;
  142.     }
  143.  
  144.     function totalSupply() public constant returns(uint256 totalSupplyValue) {
  145.         return _totalSupply;
  146.     }
  147.  
  148.     function BonusTokensPerETHdonated_() public constant returns(uint256 BonusTokensPerETHdonated) {
  149.         return _BonusTokensPerETHdonated;
  150.     }
  151.  
  152.     function MaxDistribPublicSupply_() public constant returns(uint256 MaxDistribPublicSupply) {
  153.         return _MaxDistribPublicSupply;
  154.     }
  155.  
  156.     function OwnerDistribSupply_() public constant returns(uint256 OwnerDistribSupply) {
  157.         return _OwnerDistribSupply;
  158.     }
  159.  
  160.     function CurrentDistribPublicSupply_() public constant returns(uint256 CurrentDistribPublicSupply) {
  161.         return _CurrentDistribPublicSupply;
  162.     }
  163.  
  164.     function RemainingTokensReceiverAddress() public constant returns(address remainingTokensReceiverAddress) {
  165.         return _remainingTokensReceiverAddress;
  166.     }
  167.  
  168.  
  169.     function Owner() public constant returns(address ownerAddress) {
  170.         return owner;
  171.     }
  172.  
  173.     function SetupDone() public constant returns(bool setupDoneFlag) {
  174.         return setupDone;
  175.     }
  176.  
  177.     function IsDistribRunningFalg_() public constant returns(bool IsDistribRunningFalg) {
  178.         return IsDistribRunning;
  179.     }
  180.  
  181.     function IsDistribStarted() public constant returns(bool IsDistribStartedFlag) {
  182.         return DistribStarted;
  183.     }
  184.  
  185.     function balanceOf(address _owner) public constant returns(uint256 balance) {
  186.         return balances[_owner];
  187.     }
  188.  
  189.     function transfer(address _to, uint256 _amount) public returns(bool success) {
  190.         if (balances[msg.sender] >= _amount &&
  191.             _amount > 0 &&
  192.             balances[_to] + _amount > balances[_to]) {
  193.             balances[msg.sender] -= _amount;
  194.             balances[_to] += _amount;
  195.             Transfer(msg.sender, _to, _amount);
  196.             return true;
  197.         } else {
  198.             return false;
  199.         }
  200.     }
  201.  
  202.     function transferFrom(
  203.         address _from,
  204.         address _to,
  205.         uint256 _amount
  206.     ) public returns(bool success) {
  207.         if (balances[_from] >= _amount &&
  208.             allowed[_from][msg.sender] >= _amount &&
  209.             _amount > 0 &&
  210.             balances[_to] + _amount > balances[_to]) {
  211.             balances[_from] -= _amount;
  212.             allowed[_from][msg.sender] -= _amount;
  213.             balances[_to] += _amount;
  214.             Transfer(_from, _to, _amount);
  215.             return true;
  216.         } else {
  217.             return false;
  218.         }
  219.     }
  220.  
  221.     function approve(address _spender, uint256 _amount) public returns(bool success) {
  222.         allowed[msg.sender][_spender] = _amount;
  223.         Approval(msg.sender, _spender, _amount);
  224.         return true;
  225.     }
  226.  
  227.     function allowance(address _owner, address _spender) public constant returns(uint256 remaining) {
  228.         return allowed[_owner][_spender];
  229.     }
  230. }
Advertisement
Add Comment
Please, Sign In to add comment