Sponsored:   Temco - Join the Largest VC Backed ICO on the Bitcoin Network! TEMCO KYC Whitelist Starts Now!!
Contract Overview
Balance: 0 Ether
Ether Value: $0
Transactions: 59 txns
Misc:
Address Watch: Add To Watch List
Contract Creator: 0x107af532e6f828da6fe79699123c9a5ea0123d16at txn 0x0c2786d48c9cb141995b46af61cb23562605c1fa7d15d8e88f50c69845ab7cc8
 Latest 25 transactions from a total of 59 transactions

TxHash Age From To Value [TxFee]
0x745d41d45b2170883a2fd8ddd2beea887bdb9a9a4543a843840f7312c5fd45623 days 13 hrs ago0x1bae2e7cb57d699d3362d86964c6e268b19d05ca  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff1.072580645161289 Ether0.00596345
0x9a3737b898a8992b48f5a3308b16334a4d42f5891df8e1502cf5eda78388ff2e8 days 16 hrs ago0xe68fc89a36ecfc592ee7f4aef299877ffacaeaec  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.87163579168123 Ether0.00522803
0x0c0650d714f37faa54db7067d9d611512713b9fb8544c6fa67ec221a2ebaf7d714 days 15 hrs ago0xa8ee48eaab6bd037cb992e29f12a7b9da31ea222  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.086065573770491 Ether0.00596345
0xc3675435ac8dfdefd6992fe714398a8239fc82643da404922e9ff5cf28384d4114 days 15 hrs ago0xbad134ce4149417c493f0cdd9629d520884d54ec  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.430327868852458 Ether0.0005308
0x88e1b5c8b9b7da1df3bfa7a0e70cd1f509e707a375f6b8fe31c6d7bcf1ed0ded14 days 16 hrs ago0xbad134ce4149417c493f0cdd9629d520884d54ec  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.430327868852458 Ether0.00047772
0xb0530c44b3bf38d45ad23feff2361c5c1ef2689756770e29ca08875c325f1f3515 days 13 hrs ago0xfc6963d9441bb7a971d3b0261d42b32dbaf75b29  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.093574117596071 Ether0.00715614
0x7b0855206a624f3c96dd27a8a55078521d8e03e19bf6d306d321a7b11ea07f1517 days 13 hrs ago0x4dd6694d055a82846bda9717720dce3f2906f9b7  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.448960342871576 Ether0.00611345
0x5abdefd69f00da9ba664753bc9871c111c9d466eb1479580563687496c354ad619 days 9 hrs ago0x50f124eb8e8d42c7a05666e7908b28878779c8e4  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.831250069270838 Ether0.00522517
0x6aa13e4cf4ffee23eb0503c82429d0f462472e520b9e49b06531aa7c2daa50d622 days 14 hrs ago0xe13ccb8c29e1a921cbd70e1dd5cfe802f9f9d415  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.232483153072676 Ether0.00673004
0x32c7c96a5136944084faaf39b9d6870f881096ffcc98eeadac691d6bcca20f8b24 days 16 hrs ago0x198a123599e65140bfefa096648d968a67c3b807  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.056039325842696 Ether0.00522803
0xc783f80129861f094b159d6ead58cbf79d92106e1d7763e9667ebd287aa0938826 days 14 hrs ago0x6d8311be9b2fd060552f08145a303cdf6c28d8e9  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.548679867986798 Ether0.00596345
0x575b9bfd00461d8a9e37d798afaefbeefecbf98b138f06c20afea8a059ff664030 days 17 hrs ago0xee80db4997098b2b517223636f15d51a61f3549b  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.046941176470588 Ether0.002124872
0x52409f2ace1864011bd3c599a80b00274876251f7f05776fe4af976bbcc7546332 days 13 hrs ago0xebd20448db60014a2839ec4c55aff42e4f2fa2cb  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.046478809872566 Ether0.00611297
0x5353d4c6a3c3e48f599ee950b2ffe6c9c5ebaa39658b62ea11ada7307a8b14d533 days 1 hr ago0x6d03b52c2c5c8bf9d57adcbd0bcb1703058342c8  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.47319734345351 Ether0.0061976
0x0cdc2eee75266afd83f0b1fbb8d9b0ea6ada3b3d025105f9aa79b432841872a033 days 19 hrs ago0x7344d21a46749d6513fa9a53fa53fd407c86f614  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.465323772740303 Ether0.00667265
0x26113b029857ec7fbb7831cba276869d08f1796bd2bf3ebfdb762ae1b812f7c334 days 16 hrs ago0xe4bf41cfc43dc5361d3ec6219fcb10b6a283b40d  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.462233549582946 Ether0.00611108
0x2d0d6d6719387bd5d07f0bed88d94852e1807cbe404337e21832c8313e8fcc4034 days 16 hrs ago0xd7ce18835f371cf04a9ad8b61e61226875bcc2d8  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.231116774791473 Ether0.00611108
0x3e0676ff2c2050be4f63482d1bf4c5b48d9d049a89ffbe78e890e42c1a96144a35 days 15 hrs ago0x71a4ffc09dd5a7697c3e1026e704e2db1a149dfe  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.231521905343361 Ether0.00611297
0x679b93273b92f2bc4b16309a230d27cb7207d6f5bbe9b018ff0ab3c3f1e4768c37 days 19 hrs ago0x6de754c0816aa1ec98d2ff55ad6ea7d00ab6e131  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.470661007548807 Ether0.007151452
0xa8116b4a25a3dd8e9c1ffff696137f74c6b04a35205620b5fff5f9d23c43698838 days 13 hrs ago0x87bf1fccf3a0771584c6846ec7442ea0789ffa6b  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.049626865671641 Ether0.0068465
0xfd76243875eeb883f0932a2e5bb26ece9627d3dd5380bb89b24221be4a1b420b38 days 19 hrs ago0x349bd094209d50280dfaca12779576c748395c15  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.049626865671641 Ether0.0068465
0x11853e57911b343aef0e615c9201a6797681993360d75ba624418ff4207b925c38 days 20 hrs ago0x6cf16cb622a1dcf4b2acdd195e404a9095b83da7  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.247764542859639 Ether0.00684839
0xde4462eab3e8eb0476bbe74778975cd1af067e3d8907f05e910de1d353f0a40a38 days 20 hrs ago0x11763f0cb608516e768358c2a3890bdf8a158b35  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.495529085719278 Ether0.00611297
0x45db2dfab249929bb912d6a1c989197d0dc8d9b9b853e7d4f89d1417bfd825f838 days 23 hrs ago0x49335ba21fb78920119c9e4eba65e2097e2698e2  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.247518610421836 Ether0.00684839
0xee3bdc67b3e292977005f9a4c01ba790e141752832b7c9a1c99598ecb2ba6ec538 days 23 hrs ago0x11e059d9ac6bde6718cc9c86555f40bdb05e44f9  IN   0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0.049503722084367 Ether0.00611297
[ Download CSV Export  ] 
 Internal Transactions as a result of Contract Execution
 Latest 25 Internal Txns, Click here To View More View All
ParentTxHash Block Age From To Value
0x745d41d45b2170883a2fd8ddd2beea887bdb9a9a4543a843840f7312c5fd456268551783 days 13 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7551.0725806451612896 Ether
0x9a3737b898a8992b48f5a3308b16334a4d42f5891df8e1502cf5eda78388ff2e68241008 days 16 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.8716357916812301 Ether
0x0c0650d714f37faa54db7067d9d611512713b9fb8544c6fa67ec221a2ebaf7d7678812314 days 15 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.08606557377049173 Ether
0xb0530c44b3bf38d45ad23feff2361c5c1ef2689756770e29ca08875c325f1f35678256415 days 13 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.09357411759607102 Ether
0x7b0855206a624f3c96dd27a8a55078521d8e03e19bf6d306d321a7b11ea07f15677031917 days 13 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.4489603428715763 Ether
0x5abdefd69f00da9ba664753bc9871c111c9d466eb1479580563687496c354ad6675912219 days 9 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.8312500692708384 Ether
0x6aa13e4cf4ffee23eb0503c82429d0f462472e520b9e49b06531aa7c2daa50d6673975022 days 14 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.23248315307267606 Ether
0x32c7c96a5136944084faaf39b9d6870f881096ffcc98eeadac691d6bcca20f8b672709424 days 16 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.056039325842696584 Ether
0xc783f80129861f094b159d6ead58cbf79d92106e1d7763e9667ebd287aa09388671528626 days 14 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.548679867986798 Ether
0x575b9bfd00461d8a9e37d798afaefbeefecbf98b138f06c20afea8a059ff6640668996430 days 17 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.046941176470588184 Ether
0x52409f2ace1864011bd3c599a80b00274876251f7f05776fe4af976bbcc75463667876332 days 13 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.04647880987256679 Ether
0x5353d4c6a3c3e48f599ee950b2ffe6c9c5ebaa39658b62ea11ada7307a8b14d5667577633 days 1 hr ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.47319734345351014 Ether
0x0cdc2eee75266afd83f0b1fbb8d9b0ea6ada3b3d025105f9aa79b432841872a0667125133 days 19 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.4653237727403034 Ether
0x26113b029857ec7fbb7831cba276869d08f1796bd2bf3ebfdb762ae1b812f7c3666605634 days 16 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.4622335495829469 Ether
0x2d0d6d6719387bd5d07f0bed88d94852e1807cbe404337e21832c8313e8fcc40666603034 days 16 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.23111677479147344 Ether
0x3e0676ff2c2050be4f63482d1bf4c5b48d9d049a89ffbe78e890e42c1a96144a665993035 days 15 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.2315219053433612 Ether
0x679b93273b92f2bc4b16309a230d27cb7207d6f5bbe9b018ff0ab3c3f1e4768c664689137 days 19 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.4706610075488074 Ether
0xa8116b4a25a3dd8e9c1ffff696137f74c6b04a35205620b5fff5f9d23c436988664246238 days 13 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.04962686567164174 Ether
0xfd76243875eeb883f0932a2e5bb26ece9627d3dd5380bb89b24221be4a1b420b664084238 days 19 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.04962686567164175 Ether
0x11853e57911b343aef0e615c9201a6797681993360d75ba624418ff4207b925c664058438 days 20 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.2477645428596393 Ether
0xde4462eab3e8eb0476bbe74778975cd1af067e3d8907f05e910de1d353f0a40a664057738 days 20 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.4955290857192785 Ether
0x45db2dfab249929bb912d6a1c989197d0dc8d9b9b853e7d4f89d1417bfd825f8663979038 days 23 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.2475186104218362 Ether
0xee3bdc67b3e292977005f9a4c01ba790e141752832b7c9a1c99598ecb2ba6ec5663978738 days 23 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.04950372208436723 Ether
0x9c17eb3639358bb3676bcebe09154e65d756d5bdc3673285e3e76c0a53b00d1e663940939 days 1 hr ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.2475186104218362 Ether
0x20c29353148abccda4e621334f929596e6b51fb1a4df5f8252898625f619716d663648639 days 12 hrs ago0xf6ca4bde4f6df4d733090476e5052f26da37d8ff0x818e6fecd516ecc3849daf6845e3ec868087b7550.49386077829488026 Ether
[ Download CSV Export  ] 
Warning: The Compiled Contract might be susceptible to ExpExponentCleanup (medium/high-severity), EventStructWrongData (very low-severity) SolidityCompiler Bugs.

Contract Source Code Verified (Similar Match)
Note: Displaying Similar Match Verified Source Code At Contract 0x6b70f1bbc1c45200caa4711f5e68af2559cb7b58(Excluding Constructor Arguments if any)
Contract Name: IAO
Compiler Text: v0.4.24+commit.e67f0147
Optimization Enabled: Yes
Runs (Optimiser):  200



  Contract Source Code   Find Similiar Contracts

pragma solidity ^0.4.24;

/**
 * @title Ownable
 * @dev The Ownable contract has an owner address, and provides basic authorization control
 * functions, this simplifies the implementation of "user permissions".
 */
contract Ownable {
  address public owner;


  event OwnershipRenounced(address indexed previousOwner);
  event OwnershipTransferred(
    address indexed previousOwner,
    address indexed newOwner
  );


  /**
   * @dev The Ownable constructor sets the original `owner` of the contract to the sender
   * account.
   */
  constructor() public {
    owner = msg.sender;
  }

  /**
   * @dev Throws if called by any account other than the owner.
   */
  modifier onlyOwner() {
    require(msg.sender == owner);
    _;
  }

  /**
   * @dev Allows the current owner to relinquish control of the contract.
   * @notice Renouncing to ownership will leave the contract without an owner.
   * It will not be possible to call the functions with the `onlyOwner`
   * modifier anymore.
   */
  function renounceOwnership() public onlyOwner {
    emit OwnershipRenounced(owner);
    owner = address(0);
  }

  /**
   * @dev Allows the current owner to transfer control of the contract to a newOwner.
   * @param _newOwner The address to transfer ownership to.
   */
  function transferOwnership(address _newOwner) public onlyOwner {
    _transferOwnership(_newOwner);
  }

  /**
   * @dev Transfers control of the contract to a newOwner.
   * @param _newOwner The address to transfer ownership to.
   */
  function _transferOwnership(address _newOwner) internal {
    require(_newOwner != address(0));
    emit OwnershipTransferred(owner, _newOwner);
    owner = _newOwner;
  }
}


/**
 * @title SafeMath
 * @dev Math operations with safety checks that throw on error
 */
library SafeMath {

  /**
  * @dev Multiplies two numbers, throws on overflow.
  */
  function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
    // Gas optimization: this is cheaper than asserting 'a' not being zero, but the
    // benefit is lost if 'b' is also tested.
    // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
    if (_a == 0) {
      return 0;
    }

    c = _a * _b;
    assert(c / _a == _b);
    return c;
  }

  /**
  * @dev Integer division of two numbers, truncating the quotient.
  */
  function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
    // assert(_b > 0); // Solidity automatically throws when dividing by 0
    // uint256 c = _a / _b;
    // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
    return _a / _b;
  }

  /**
  * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
  */
  function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
    assert(_b <= _a);
    return _a - _b;
  }

  /**
  * @dev Adds two numbers, throws on overflow.
  */
  function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
    c = _a + _b;
    assert(c >= _a);
    return c;
  }
}

/**
 * @title Helps contracts guard against reentrancy attacks.
 * @author Remco Bloemen <[email protected]π.com>, Eenae <[email protected]>
 * @dev If you mark a function `nonReentrant`, you should also
 * mark it `external`.
 */
contract ReentrancyGuard {

  /// @dev Constant for unlocked guard state - non-zero to prevent extra gas costs.
  /// See: https://github.com/OpenZeppelin/openzeppelin-solidity/issues/1056
  uint private constant REENTRANCY_GUARD_FREE = 1;

  /// @dev Constant for locked guard state
  uint private constant REENTRANCY_GUARD_LOCKED = 2;

  /**
   * @dev We use a single lock for the whole contract.
   */
  uint private reentrancyLock = REENTRANCY_GUARD_FREE;

  /**
   * @dev Prevents a contract from calling itself, directly or indirectly.
   * If you mark a function `nonReentrant`, you should also
   * mark it `external`. Calling one `nonReentrant` function from
   * another is not supported. Instead, you can implement a
   * `private` function doing the actual work, and an `external`
   * wrapper marked as `nonReentrant`.
   */
  modifier nonReentrant() {
    require(reentrancyLock == REENTRANCY_GUARD_FREE);
    reentrancyLock = REENTRANCY_GUARD_LOCKED;
    _;
    reentrancyLock = REENTRANCY_GUARD_FREE;
  }

}


/**
 * @title ERC20Basic
 * @dev Simpler version of ERC20 interface
 * See https://github.com/ethereum/EIPs/issues/179
 */
contract ERC20Basic {
  function totalSupply() public view returns (uint256);
  function balanceOf(address _who) public view returns (uint256);
  function transfer(address _to, uint256 _value) public returns (bool);
  event Transfer(address indexed from, address indexed to, uint256 value);
}


/**
 * @title ERC20 interface
 * @dev see https://github.com/ethereum/EIPs/issues/20
 */
contract ERC20 is ERC20Basic {
  function allowance(address _owner, address _spender)
    public view returns (uint256);

  function transferFrom(address _from, address _to, uint256 _value)
    public returns (bool);

  function approve(address _spender, uint256 _value) public returns (bool);
  event Approval(
    address indexed owner,
    address indexed spender,
    uint256 value
  );
}


/**
 * @title DetailedERC20 token
 * @dev The decimals are only for visualization purposes.
 * All the operations are done using the smallest and indivisible token unit,
 * just as on Ethereum all the operations are done in wei.
 */
contract DetailedERC20 is ERC20 {
  string public name;
  string public symbol;
  uint8 public decimals;

  constructor(string _name, string _symbol, uint8 _decimals) public {
    name = _name;
    symbol = _symbol;
    decimals = _decimals;
  }
}


/// @dev The token controller contract must implement these functions
contract TokenController {
    /// @notice Called when `_owner` sends ether to the MiniMe Token contract
    /// @param _owner The address that sent the ether to create tokens
    /// @return True if the ether is accepted, false if it throws
    function proxyPayment(address _owner) public payable returns(bool);

    /// @notice Notifies the controller about a token transfer allowing the
    ///  controller to react if desired
    /// @param _from The origin of the transfer
    /// @param _to The destination of the transfer
    /// @param _amount The amount of the transfer
    /// @return False if the controller does not authorize the transfer
    function onTransfer(address _from, address _to, uint _amount) public returns(bool);

    /// @notice Notifies the controller about an approval allowing the
    ///  controller to react if desired
    /// @param _owner The address that calls `approve()`
    /// @param _spender The spender in the `approve()` call
    /// @param _amount The amount in the `approve()` call
    /// @return False if the controller does not authorize the approval
    function onApprove(address _owner, address _spender, uint _amount) public
        returns(bool);
}

/*
    Copyright 2016, Jordi Baylina

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/// @title MiniMeToken Contract
/// @author Jordi Baylina
/// @dev This token contract's goal is to make it easy for anyone to clone this
///  token using the token distribution at a given block, this will allow DAO's
///  and DApps to upgrade their features in a decentralized manner without
///  affecting the original token
/// @dev It is ERC20 compliant, but still needs to under go further testing.

contract ApproveAndCallFallBack {
    function receiveApproval(address from, uint256 _amount, address _token, bytes _data) public;
}

/// @dev The actual token contract, the default owner is the msg.sender
///  that deploys the contract, so usually this token will be deployed by a
///  token owner contract, which Giveth will call a "Campaign"
contract MiniMeToken is Ownable {

    string public name;                //The Token's name: e.g. DigixDAO Tokens
    uint8 public decimals;             //Number of decimals of the smallest unit
    string public symbol;              //An identifier: e.g. REP
    string public version = 'MMT_0.2'; //An arbitrary versioning scheme


    /// @dev `Checkpoint` is the structure that attaches a block number to a
    ///  given value, the block number attached is the one that last changed the
    ///  value
    struct  Checkpoint {

        // `fromBlock` is the block number that the value was generated from
        uint128 fromBlock;

        // `value` is the amount of tokens at a specific block number
        uint128 value;
    }

    // `parentToken` is the Token address that was cloned to produce this token;
    //  it will be 0x0 for a token that was not cloned
    MiniMeToken public parentToken;

    // `parentSnapShotBlock` is the block number from the Parent Token that was
    //  used to determine the initial distribution of the Clone Token
    uint public parentSnapShotBlock;

    // `creationBlock` is the block number that the Clone Token was created
    uint public creationBlock;

    // `balances` is the map that tracks the balance of each address, in this
    //  contract when the balance changes the block number that the change
    //  occurred is also included in the map
    mapping (address => Checkpoint[]) balances;

    // `allowed` tracks any extra transfer rights as in all ERC20 tokens
    mapping (address => mapping (address => uint256)) allowed;

    // Tracks the history of the `totalSupply` of the token
    Checkpoint[] totalSupplyHistory;

    // Flag that determines if the token is transferable or not.
    bool public transfersEnabled;

    // The factory used to create new clone tokens
    MiniMeTokenFactory public tokenFactory;

////////////////
// Constructor
////////////////

    /// @notice Constructor to create a MiniMeToken
    /// @param _tokenFactory The address of the MiniMeTokenFactory contract that
    ///  will create the Clone token contracts, the token factory needs to be
    ///  deployed first
    /// @param _parentToken Address of the parent token, set to 0x0 if it is a
    ///  new token
    /// @param _parentSnapShotBlock Block of the parent token that will
    ///  determine the initial distribution of the clone token, set to 0 if it
    ///  is a new token
    /// @param _tokenName Name of the new token
    /// @param _decimalUnits Number of decimals of the new token
    /// @param _tokenSymbol Token Symbol for the new token
    /// @param _transfersEnabled If true, tokens will be able to be transferred
    constructor(
        address _tokenFactory,
        address _parentToken,
        uint _parentSnapShotBlock,
        string _tokenName,
        uint8 _decimalUnits,
        string _tokenSymbol,
        bool _transfersEnabled
    ) public {
        tokenFactory = MiniMeTokenFactory(_tokenFactory);
        name = _tokenName;                                 // Set the name
        decimals = _decimalUnits;                          // Set the decimals
        symbol = _tokenSymbol;                             // Set the symbol
        parentToken = MiniMeToken(_parentToken);
        parentSnapShotBlock = _parentSnapShotBlock;
        transfersEnabled = _transfersEnabled;
        creationBlock = block.number;
    }


///////////////////
// ERC20 Methods
///////////////////

    /// @notice Send `_amount` tokens to `_to` from `msg.sender`
    /// @param _to The address of the recipient
    /// @param _amount The amount of tokens to be transferred
    /// @return Whether the transfer was successful or not
    function transfer(address _to, uint256 _amount) public returns (bool success) {
        require(transfersEnabled);
        doTransfer(msg.sender, _to, _amount);
        return true;
    }

    /// @notice Send `_amount` tokens to `_to` from `_from` on the condition it
    ///  is approved by `_from`
    /// @param _from The address holding the tokens being transferred
    /// @param _to The address of the recipient
    /// @param _amount The amount of tokens to be transferred
    /// @return True if the transfer was successful
    function transferFrom(address _from, address _to, uint256 _amount
    ) public returns (bool success) {

        // The owner of this contract can move tokens around at will,
        //  this is important to recognize! Confirm that you trust the
        //  owner of this contract, which in most situations should be
        //  another open source smart contract or 0x0
        if (msg.sender != owner) {
            require(transfersEnabled);

            // The standard ERC 20 transferFrom functionality
            require(allowed[_from][msg.sender] >= _amount);
            allowed[_from][msg.sender] -= _amount;
        }
        doTransfer(_from, _to, _amount);
        return true;
    }

    /// @dev This is the actual transfer function in the token contract, it can
    ///  only be called by other functions in this contract.
    /// @param _from The address holding the tokens being transferred
    /// @param _to The address of the recipient
    /// @param _amount The amount of tokens to be transferred
    /// @return True if the transfer was successful
    function doTransfer(address _from, address _to, uint _amount
    ) internal {

           if (_amount == 0) {
               emit Transfer(_from, _to, _amount);    // Follow the spec to louch the event when transfer 0
               return;
           }

           require(parentSnapShotBlock < block.number);

           // Do not allow transfer to 0x0 or the token contract itself
           require((_to != 0) && (_to != address(this)));

           // If the amount being transfered is more than the balance of the
           //  account the transfer throws
           uint previousBalanceFrom = balanceOfAt(_from, block.number);

           require(previousBalanceFrom >= _amount);

           // Alerts the token owner of the transfer
           if (isContract(owner)) {
               require(TokenController(owner).onTransfer(_from, _to, _amount));
           }

           // First update the balance array with the new value for the address
           //  sending the tokens
           updateValueAtNow(balances[_from], previousBalanceFrom - _amount);

           // Then update the balance array with the new value for the address
           //  receiving the tokens
           uint previousBalanceTo = balanceOfAt(_to, block.number);
           require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
           updateValueAtNow(balances[_to], previousBalanceTo + _amount);

           // An event to make the transfer easy to find on the blockchain
           emit Transfer(_from, _to, _amount);

    }

    /// @param _owner The address that's balance is being requested
    /// @return The balance of `_owner` at the current block
    function balanceOf(address _owner) public constant returns (uint256 balance) {
        return balanceOfAt(_owner, block.number);
    }

    /// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
    ///  its behalf. This is a modified version of the ERC20 approve function
    ///  to be a little bit safer
    /// @param _spender The address of the account able to transfer the tokens
    /// @param _amount The amount of tokens to be approved for transfer
    /// @return True if the approval was successful
    function approve(address _spender, uint256 _amount) public returns (bool success) {
        require(transfersEnabled);

        // To change the approve amount you first have to reduce the addresses`
        //  allowance to zero by calling `approve(_spender,0)` if it is not
        //  already 0 to mitigate the race condition described here:
        //  https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
        require((_amount == 0) || (allowed[msg.sender][_spender] == 0));

        // Alerts the token owner of the approve function call
        if (isContract(owner)) {
            require(TokenController(owner).onApprove(msg.sender, _spender, _amount));
        }

        allowed[msg.sender][_spender] = _amount;
        emit Approval(msg.sender, _spender, _amount);
        return true;
    }

    /// @dev This function makes it easy to read the `allowed[]` map
    /// @param _owner The address of the account that owns the token
    /// @param _spender The address of the account able to transfer the tokens
    /// @return Amount of remaining tokens of _owner that _spender is allowed
    ///  to spend
    function allowance(address _owner, address _spender
    ) public constant returns (uint256 remaining) {
        return allowed[_owner][_spender];
    }

    /// @notice `msg.sender` approves `_spender` to send `_amount` tokens on
    ///  its behalf, and then a function is triggered in the contract that is
    ///  being approved, `_spender`. This allows users to use their tokens to
    ///  interact with contracts in one function call instead of two
    /// @param _spender The address of the contract able to transfer the tokens
    /// @param _amount The amount of tokens to be approved for transfer
    /// @return True if the function call was successful
    function approveAndCall(address _spender, uint256 _amount, bytes _extraData
    ) public returns (bool success) {
        require(approve(_spender, _amount));

        ApproveAndCallFallBack(_spender).receiveApproval(
            msg.sender,
            _amount,
            this,
            _extraData
        );

        return true;
    }

    /// @dev This function makes it easy to get the total number of tokens
    /// @return The total number of tokens
    function totalSupply() public constant returns (uint) {
        return totalSupplyAt(block.number);
    }


////////////////
// Query balance and totalSupply in History
////////////////

    /// @dev Queries the balance of `_owner` at a specific `_blockNumber`
    /// @param _owner The address from which the balance will be retrieved
    /// @param _blockNumber The block number when the balance is queried
    /// @return The balance at `_blockNumber`
    function balanceOfAt(address _owner, uint _blockNumber) public constant
        returns (uint) {

        // These next few lines are used when the balance of the token is
        //  requested before a check point was ever created for this token, it
        //  requires that the `parentToken.balanceOfAt` be queried at the
        //  genesis block for that token as this contains initial balance of
        //  this token
        if ((balances[_owner].length == 0)
            || (balances[_owner][0].fromBlock > _blockNumber)) {
            if (address(parentToken) != 0) {
                return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock));
            } else {
                // Has no parent
                return 0;
            }

        // This will return the expected balance during normal situations
        } else {
            return getValueAt(balances[_owner], _blockNumber);
        }
    }

    /// @notice Total amount of tokens at a specific `_blockNumber`.
    /// @param _blockNumber The block number when the totalSupply is queried
    /// @return The total amount of tokens at `_blockNumber`
    function totalSupplyAt(uint _blockNumber) public constant returns(uint) {

        // These next few lines are used when the totalSupply of the token is
        //  requested before a check point was ever created for this token, it
        //  requires that the `parentToken.totalSupplyAt` be queried at the
        //  genesis block for this token as that contains totalSupply of this
        //  token at this block number.
        if ((totalSupplyHistory.length == 0)
            || (totalSupplyHistory[0].fromBlock > _blockNumber)) {
            if (address(parentToken) != 0) {
                return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock));
            } else {
                return 0;
            }

        // This will return the expected totalSupply during normal situations
        } else {
            return getValueAt(totalSupplyHistory, _blockNumber);
        }
    }

////////////////
// Clone Token Method
////////////////

    /// @notice Creates a new clone token with the initial distribution being
    ///  this token at `_snapshotBlock`
    /// @param _cloneTokenName Name of the clone token
    /// @param _cloneDecimalUnits Number of decimals of the smallest unit
    /// @param _cloneTokenSymbol Symbol of the clone token
    /// @param _snapshotBlock Block when the distribution of the parent token is
    ///  copied to set the initial distribution of the new clone token;
    ///  if the block is zero than the actual block, the current block is used
    /// @param _transfersEnabled True if transfers are allowed in the clone
    /// @return The address of the new MiniMeToken Contract
    function createCloneToken(
        string _cloneTokenName,
        uint8 _cloneDecimalUnits,
        string _cloneTokenSymbol,
        uint _snapshotBlock,
        bool _transfersEnabled
        ) public returns(address) {
        if (_snapshotBlock == 0) _snapshotBlock = block.number;
        MiniMeToken cloneToken = tokenFactory.createCloneToken(
            this,
            _snapshotBlock,
            _cloneTokenName,
            _cloneDecimalUnits,
            _cloneTokenSymbol,
            _transfersEnabled
            );

        cloneToken.transferOwnership(msg.sender);

        // An event to make the token easy to find on the blockchain
        emit NewCloneToken(address(cloneToken), _snapshotBlock);
        return address(cloneToken);
    }

////////////////
// Generate and destroy tokens
////////////////

    /// @notice Generates `_amount` tokens that are assigned to `_owner`
    /// @param _owner The address that will be assigned the new tokens
    /// @param _amount The quantity of tokens generated
    /// @return True if the tokens are generated correctly
    function generateTokens(address _owner, uint _amount
    ) public onlyOwner returns (bool) {
        uint curTotalSupply = totalSupply();
        require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
        uint previousBalanceTo = balanceOf(_owner);
        require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
        updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
        updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
        emit Transfer(0, _owner, _amount);
        return true;
    }


    /// @notice Burns `_amount` tokens from `_owner`
    /// @param _owner The address that will lose the tokens
    /// @param _amount The quantity of tokens to burn
    /// @return True if the tokens are burned correctly
    function destroyTokens(address _owner, uint _amount
    ) onlyOwner public returns (bool) {
        uint curTotalSupply = totalSupply();
        require(curTotalSupply >= _amount);
        uint previousBalanceFrom = balanceOf(_owner);
        require(previousBalanceFrom >= _amount);
        updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);
        updateValueAtNow(balances[_owner], previousBalanceFrom - _amount);
        emit Transfer(_owner, 0, _amount);
        return true;
    }

////////////////
// Enable tokens transfers
////////////////


    /// @notice Enables token holders to transfer their tokens freely if true
    /// @param _transfersEnabled True if transfers are allowed in the clone
    function enableTransfers(bool _transfersEnabled) public onlyOwner {
        transfersEnabled = _transfersEnabled;
    }

////////////////
// Internal helper functions to query and set a value in a snapshot array
////////////////

    /// @dev `getValueAt` retrieves the number of tokens at a given block number
    /// @param checkpoints The history of values being queried
    /// @param _block The block number to retrieve the value at
    /// @return The number of tokens being queried
    function getValueAt(Checkpoint[] storage checkpoints, uint _block
    ) constant internal returns (uint) {
        if (checkpoints.length == 0) return 0;

        // Shortcut for the actual value
        if (_block >= checkpoints[checkpoints.length-1].fromBlock)
            return checkpoints[checkpoints.length-1].value;
        if (_block < checkpoints[0].fromBlock) return 0;

        // Binary search of the value in the array
        uint min = 0;
        uint max = checkpoints.length-1;
        while (max > min) {
            uint mid = (max + min + 1)/ 2;
            if (checkpoints[mid].fromBlock<=_block) {
                min = mid;
            } else {
                max = mid-1;
            }
        }
        return checkpoints[min].value;
    }

    /// @dev `updateValueAtNow` used to update the `balances` map and the
    ///  `totalSupplyHistory`
    /// @param checkpoints The history of data being updated
    /// @param _value The new number of tokens
    function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value
    ) internal  {
        if ((checkpoints.length == 0)
        || (checkpoints[checkpoints.length -1].fromBlock < block.number)) {
               Checkpoint storage newCheckPoint = checkpoints[ checkpoints.length++ ];
               newCheckPoint.fromBlock =  uint128(block.number);
               newCheckPoint.value = uint128(_value);
           } else {
               Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length-1];
               oldCheckPoint.value = uint128(_value);
           }
    }

    /// @dev Internal function to determine if an address is a contract
    /// @param _addr The address being queried
    /// @return True if `_addr` is a contract
    function isContract(address _addr) constant internal returns(bool) {
        uint size;
        if (_addr == 0) return false;
        assembly {
            size := extcodesize(_addr)
        }
        return size>0;
    }

    /// @dev Helper function to return a min betwen the two uints
    function min(uint a, uint b) pure internal returns (uint) {
        return a < b ? a : b;
    }

    /// @notice The fallback function: If the contract's owner has not been
    ///  set to 0, then the `proxyPayment` method is called which relays the
    ///  ether and creates tokens as described in the token owner contract
    function () public payable {
        require(isContract(owner));
        require(TokenController(owner).proxyPayment.value(msg.value)(msg.sender));
    }

//////////
// Safety Methods
//////////

    /// @notice This method can be used by the owner to extract mistakenly
    ///  sent tokens to this contract.
    /// @param _token The address of the token contract that you want to recover
    ///  set to 0 in case you want to extract ether.
    function claimTokens(address _token) public onlyOwner {
        if (_token == 0x0) {
            owner.transfer(address(this).balance);
            return;
        }

        MiniMeToken token = MiniMeToken(_token);
        uint balance = token.balanceOf(this);
        token.transfer(owner, balance);
        emit ClaimedTokens(_token, owner, balance);
    }

////////////////
// Events
////////////////
    event ClaimedTokens(address indexed _token, address indexed _owner, uint _amount);
    event Transfer(address indexed _from, address indexed _to, uint256 _amount);
    event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock);
    event Approval(
        address indexed _owner,
        address indexed _spender,
        uint256 _amount
        );

}


////////////////
// MiniMeTokenFactory
////////////////

/// @dev This contract is used to generate clone contracts from a contract.
///  In solidity this is the way to create a contract from a contract of the
///  same class
contract MiniMeTokenFactory {
    event CreatedToken(string symbol, address addr);

    /// @notice Update the DApp by creating a new token with new functionalities
    ///  the msg.sender becomes the owner of this clone token
    /// @param _parentToken Address of the token being cloned
    /// @param _snapshotBlock Block of the parent token that will
    ///  determine the initial distribution of the clone token
    /// @param _tokenName Name of the new token
    /// @param _decimalUnits Number of decimals of the new token
    /// @param _tokenSymbol Token Symbol for the new token
    /// @param _transfersEnabled If true, tokens will be able to be transferred
    /// @return The address of the new token contract
    function createCloneToken(
        address _parentToken,
        uint _snapshotBlock,
        string _tokenName,
        uint8 _decimalUnits,
        string _tokenSymbol,
        bool _transfersEnabled
    ) public returns (MiniMeToken) {
        MiniMeToken newToken = new MiniMeToken(
            this,
            _parentToken,
            _snapshotBlock,
            _tokenName,
            _decimalUnits,
            _tokenSymbol,
            _transfersEnabled
            );

        newToken.transferOwnership(msg.sender);
        emit CreatedToken(_tokenSymbol, address(newToken));
        return newToken;
    }
}

/// @title Kyber Network interface
interface KyberNetworkProxyInterface {
    function maxGasPrice() public view returns(uint);
    function getUserCapInWei(address user) public view returns(uint);
    function getUserCapInTokenWei(address user, DetailedERC20 token) public view returns(uint);
    function enabled() public view returns(bool);
    function info(bytes32 id) public view returns(uint);

    function getExpectedRate(DetailedERC20 src, DetailedERC20 dest, uint srcQty) public view
        returns (uint expectedRate, uint slippageRate);

    function tradeWithHint(DetailedERC20 src, uint srcAmount, DetailedERC20 dest, address destAddress, uint maxDestAmount,
        uint minConversionRate, address walletId, bytes hint) public payable returns(uint);
}


contract IAO is Ownable, ReentrancyGuard, TokenController {
    using SafeMath for uint256;

    modifier onlyActive {
        require(isActive, "IAO is not active");
        _;
    }

    DetailedERC20 constant internal ETH_TOKEN_ADDRESS = DetailedERC20(0x00eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee);

    uint256 constant PRECISION = 10 ** 18; // we use 18 decimals
    uint256 constant MAX_DONATION = 100 * (10 ** 18); // max donation is 100 DAI
    uint256 constant KRO_RATE = 5 * (10 ** 17); // 1 DAI == 0.5 KRO
    uint256 constant REFERRAL_BONUS = 10 * (10 ** 16); // 10% bonus for getting referred
    address constant DAI_ADDR = 0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359;
    address constant KYBER_ADDR = 0x818E6FECD516Ecc3849DAf6845e3EC868087B755;

    address public kroAddr;
    address public beneficiary;
    bytes32 public secretHash;
    bool public isActive;

    event Register(address indexed _manager, uint256 indexed _block, uint256 _donationInDAI);


    // admin & internal functions

    constructor (address _kroAddr, address _beneficiary, bytes32 _secretHash) public {
        kroAddr = _kroAddr;
        beneficiary = _beneficiary;
        secretHash = _secretHash;
    }
    

    function setActive(bool _isActive) onlyOwner public {
        isActive = _isActive;
    }


    function transferKROContractOwnership(address _newOwner, string _secret) public onlyOwner {
        require(!isActive, "IAO is not over"); // can only transfer ownership when IAO is over
        require(keccak256(abi.encodePacked(_secret)) == secretHash, "Secret incorrect"); // need to provide the correct secret

        // transfer ownership
        Ownable kro = Ownable(kroAddr);
        kro.transferOwnership(_newOwner);
    }


    function _register(uint256 _donationInDAI, address _referrer) internal onlyActive {
        require(_donationInDAI > 0 && _donationInDAI <= MAX_DONATION, "Donation out of range");
        require(_referrer != msg.sender, "Can't refer self");

        MiniMeToken kro = MiniMeToken(kroAddr);
        require(kro.balanceOf(msg.sender) == 0, "Already joined"); // each address can only join the IAO once

        // mint KRO for msg.sender
        uint256 kroAmount = _donationInDAI.mul(KRO_RATE).div(PRECISION);
        require(kro.generateTokens(msg.sender, kroAmount), "Failed minting");

        // mint KRO for referral program
        if (_referrer != address(0) && kro.balanceOf(_referrer) > 0) {
            uint256 bonusAmount = kroAmount.mul(REFERRAL_BONUS).div(PRECISION);
            require(kro.generateTokens(msg.sender, bonusAmount), "Failed minting sender bonus");
            require(kro.generateTokens(_referrer, bonusAmount), "Failed minting referrer bonus");
        }

        // transfer DAI to beneficiary
        DetailedERC20 dai = DetailedERC20(DAI_ADDR);
        require(dai.transfer(beneficiary, _donationInDAI), "Failed DAI transfer to beneficiary");
        
        // emit events
        emit Register(msg.sender, block.number, _donationInDAI);
    }


    // MiniMe TokenController functions, not used right now

    function proxyPayment(address _owner) public payable returns(bool) {
        return false;
    }


    function onTransfer(address _from, address _to, uint _amount) public returns(bool) {
        return false;
    }


    function onApprove(address _owner, address _spender, uint _amount) public
        returns(bool) {
        return false;
    }


    // registration functions

    function registerWithDAI(uint256 _donationInDAI, address _referrer) public nonReentrant {
        DetailedERC20 dai = DetailedERC20(DAI_ADDR);
        require(dai.transferFrom(msg.sender, this, _donationInDAI), "Failed DAI transfer to IAO");
        _register(_donationInDAI, _referrer);
    }


    function registerWithETH(address _referrer) public payable nonReentrant {
        DetailedERC20 dai = DetailedERC20(DAI_ADDR);
        KyberNetworkProxyInterface kyber = KyberNetworkProxyInterface(KYBER_ADDR);
        uint256 daiRate;
        bytes memory hint;

        // trade ETH for DAI
        (,daiRate) = kyber.getExpectedRate(ETH_TOKEN_ADDRESS, dai, msg.value);
        require(daiRate > 0, "Zero price");
        uint256 receivedDAI = kyber.tradeWithHint.value(msg.value)(ETH_TOKEN_ADDRESS, msg.value, dai, this, MAX_DONATION * 2, daiRate, beneficiary, hint);
        
        // if DAI value is greater than maximum allowed, return excess DAI to msg.sender
        if (receivedDAI > MAX_DONATION) {
            require(dai.transfer(msg.sender, receivedDAI.sub(MAX_DONATION)), "Excess DAI transfer failed");
            receivedDAI = MAX_DONATION;
        }

        // register new manager
        _register(receivedDAI, _referrer);
    }

    // _donationInTokens should use the token's precision
    function registerWithToken(address _token, uint256 _donationInTokens, address _referrer) public nonReentrant {
        require(_token != address(0) && _token != address(ETH_TOKEN_ADDRESS) && _token != DAI_ADDR, "Invalid token");
        DetailedERC20 token = DetailedERC20(_token);
        require(token.totalSupply() > 0, "Zero token supply");

        DetailedERC20 dai = DetailedERC20(DAI_ADDR);
        KyberNetworkProxyInterface kyber = KyberNetworkProxyInterface(KYBER_ADDR);
        uint256 daiRate;
        bytes memory hint;

        // transfer tokens to this contract
        require(token.transferFrom(msg.sender, this, _donationInTokens), "Failed token transfer to IAO");

        // trade tokens for DAI
        (,daiRate) = kyber.getExpectedRate(token, dai, _donationInTokens);
        require(daiRate > 0, "Zero price");
        require(token.approve(KYBER_ADDR, 0), "Token allowance prezeroing failed");
        require(token.approve(KYBER_ADDR, _donationInTokens), "Token approval failed");
        uint256 receivedDAI = kyber.tradeWithHint(token, _donationInTokens, dai, this, MAX_DONATION * 2, daiRate, beneficiary, hint);
        require(token.approve(KYBER_ADDR, 0), "Token allowance postzeroing failed");

        // if DAI value is greater than maximum allowed, return excess DAI to msg.sender
        if (receivedDAI > MAX_DONATION) {
            require(dai.transfer(msg.sender, receivedDAI.sub(MAX_DONATION)), "Excess DAI transfer failed");
            receivedDAI = MAX_DONATION;
        }

        // register new manager
        _register(receivedDAI, _referrer);
    }


    function () public payable nonReentrant {
        registerWithETH(address(0));
    }
}

    Contract ABI  
[{"constant":true,"inputs":[],"name":"kroAddr","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isActive","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"beneficiary","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"onTransfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_donationInDAI","type":"uint256"},{"name":"_referrer","type":"address"}],"name":"registerWithDAI","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_isActive","type":"bool"}],"name":"setActive","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"},{"name":"_donationInTokens","type":"uint256"},{"name":"_referrer","type":"address"}],"name":"registerWithToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"secretHash","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_referrer","type":"address"}],"name":"registerWithETH","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"onApprove","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"}],"name":"proxyPayment","outputs":[{"name":"","type":"bool"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"},{"name":"_secret","type":"string"}],"name":"transferKROContractOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_kroAddr","type":"address"},{"name":"_beneficiary","type":"address"},{"name":"_secretHash","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_manager","type":"address"},{"indexed":true,"name":"_block","type":"uint256"},{"indexed":false,"name":"_donationInDAI","type":"uint256"}],"name":"Register","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"}],"name":"OwnershipRenounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}]

  Contract Creation Code Switch To Opcodes View
60806040526001805534801561001457600080fd5b50604051606080611d9e83398101604090815281516020830151919092015160008054600160a060020a0319908116331790915560028054600160a060020a0395861690831617905560038054949093169316929092179055600455611d1f8061007f6000396000f3006080604052600436106100c15763ffffffff60e060020a6000350416630588e62281146100e457806322f3e2d41461011557806338af3eed1461013e5780634a39314914610153578063715018a61461017d5780638da5cb5b14610194578063a4619682146101a9578063acec338a146101cd578063ccfc8729146101e7578063d29e680314610212578063d2f03bf614610239578063da682aeb14610153578063f2fde38b1461024d578063f48c30541461026e578063fa1456a914610282575b60018054146100cf57600080fd5b60026001556100de60006102e9565b60018055005b3480156100f057600080fd5b506100f96106f3565b60408051600160a060020a039092168252519081900360200190f35b34801561012157600080fd5b5061012a610702565b604080519115158252519081900360200190f35b34801561014a57600080fd5b506100f961070b565b34801561015f57600080fd5b5061012a600160a060020a036004358116906024351660443561071a565b34801561018957600080fd5b50610192610723565b005b3480156101a057600080fd5b506100f961078f565b3480156101b557600080fd5b50610192600435600160a060020a036024351661079e565b3480156101d957600080fd5b5061019260043515156108c6565b3480156101f357600080fd5b50610192600160a060020a0360043581169060243590604435166108f0565b34801561021e57600080fd5b50610227611291565b60408051918252519081900360200190f35b610192600160a060020a03600435166102e9565b34801561025957600080fd5b50610192600160a060020a0360043516611297565b61012a600160a060020a03600435166112ba565b34801561028e57600080fd5b5060408051602060046024803582810135601f8101859004850286018501909652858552610192958335600160a060020a03169536956044949193909101919081908401838280828437509497506112c09650505050505050565b6000806000606060006001805414151561030257600080fd5b6002600155604080517f809a9e5500000000000000000000000000000000000000000000000000000000815273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee60048201527389d24a6b4ccb1b6faa2625fe562bdd9a2326035960248201819052346044830152825190975073818e6fecd516ecc3849daf6845e3ec868087b7559650869263809a9e5592606480820193918290030181600087803b1580156103ab57600080fd5b505af11580156103bf573d6000803e3d6000fd5b505050506040513d60408110156103d557600080fd5b5060200151925060008311610434576040805160e560020a62461bcd02815260206004820152600a60248201527f5a65726f20707269636500000000000000000000000000000000000000000000604482015290519081900360640190fd5b83600160a060020a03166329589f613473eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee34893068056bc75e2d631000006002028a600360009054906101000a9004600160a060020a03168b6040518a63ffffffff1660e060020a0281526004018089600160a060020a0316600160a060020a0316815260200188815260200187600160a060020a0316600160a060020a0316815260200186600160a060020a0316600160a060020a0316815260200185815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561054257818101518382015260200161052a565b50505050905090810190601f16801561056f5780820380516001836020036101000a031916815260200191505b5099505050505050505050506020604051808303818588803b15801561059457600080fd5b505af11580156105a8573d6000803e3d6000fd5b50505050506040513d60208110156105bf57600080fd5b5051905068056bc75e2d631000008111156106dd57600160a060020a03851663a9059cbb336105fd8468056bc75e2d6310000063ffffffff6114e016565b6040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b15801561064f57600080fd5b505af1158015610663573d6000803e3d6000fd5b505050506040513d602081101561067957600080fd5b505115156106d1576040805160e560020a62461bcd02815260206004820152601a60248201527f45786365737320444149207472616e73666572206661696c6564000000000000604482015290519081900360640190fd5b5068056bc75e2d631000005b6106e781876114f7565b50506001805550505050565b600254600160a060020a031681565b60055460ff1681565b600354600160a060020a031681565b60009392505050565b600054600160a060020a0316331461073a57600080fd5b60008054604051600160a060020a03909116917ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482091a26000805473ffffffffffffffffffffffffffffffffffffffff19169055565b600054600160a060020a031681565b60018054600091146107af57600080fd5b506002600155604080517f23b872dd0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044810184905290517389d24a6b4ccb1b6faa2625fe562bdd9a232603599182916323b872dd916064808201926020929091908290030181600087803b15801561083157600080fd5b505af1158015610845573d6000803e3d6000fd5b505050506040513d602081101561085b57600080fd5b505115156108b3576040805160e560020a62461bcd02815260206004820152601a60248201527f4661696c656420444149207472616e7366657220746f2049414f000000000000604482015290519081900360640190fd5b6108bd83836114f7565b50506001805550565b600054600160a060020a031633146108dd57600080fd5b6005805460ff1916911515919091179055565b600080600080606060006001805414151561090a57600080fd5b6002600155600160a060020a038916158015906109445750600160a060020a03891673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14155b801561096d5750600160a060020a0389167389d24a6b4ccb1b6faa2625fe562bdd9a2326035914155b15156109c3576040805160e560020a62461bcd02815260206004820152600d60248201527f496e76616c696420746f6b656e00000000000000000000000000000000000000604482015290519081900360640190fd5b889550600086600160a060020a03166318160ddd6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610a0657600080fd5b505af1158015610a1a573d6000803e3d6000fd5b505050506040513d6020811015610a3057600080fd5b505111610a87576040805160e560020a62461bcd02815260206004820152601160248201527f5a65726f20746f6b656e20737570706c79000000000000000000000000000000604482015290519081900360640190fd5b604080517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018a905290517389d24a6b4ccb1b6faa2625fe562bdd9a23260359965073818e6fecd516ecc3849daf6845e3ec868087b7559550600160a060020a038816916323b872dd9160648083019260209291908290030181600087803b158015610b2357600080fd5b505af1158015610b37573d6000803e3d6000fd5b505050506040513d6020811015610b4d57600080fd5b50511515610ba5576040805160e560020a62461bcd02815260206004820152601c60248201527f4661696c656420746f6b656e207472616e7366657220746f2049414f00000000604482015290519081900360640190fd5b604080517f809a9e55000000000000000000000000000000000000000000000000000000008152600160a060020a0388811660048301528781166024830152604482018b905282519087169263809a9e5592606480820193918290030181600087803b158015610c1457600080fd5b505af1158015610c28573d6000803e3d6000fd5b505050506040513d6040811015610c3e57600080fd5b5060200151925060008311610c9d576040805160e560020a62461bcd02815260206004820152600a60248201527f5a65726f20707269636500000000000000000000000000000000000000000000604482015290519081900360640190fd5b85600160a060020a031663095ea7b373818e6fecd516ecc3849daf6845e3ec868087b75560006040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b158015610d1557600080fd5b505af1158015610d29573d6000803e3d6000fd5b505050506040513d6020811015610d3f57600080fd5b50511515610dbd576040805160e560020a62461bcd02815260206004820152602160248201527f546f6b656e20616c6c6f77616e6365207072657a65726f696e67206661696c6560448201527f6400000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b604080517f095ea7b300000000000000000000000000000000000000000000000000000000815273818e6fecd516ecc3849daf6845e3ec868087b7556004820152602481018a90529051600160a060020a0388169163095ea7b39160448083019260209291908290030181600087803b158015610e3957600080fd5b505af1158015610e4d573d6000803e3d6000fd5b505050506040513d6020811015610e6357600080fd5b50511515610ebb576040805160e560020a62461bcd02815260206004820152601560248201527f546f6b656e20617070726f76616c206661696c65640000000000000000000000604482015290519081900360640190fd5b83600160a060020a03166329589f61878a883068056bc75e2d6310000060020289600360009054906101000a9004600160a060020a03168a6040518963ffffffff1660e060020a0281526004018089600160a060020a0316600160a060020a0316815260200188815260200187600160a060020a0316600160a060020a0316815260200186600160a060020a0316600160a060020a0316815260200185815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610fb4578181015183820152602001610f9c565b50505050905090810190601f168015610fe15780820380516001836020036101000a031916815260200191505b509950505050505050505050602060405180830381600087803b15801561100757600080fd5b505af115801561101b573d6000803e3d6000fd5b505050506040513d602081101561103157600080fd5b5051604080517f095ea7b300000000000000000000000000000000000000000000000000000000815273818e6fecd516ecc3849daf6845e3ec868087b75560048201526000602482018190529151929350600160a060020a0389169263095ea7b392604480840193602093929083900390910190829087803b1580156110b657600080fd5b505af11580156110ca573d6000803e3d6000fd5b505050506040513d60208110156110e057600080fd5b5051151561115e576040805160e560020a62461bcd02815260206004820152602260248201527f546f6b656e20616c6c6f77616e636520706f73747a65726f696e67206661696c60448201527f6564000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b68056bc75e2d6310000081111561127857600160a060020a03851663a9059cbb336111988468056bc75e2d6310000063ffffffff6114e016565b6040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b1580156111ea57600080fd5b505af11580156111fe573d6000803e3d6000fd5b505050506040513d602081101561121457600080fd5b5051151561126c576040805160e560020a62461bcd02815260206004820152601a60248201527f45786365737320444149207472616e73666572206661696c6564000000000000604482015290519081900360640190fd5b5068056bc75e2d631000005b61128281886114f7565b50506001805550505050505050565b60045481565b600054600160a060020a031633146112ae57600080fd5b6112b781611c38565b50565b50600090565b60008054600160a060020a031633146112d857600080fd5b60055460ff1615611333576040805160e560020a62461bcd02815260206004820152600f60248201527f49414f206973206e6f74206f7665720000000000000000000000000000000000604482015290519081900360640190fd5b60045460001916826040516020018082805190602001908083835b6020831061136d5780518252601f19909201916020918201910161134e565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b602083106113d05780518252601f1990920191602091820191016113b1565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902060001916141515611458576040805160e560020a62461bcd02815260206004820152601060248201527f53656372657420696e636f727265637400000000000000000000000000000000604482015290519081900360640190fd5b50600254604080517ff2fde38b000000000000000000000000000000000000000000000000000000008152600160a060020a03858116600483015291519190921691829163f2fde38b9160248082019260009290919082900301818387803b1580156114c357600080fd5b505af11580156114d7573d6000803e3d6000fd5b50505050505050565b6000828211156114ec57fe5b508082035b92915050565b60055460009081908190819060ff16151561155c576040805160e560020a62461bcd02815260206004820152601160248201527f49414f206973206e6f7420616374697665000000000000000000000000000000604482015290519081900360640190fd5b600086118015611575575068056bc75e2d631000008611155b15156115cb576040805160e560020a62461bcd02815260206004820152601560248201527f446f6e6174696f6e206f7574206f662072616e67650000000000000000000000604482015290519081900360640190fd5b600160a060020a03851633141561162c576040805160e560020a62461bcd02815260206004820152601060248201527f43616e27742072656665722073656c6600000000000000000000000000000000604482015290519081900360640190fd5b600254604080517f70a082310000000000000000000000000000000000000000000000000000000081523360048201529051600160a060020a03909216955085916370a08231916024808201926020929091908290030181600087803b15801561169557600080fd5b505af11580156116a9573d6000803e3d6000fd5b505050506040513d60208110156116bf57600080fd5b505115611716576040805160e560020a62461bcd02815260206004820152600e60248201527f416c7265616479206a6f696e6564000000000000000000000000000000000000604482015290519081900360640190fd5b611746670de0b6b3a764000061173a886706f05b59d3b2000063ffffffff611cb516565b9063ffffffff611cde16565b604080517f827f32c0000000000000000000000000000000000000000000000000000000008152336004820152602481018390529051919450600160a060020a0386169163827f32c0916044808201926020929091908290030181600087803b1580156117b257600080fd5b505af11580156117c6573d6000803e3d6000fd5b505050506040513d60208110156117dc57600080fd5b50511515611834576040805160e560020a62461bcd02815260206004820152600e60248201527f4661696c6564206d696e74696e67000000000000000000000000000000000000604482015290519081900360640190fd5b600160a060020a038516158015906118d25750600084600160a060020a03166370a08231876040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a03168152602001915050602060405180830381600087803b1580156118a457600080fd5b505af11580156118b8573d6000803e3d6000fd5b505050506040513d60208110156118ce57600080fd5b5051115b15611ace576118fb670de0b6b3a764000061173a8567016345785d8a000063ffffffff611cb516565b604080517f827f32c0000000000000000000000000000000000000000000000000000000008152336004820152602481018390529051919350600160a060020a0386169163827f32c0916044808201926020929091908290030181600087803b15801561196757600080fd5b505af115801561197b573d6000803e3d6000fd5b505050506040513d602081101561199157600080fd5b505115156119e9576040805160e560020a62461bcd02815260206004820152601b60248201527f4661696c6564206d696e74696e672073656e64657220626f6e75730000000000604482015290519081900360640190fd5b83600160a060020a031663827f32c086846040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b158015611a4c57600080fd5b505af1158015611a60573d6000803e3d6000fd5b505050506040513d6020811015611a7657600080fd5b50511515611ace576040805160e560020a62461bcd02815260206004820152601d60248201527f4661696c6564206d696e74696e6720726566657272657220626f6e7573000000604482015290519081900360640190fd5b50600354604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a03909216600483015260248201879052517389d24a6b4ccb1b6faa2625fe562bdd9a2326035991829163a9059cbb916044808201926020929091908290030181600087803b158015611b5157600080fd5b505af1158015611b65573d6000803e3d6000fd5b505050506040513d6020811015611b7b57600080fd5b50511515611bf9576040805160e560020a62461bcd02815260206004820152602260248201527f4661696c656420444149207472616e7366657220746f2062656e65666963696160448201527f7279000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b604080518781529051439133917f1d759fb22634fe2d322d688a4b46aaf185dd0a3db78ccf01a9218f00ac3df03f9181900360200190a3505050505050565b600160a060020a0381161515611c4d57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6000821515611cc6575060006114f1565b50818102818382811515611cd657fe5b04146114f157fe5b60008183811515611ceb57fe5b0493925050505600a165627a7a723058208c1620f96f9e4d57af42bd237ca5dab2d4c5cca9da09c2c9f9f3e89bed22c565002900000000000000000000000013c03e7a1c944fa87ffcd657182616420c6ea1f9000000000000000000000000332d87209f7c8296389c307eae170c2440830a476b8ac3035968526b7e0b8f25ac116418e1caa44f4d6038ec522d597ba2dd2c58

   Swarm Source:
bzzr://8c1620f96f9e4d57af42bd237ca5dab2d4c5cca9da09c2c9f9f3e89bed22c565

 

View All
Block Age transaction Difficulty GasUsed Reward
View All
Block Age UncleNumber Difficulty GasUsed Reward
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.