Contract 0x8b3c579efdd5e3cb445348eed499c2d86f64ad29

Contract Overview

Balance:
0.7809 Ether
TxHash Block Age From To Value [TxFee]
0x656e9da26b36298cf36d2f144e764dd8692be56c2c87a404c76f7775b7a9fd9f3346280124 days 1 hr ago0xd9a8ebfc5a7efa6b3e67fbbc014f1e493247294d IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290 Ether0.000028268
0xcb938936dcde87809a092ce11f9723a1495a302d7b5fa5ea47b6b56c3f78812f3346278124 days 1 hr ago0x6ba5835665a95462c414b5fad64782444402951e IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290 Ether0.0006186019
0xc0f2e8ea6dd2dc9dcf6cafb6d04be159d3aaa28c771fcae92582a5462e3a47cb3346277124 days 1 hr ago0x7249689ab618466f72c83a54e8da7d9905684405 IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290.011 Ether0.000060275
0x9d6ff3ae4bb5108a3fabff299708a6d531b29390538f928ba4fe732d4b7b1b973346268124 days 1 hr ago0x0d518269cfd6044b839927192ed35502055785e9 IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290 Ether0.0005721825
0x3184561948827eb33ef0814361c5ad6fd1e96893ddf3bf5f549e277e835563fb3346267124 days 1 hr ago0x4b20e709240fcb98f35c558f24ae2ca10727fcdd IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290.011 Ether0.000085275
0xe95fb6b3b14d7c51528928ac87046f3babfadf660aad282edeaf6bb82d2dbc6f3346092124 days 2 hrs ago0x555c6cdd6f1a4b6c3db8018b8e9c4ca9ed2018ae IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290 Ether0.004412698
0x82f2f8ffb6b00c8225d124c14f71922dca64d1a566516f540ba9f413707ae96e3346091124 days 2 hrs ago0x4b20e709240fcb98f35c558f24ae2ca10727fcdd IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290.38 Ether0.000051487
0x1046c7f26a74aa5a67c3cbb117c034f7047705d27a9d2e9ba7db6236d9f7510d3346073124 days 2 hrs ago0x03014be565459aa0829f2641935949d7be8b1ed9 IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290 Ether0.004564908
0xd3c58a99adb50307ae16d9d43ff688c8755675704a240ff74a51977e5d1bb1fe3346072124 days 2 hrs ago0x2dc92c5b4dfaad03f36a48840cca0941f0b9f7b8 IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290.38 Ether0.000051487
0x2ab89c4981f8bd1ee22c21ff5c13b4e66d0243cf4595e00996697f186d1caa483346024124 days 2 hrs ago0xd9a8ebfc5a7efa6b3e67fbbc014f1e493247294d IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290 Ether0.000030003
0x08e80d40248b3c65db0ec061dd0c77798e2fbf50fe5fb986bc298354f3320fe13345942124 days 3 hrs ago0x1e849ad655f7f364c4022bd8129f51083570d95f IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290 Ether0.002335644
0xcc7189662b376520a87ae9a850dad11b61ac137fbde3f504b4206d400c87bd7e3345941124 days 3 hrs ago0x2dc92c5b4dfaad03f36a48840cca0941f0b9f7b8 IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290.055 Ether0.000051455
0xd385084114a86e45d21e983f9fd8be454460fd62dddd830e95cad2fd6563e1113345939124 days 3 hrs ago0x55f74949a15ce98c9e9d8ebbdd774d5d7a25b473 IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290 Ether0.004609938
0x45911cdc659c9bd0719310e87fbf1c89330ba7984e511ceee6eceef639ac46003345938124 days 3 hrs ago0xa809ea076478d98219067925ccd816b47f01daa4 IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290.38 Ether0.000051487
0xdfa06f5561b5261a8d9fb2e1c89a33fca7e4276b5ebe0661d00e0328aa015d3c3345927124 days 3 hrs ago0xa6c58da995d30a3562d2e81eb06c42cfb5ffefd7 IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290 Ether0.000598647
0x7437d85145bd230bc51f28437f56fca729c14f9fb49620551ca317f65c24ac9e3345926124 days 3 hrs ago0x2dc92c5b4dfaad03f36a48840cca0941f0b9f7b8 IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290.011 Ether0.000085275
0x508896f6161047afd78aa4ae30193ea64e38dbd5c47a034b7acabce585ff80a33345908124 days 3 hrs ago0x7f4d43c46073f656ff231a3a6bf3170043f731f3 IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290 Ether0.002380566
0xd9a56f6610216757b52058596bf455e56165cf39fd91a023ea7a44d5c5fe8b503345906124 days 3 hrs ago0x4b20e709240fcb98f35c558f24ae2ca10727fcdd IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290.055 Ether0.000051455
0x1154307856da07d364d863d66184a968251f64cdf493d197d62ed9c6b590e4b03344900124 days 7 hrs ago0xd9a8ebfc5a7efa6b3e67fbbc014f1e493247294d IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290 Ether0.000042784
0x8c83390f335854f14bd6dfd92b713813483c4f7f974c493280b8473ab08eb85d3344899124 days 7 hrs ago0xd9a8ebfc5a7efa6b3e67fbbc014f1e493247294d IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290 Ether0.000042784
0x7c2e1cd7e2bfdc7c99e07f1f2752e6861c32154ae29d7b20d9ad1aea0000ae2b3344899124 days 7 hrs ago0xd9a8ebfc5a7efa6b3e67fbbc014f1e493247294d IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290 Ether0.000042784
0x906f32d67b04901a79cd35141590125386ca86b5b7fb7818a0ad417e2f60b3453344898124 days 7 hrs ago0xd9a8ebfc5a7efa6b3e67fbbc014f1e493247294d IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290 Ether0.000042784
0x6b49282b88dcf4c6732e015bab54ee3ce6bf4399f3af540be8490e696d469f963344897124 days 7 hrs ago0xd9a8ebfc5a7efa6b3e67fbbc014f1e493247294d IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290 Ether0.000042784
0x0adda6fd25386450369fd0b965116280bc1350ecfcdebb52edefb275db2e441a3344888124 days 7 hrs ago0xd9a8ebfc5a7efa6b3e67fbbc014f1e493247294d IN  0x8b3c579efdd5e3cb445348eed499c2d86f64ad290 Ether0.000043785
0xdd21b0637e3ab4a7699a1ec60bbf26a626202c3139915b69e1c782cbf5170ba63342342124 days 18 hrs ago0xd9a8ebfc5a7efa6b3e67fbbc014f1e493247294d IN  Contract Creation0 Ether0.054961361
[ Download CSV Export 

Latest 25 internal transaction, Click here to view more Internal Transactions as a result of Contract Execution

Parent TxHash Block Age From To Value
0xcb938936dcde87809a092ce11f9723a1495a302d7b5fa5ea47b6b56c3f78812f3346278124 days 1 hr ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0xc0f2e8ea6dd2dc9dcf6cafb6d04be159d3aaa28c771fcae92582a5462e3a47cb3346277124 days 1 hr ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290x3e256ae0034f1eca134308e5f2ea8e40014493f80.00055 Ether
0x9d6ff3ae4bb5108a3fabff299708a6d531b29390538f928ba4fe732d4b7b1b973346268124 days 1 hr ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0x3184561948827eb33ef0814361c5ad6fd1e96893ddf3bf5f549e277e835563fb3346267124 days 1 hr ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290x3e256ae0034f1eca134308e5f2ea8e40014493f80.00055 Ether
0xe95fb6b3b14d7c51528928ac87046f3babfadf660aad282edeaf6bb82d2dbc6f3346092124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0xe95fb6b3b14d7c51528928ac87046f3babfadf660aad282edeaf6bb82d2dbc6f3346092124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0xe95fb6b3b14d7c51528928ac87046f3babfadf660aad282edeaf6bb82d2dbc6f3346092124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0xe95fb6b3b14d7c51528928ac87046f3babfadf660aad282edeaf6bb82d2dbc6f3346092124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0xe95fb6b3b14d7c51528928ac87046f3babfadf660aad282edeaf6bb82d2dbc6f3346092124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0xe95fb6b3b14d7c51528928ac87046f3babfadf660aad282edeaf6bb82d2dbc6f3346092124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0xe95fb6b3b14d7c51528928ac87046f3babfadf660aad282edeaf6bb82d2dbc6f3346092124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0xe95fb6b3b14d7c51528928ac87046f3babfadf660aad282edeaf6bb82d2dbc6f3346092124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0xe95fb6b3b14d7c51528928ac87046f3babfadf660aad282edeaf6bb82d2dbc6f3346092124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0xe95fb6b3b14d7c51528928ac87046f3babfadf660aad282edeaf6bb82d2dbc6f3346092124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0x1046c7f26a74aa5a67c3cbb117c034f7047705d27a9d2e9ba7db6236d9f7510d3346073124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0x1046c7f26a74aa5a67c3cbb117c034f7047705d27a9d2e9ba7db6236d9f7510d3346073124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0x1046c7f26a74aa5a67c3cbb117c034f7047705d27a9d2e9ba7db6236d9f7510d3346073124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0x1046c7f26a74aa5a67c3cbb117c034f7047705d27a9d2e9ba7db6236d9f7510d3346073124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0x1046c7f26a74aa5a67c3cbb117c034f7047705d27a9d2e9ba7db6236d9f7510d3346073124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0x1046c7f26a74aa5a67c3cbb117c034f7047705d27a9d2e9ba7db6236d9f7510d3346073124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0x1046c7f26a74aa5a67c3cbb117c034f7047705d27a9d2e9ba7db6236d9f7510d3346073124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0x1046c7f26a74aa5a67c3cbb117c034f7047705d27a9d2e9ba7db6236d9f7510d3346073124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0x1046c7f26a74aa5a67c3cbb117c034f7047705d27a9d2e9ba7db6236d9f7510d3346073124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0x1046c7f26a74aa5a67c3cbb117c034f7047705d27a9d2e9ba7db6236d9f7510d3346073124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xa6dda780878d48853fe6cd96c7c1ebeaed7bfa010 Ether
0x2ab89c4981f8bd1ee22c21ff5c13b4e66d0243cf4595e00996697f186d1caa483346024124 days 2 hrs ago0x8b3c579efdd5e3cb445348eed499c2d86f64ad290xd9a8ebfc5a7efa6b3e67fbbc014f1e493247294d0.50045 Ether
[ Download CSV Export 
Warning: The compiled contract might be susceptible to ExpExponentCleanup (medium/high-severity), EventStructWrongData (very low-severity) Solidity Compiler Bugs.

Contract Source Code Verified (Exact Match)
Contract Name: GachaSale
Compiler Version: v0.4.24+commit.e67f0147
Optimization Enabled: Yes
Runs (Optimizer):  200


Contract Source Code
pragma solidity ^0.4.24;

// File: contracts/openzeppelin-solidity/introspection/ERC165.sol

/**
 * @title ERC165
 * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md
 */
interface ERC165 {

  /**
   * @notice Query if a contract implements an interface
   * @param _interfaceId The interface identifier, as specified in ERC-165
   * @dev Interface identification is specified in ERC-165. This function
   * uses less than 30,000 gas.
   */
  function supportsInterface(bytes4 _interfaceId)
    external
    view
    returns (bool);
}

// File: contracts/openzeppelin-solidity/token/ERC721/ERC721Basic.sol

/**
 * @title ERC721 Non-Fungible Token Standard basic interface
 * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
 */
contract ERC721Basic is ERC165 {
  event Transfer(
    address indexed _from,
    address indexed _to,
    uint256 indexed _tokenId
  );
  event Approval(
    address indexed _owner,
    address indexed _approved,
    uint256 indexed _tokenId
  );
  event ApprovalForAll(
    address indexed _owner,
    address indexed _operator,
    bool _approved
  );

  function balanceOf(address _owner) public view returns (uint256 _balance);
  function ownerOf(uint256 _tokenId) public view returns (address _owner);
  function exists(uint256 _tokenId) public view returns (bool _exists);

  function approve(address _to, uint256 _tokenId) public;
  function getApproved(uint256 _tokenId)
    public view returns (address _operator);

  function setApprovalForAll(address _operator, bool _approved) public;
  function isApprovedForAll(address _owner, address _operator)
    public view returns (bool);

  function transferFrom(address _from, address _to, uint256 _tokenId) public;
  function safeTransferFrom(address _from, address _to, uint256 _tokenId)
    public;

  function safeTransferFrom(
    address _from,
    address _to,
    uint256 _tokenId,
    bytes _data
  )
    public;
}

// File: contracts/openzeppelin-solidity/token/ERC721/ERC721.sol

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
 */
contract ERC721Enumerable is ERC721Basic {
  function totalSupply() public view returns (uint256);
  function tokenOfOwnerByIndex(
    address _owner,
    uint256 _index
  )
    public
    view
    returns (uint256 _tokenId);

  function tokenByIndex(uint256 _index) public view returns (uint256);
}


/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
 */
contract ERC721Metadata is ERC721Basic {
  function name() external view returns (string _name);
  function symbol() external view returns (string _symbol);
  function tokenURI(uint256 _tokenId) public view returns (string);
}


/**
 * @title ERC-721 Non-Fungible Token Standard, full implementation interface
 * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
 */
contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata {
}

// File: contracts/openzeppelin-solidity/token/ERC721/ERC721Receiver.sol

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
contract ERC721Receiver {
  /**
   * @dev Magic value to be returned upon successful reception of an NFT
   *  Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`,
   *  which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
   */
  bytes4 internal constant ERC721_RECEIVED = 0x150b7a02;

  /**
   * @notice Handle the receipt of an NFT
   * @dev The ERC721 smart contract calls this function on the recipient
   * after a `safetransfer`. This function MAY throw to revert and reject the
   * transfer. Return of other than the magic value MUST result in the 
   * transaction being reverted.
   * Note: the contract address is always the message sender.
   * @param _operator The address which called `safeTransferFrom` function
   * @param _from The address which previously owned the token
   * @param _tokenId The NFT identifier which is being transfered
   * @param _data Additional data with no specified format
   * @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
   */
  function onERC721Received(
    address _operator,
    address _from,
    uint256 _tokenId,
    bytes _data
  )
    public
    returns(bytes4);
}

// File: contracts/openzeppelin-solidity/math/SafeMath.sol

/**
 * @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;
  }
}

// File: contracts/openzeppelin-solidity/AddressUtils.sol

/**
 * Utility library of inline functions on addresses
 */
library AddressUtils {

  /**
   * Returns whether the target address is a contract
   * @dev This function will return false if invoked during the constructor of a contract,
   * as the code is not actually created until after the constructor finishes.
   * @param addr address to check
   * @return whether the target address is a contract
   */
  function isContract(address addr) internal view returns (bool) {
    uint256 size;
    // XXX Currently there is no better way to check if there is a contract in an address
    // than to check the size of the code at that address.
    // See https://ethereum.stackexchange.com/a/14016/36603
    // for more details about how this works.
    // TODO Check this again before the Serenity release, because all addresses will be
    // contracts then.
    // solium-disable-next-line security/no-inline-assembly
    assembly { size := extcodesize(addr) }
    return size > 0;
  }

}

// File: contracts/openzeppelin-solidity/introspection/SupportsInterfaceWithLookup.sol

/**
 * @title SupportsInterfaceWithLookup
 * @author Matt Condon (@shrugs)
 * @dev Implements ERC165 using a lookup table.
 */
contract SupportsInterfaceWithLookup is ERC165 {
  bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7;
  /**
   * 0x01ffc9a7 ===
   *   bytes4(keccak256('supportsInterface(bytes4)'))
   */

  /**
   * @dev a mapping of interface id to whether or not it's supported
   */
  mapping(bytes4 => bool) internal supportedInterfaces;

  /**
   * @dev A contract implementing SupportsInterfaceWithLookup
   * implement ERC165 itself
   */
  constructor()
    public
  {
    _registerInterface(InterfaceId_ERC165);
  }

  /**
   * @dev implement supportsInterface(bytes4) using a lookup table
   */
  function supportsInterface(bytes4 _interfaceId)
    external
    view
    returns (bool)
  {
    return supportedInterfaces[_interfaceId];
  }

  /**
   * @dev private method for registering an interface
   */
  function _registerInterface(bytes4 _interfaceId)
    internal
  {
    require(_interfaceId != 0xffffffff);
    supportedInterfaces[_interfaceId] = true;
  }
}

// File: contracts/openzeppelin-solidity/token/ERC721/ERC721BasicToken.sol

/**
 * @title ERC721 Non-Fungible Token Standard basic implementation
 * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
 */
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic {

  bytes4 private constant InterfaceId_ERC721 = 0x80ac58cd;
  /*
   * 0x80ac58cd ===
   *   bytes4(keccak256('balanceOf(address)')) ^
   *   bytes4(keccak256('ownerOf(uint256)')) ^
   *   bytes4(keccak256('approve(address,uint256)')) ^
   *   bytes4(keccak256('getApproved(uint256)')) ^
   *   bytes4(keccak256('setApprovalForAll(address,bool)')) ^
   *   bytes4(keccak256('isApprovedForAll(address,address)')) ^
   *   bytes4(keccak256('transferFrom(address,address,uint256)')) ^
   *   bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^
   *   bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)'))
   */

  bytes4 private constant InterfaceId_ERC721Exists = 0x4f558e79;
  /*
   * 0x4f558e79 ===
   *   bytes4(keccak256('exists(uint256)'))
   */

  using SafeMath for uint256;
  using AddressUtils for address;

  // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
  // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
  bytes4 private constant ERC721_RECEIVED = 0x150b7a02;

  // Mapping from token ID to owner
  mapping (uint256 => address) internal tokenOwner;

  // Mapping from token ID to approved address
  mapping (uint256 => address) internal tokenApprovals;

  // Mapping from owner to number of owned token
  mapping (address => uint256) internal ownedTokensCount;

  // Mapping from owner to operator approvals
  mapping (address => mapping (address => bool)) internal operatorApprovals;

  /**
   * @dev Guarantees msg.sender is owner of the given token
   * @param _tokenId uint256 ID of the token to validate its ownership belongs to msg.sender
   */
  modifier onlyOwnerOf(uint256 _tokenId) {
    require(ownerOf(_tokenId) == msg.sender);
    _;
  }

  /**
   * @dev Checks msg.sender can transfer a token, by being owner, approved, or operator
   * @param _tokenId uint256 ID of the token to validate
   */
  modifier canTransfer(uint256 _tokenId) {
    require(isApprovedOrOwner(msg.sender, _tokenId));
    _;
  }

  constructor()
    public
  {
    // register the supported interfaces to conform to ERC721 via ERC165
    _registerInterface(InterfaceId_ERC721);
    _registerInterface(InterfaceId_ERC721Exists);
  }

  /**
   * @dev Gets the balance of the specified address
   * @param _owner address to query the balance of
   * @return uint256 representing the amount owned by the passed address
   */
  function balanceOf(address _owner) public view returns (uint256) {
    require(_owner != address(0));
    return ownedTokensCount[_owner];
  }

  /**
   * @dev Gets the owner of the specified token ID
   * @param _tokenId uint256 ID of the token to query the owner of
   * @return owner address currently marked as the owner of the given token ID
   */
  function ownerOf(uint256 _tokenId) public view returns (address) {
    address owner = tokenOwner[_tokenId];
    require(owner != address(0));
    return owner;
  }

  /**
   * @dev Returns whether the specified token exists
   * @param _tokenId uint256 ID of the token to query the existence of
   * @return whether the token exists
   */
  function exists(uint256 _tokenId) public view returns (bool) {
    address owner = tokenOwner[_tokenId];
    return owner != address(0);
  }

  /**
   * @dev Approves another address to transfer the given token ID
   * The zero address indicates there is no approved address.
   * There can only be one approved address per token at a given time.
   * Can only be called by the token owner or an approved operator.
   * @param _to address to be approved for the given token ID
   * @param _tokenId uint256 ID of the token to be approved
   */
  function approve(address _to, uint256 _tokenId) public {
    address owner = ownerOf(_tokenId);
    require(_to != owner);
    require(msg.sender == owner || isApprovedForAll(owner, msg.sender));

    tokenApprovals[_tokenId] = _to;
    emit Approval(owner, _to, _tokenId);
  }

  /**
   * @dev Gets the approved address for a token ID, or zero if no address set
   * @param _tokenId uint256 ID of the token to query the approval of
   * @return address currently approved for the given token ID
   */
  function getApproved(uint256 _tokenId) public view returns (address) {
    return tokenApprovals[_tokenId];
  }

  /**
   * @dev Sets or unsets the approval of a given operator
   * An operator is allowed to transfer all tokens of the sender on their behalf
   * @param _to operator address to set the approval
   * @param _approved representing the status of the approval to be set
   */
  function setApprovalForAll(address _to, bool _approved) public {
    require(_to != msg.sender);
    operatorApprovals[msg.sender][_to] = _approved;
    emit ApprovalForAll(msg.sender, _to, _approved);
  }

  /**
   * @dev Tells whether an operator is approved by a given owner
   * @param _owner owner address which you want to query the approval of
   * @param _operator operator address which you want to query the approval of
   * @return bool whether the given operator is approved by the given owner
   */
  function isApprovedForAll(
    address _owner,
    address _operator
  )
    public
    view
    returns (bool)
  {
    return operatorApprovals[_owner][_operator];
  }

  /**
   * @dev Transfers the ownership of a given token ID to another address
   * Usage of this method is discouraged, use `safeTransferFrom` whenever possible
   * Requires the msg sender to be the owner, approved, or operator
   * @param _from current owner of the token
   * @param _to address to receive the ownership of the given token ID
   * @param _tokenId uint256 ID of the token to be transferred
  */
  function transferFrom(
    address _from,
    address _to,
    uint256 _tokenId
  )
    public
    canTransfer(_tokenId)
  {
    require(_from != address(0));
    require(_to != address(0));

    clearApproval(_from, _tokenId);
    removeTokenFrom(_from, _tokenId);
    addTokenTo(_to, _tokenId);

    emit Transfer(_from, _to, _tokenId);
  }

  /**
   * @dev Safely transfers the ownership of a given token ID to another address
   * If the target address is a contract, it must implement `onERC721Received`,
   * which is called upon a safe transfer, and return the magic value
   * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,
   * the transfer is reverted.
   *
   * Requires the msg sender to be the owner, approved, or operator
   * @param _from current owner of the token
   * @param _to address to receive the ownership of the given token ID
   * @param _tokenId uint256 ID of the token to be transferred
  */
  function safeTransferFrom(
    address _from,
    address _to,
    uint256 _tokenId
  )
    public
    canTransfer(_tokenId)
  {
    // solium-disable-next-line arg-overflow
    safeTransferFrom(_from, _to, _tokenId, "");
  }

  /**
   * @dev Safely transfers the ownership of a given token ID to another address
   * If the target address is a contract, it must implement `onERC721Received`,
   * which is called upon a safe transfer, and return the magic value
   * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,
   * the transfer is reverted.
   * Requires the msg sender to be the owner, approved, or operator
   * @param _from current owner of the token
   * @param _to address to receive the ownership of the given token ID
   * @param _tokenId uint256 ID of the token to be transferred
   * @param _data bytes data to send along with a safe transfer check
   */
  function safeTransferFrom(
    address _from,
    address _to,
    uint256 _tokenId,
    bytes _data
  )
    public
    canTransfer(_tokenId)
  {
    transferFrom(_from, _to, _tokenId);
    // solium-disable-next-line arg-overflow
    require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data));
  }

  /**
   * @dev Returns whether the given spender can transfer a given token ID
   * @param _spender address of the spender to query
   * @param _tokenId uint256 ID of the token to be transferred
   * @return bool whether the msg.sender is approved for the given token ID,
   *  is an operator of the owner, or is the owner of the token
   */
  function isApprovedOrOwner(
    address _spender,
    uint256 _tokenId
  )
    internal
    view
    returns (bool)
  {
    address owner = ownerOf(_tokenId);
    // Disable solium check because of
    // https://github.com/duaraghav8/Solium/issues/175
    // solium-disable-next-line operator-whitespace
    return (
      _spender == owner ||
      getApproved(_tokenId) == _spender ||
      isApprovedForAll(owner, _spender)
    );
  }

  /**
   * @dev Internal function to mint a new token
   * Reverts if the given token ID already exists
   * @param _to The address that will own the minted token
   * @param _tokenId uint256 ID of the token to be minted by the msg.sender
   */
  function _mint(address _to, uint256 _tokenId) internal {
    require(_to != address(0));
    addTokenTo(_to, _tokenId);
    emit Transfer(address(0), _to, _tokenId);
  }

  /**
   * @dev Internal function to burn a specific token
   * Reverts if the token does not exist
   * @param _tokenId uint256 ID of the token being burned by the msg.sender
   */
  function _burn(address _owner, uint256 _tokenId) internal {
    clearApproval(_owner, _tokenId);
    removeTokenFrom(_owner, _tokenId);
    emit Transfer(_owner, address(0), _tokenId);
  }

  /**
   * @dev Internal function to clear current approval of a given token ID
   * Reverts if the given address is not indeed the owner of the token
   * @param _owner owner of the token
   * @param _tokenId uint256 ID of the token to be transferred
   */
  function clearApproval(address _owner, uint256 _tokenId) internal {
    require(ownerOf(_tokenId) == _owner);
    if (tokenApprovals[_tokenId] != address(0)) {
      tokenApprovals[_tokenId] = address(0);
    }
  }

  /**
   * @dev Internal function to add a token ID to the list of a given address
   * @param _to address representing the new owner of the given token ID
   * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address
   */
  function addTokenTo(address _to, uint256 _tokenId) internal {
    require(tokenOwner[_tokenId] == address(0));
    tokenOwner[_tokenId] = _to;
    ownedTokensCount[_to] = ownedTokensCount[_to].add(1);
  }

  /**
   * @dev Internal function to remove a token ID from the list of a given address
   * @param _from address representing the previous owner of the given token ID
   * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address
   */
  function removeTokenFrom(address _from, uint256 _tokenId) internal {
    require(ownerOf(_tokenId) == _from);
    ownedTokensCount[_from] = ownedTokensCount[_from].sub(1);
    tokenOwner[_tokenId] = address(0);
  }

  /**
   * @dev Internal function to invoke `onERC721Received` on a target address
   * The call is not executed if the target address is not a contract
   * @param _from address representing the previous owner of the given token ID
   * @param _to target address that will receive the tokens
   * @param _tokenId uint256 ID of the token to be transferred
   * @param _data bytes optional data to send along with the call
   * @return whether the call correctly returned the expected magic value
   */
  function checkAndCallSafeTransfer(
    address _from,
    address _to,
    uint256 _tokenId,
    bytes _data
  )
    internal
    returns (bool)
  {
    if (!_to.isContract()) {
      return true;
    }
    bytes4 retval = ERC721Receiver(_to).onERC721Received(
      msg.sender, _from, _tokenId, _data);
    return (retval == ERC721_RECEIVED);
  }
}

// File: contracts/openzeppelin-solidity/token/ERC721/ERC721Token.sol

/**
 * @title Full ERC721 Token
 * This implementation includes all the required and some optional functionality of the ERC721 standard
 * Moreover, it includes approve all functionality using operator terminology
 * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
 */
contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 {

  bytes4 private constant InterfaceId_ERC721Enumerable = 0x780e9d63;
  /**
   * 0x780e9d63 ===
   *   bytes4(keccak256('totalSupply()')) ^
   *   bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^
   *   bytes4(keccak256('tokenByIndex(uint256)'))
   */

  bytes4 private constant InterfaceId_ERC721Metadata = 0x5b5e139f;
  /**
   * 0x5b5e139f ===
   *   bytes4(keccak256('name()')) ^
   *   bytes4(keccak256('symbol()')) ^
   *   bytes4(keccak256('tokenURI(uint256)'))
   */

  // Token name
  string internal name_;

  // Token symbol
  string internal symbol_;

  // Mapping from owner to list of owned token IDs
  mapping(address => uint256[]) internal ownedTokens;

  // Mapping from token ID to index of the owner tokens list
  mapping(uint256 => uint256) internal ownedTokensIndex;

  // Array with all token ids, used for enumeration
  uint256[] internal allTokens;

  // Mapping from token id to position in the allTokens array
  mapping(uint256 => uint256) internal allTokensIndex;

  // Optional mapping for token URIs
  mapping(uint256 => string) internal tokenURIs;

  /**
   * @dev Constructor function
   */
  constructor(string _name, string _symbol) public {
    name_ = _name;
    symbol_ = _symbol;

    // register the supported interfaces to conform to ERC721 via ERC165
    _registerInterface(InterfaceId_ERC721Enumerable);
    _registerInterface(InterfaceId_ERC721Metadata);
  }

  /**
   * @dev Gets the token name
   * @return string representing the token name
   */
  function name() external view returns (string) {
    return name_;
  }

  /**
   * @dev Gets the token symbol
   * @return string representing the token symbol
   */
  function symbol() external view returns (string) {
    return symbol_;
  }

  /**
   * @dev Returns an URI for a given token ID
   * Throws if the token ID does not exist. May return an empty string.
   * @param _tokenId uint256 ID of the token to query
   */
  function tokenURI(uint256 _tokenId) public view returns (string) {
    require(exists(_tokenId));
    return tokenURIs[_tokenId];
  }

  /**
   * @dev Gets the token ID at a given index of the tokens list of the requested owner
   * @param _owner address owning the tokens list to be accessed
   * @param _index uint256 representing the index to be accessed of the requested tokens list
   * @return uint256 token ID at the given index of the tokens list owned by the requested address
   */
  function tokenOfOwnerByIndex(
    address _owner,
    uint256 _index
  )
    public
    view
    returns (uint256)
  {
    require(_index < balanceOf(_owner));
    return ownedTokens[_owner][_index];
  }

  /**
   * @dev Gets the total amount of tokens stored by the contract
   * @return uint256 representing the total amount of tokens
   */
  function totalSupply() public view returns (uint256) {
    return allTokens.length;
  }

  /**
   * @dev Gets the token ID at a given index of all the tokens in this contract
   * Reverts if the index is greater or equal to the total number of tokens
   * @param _index uint256 representing the index to be accessed of the tokens list
   * @return uint256 token ID at the given index of the tokens list
   */
  function tokenByIndex(uint256 _index) public view returns (uint256) {
    require(_index < totalSupply());
    return allTokens[_index];
  }

  /**
   * @dev Internal function to set the token URI for a given token
   * Reverts if the token ID does not exist
   * @param _tokenId uint256 ID of the token to set its URI
   * @param _uri string URI to assign
   */
  function _setTokenURI(uint256 _tokenId, string _uri) internal {
    require(exists(_tokenId));
    tokenURIs[_tokenId] = _uri;
  }

  /**
   * @dev Internal function to add a token ID to the list of a given address
   * @param _to address representing the new owner of the given token ID
   * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address
   */
  function addTokenTo(address _to, uint256 _tokenId) internal {
    super.addTokenTo(_to, _tokenId);
    uint256 length = ownedTokens[_to].length;
    ownedTokens[_to].push(_tokenId);
    ownedTokensIndex[_tokenId] = length;
  }

  /**
   * @dev Internal function to remove a token ID from the list of a given address
   * @param _from address representing the previous owner of the given token ID
   * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address
   */
  function removeTokenFrom(address _from, uint256 _tokenId) internal {
    super.removeTokenFrom(_from, _tokenId);

    uint256 tokenIndex = ownedTokensIndex[_tokenId];
    uint256 lastTokenIndex = ownedTokens[_from].length.sub(1);
    uint256 lastToken = ownedTokens[_from][lastTokenIndex];

    ownedTokens[_from][tokenIndex] = lastToken;
    ownedTokens[_from][lastTokenIndex] = 0;
    // Note that this will handle single-element arrays. In that case, both tokenIndex and lastTokenIndex are going to
    // be zero. Then we can make sure that we will remove _tokenId from the ownedTokens list since we are first swapping
    // the lastToken to the first position, and then dropping the element placed in the last position of the list

    ownedTokens[_from].length--;
    ownedTokensIndex[_tokenId] = 0;
    ownedTokensIndex[lastToken] = tokenIndex;
  }

  /**
   * @dev Internal function to mint a new token
   * Reverts if the given token ID already exists
   * @param _to address the beneficiary that will own the minted token
   * @param _tokenId uint256 ID of the token to be minted by the msg.sender
   */
  function _mint(address _to, uint256 _tokenId) internal {
    super._mint(_to, _tokenId);

    allTokensIndex[_tokenId] = allTokens.length;
    allTokens.push(_tokenId);
  }

  /**
   * @dev Internal function to burn a specific token
   * Reverts if the token does not exist
   * @param _owner owner of the token to burn
   * @param _tokenId uint256 ID of the token being burned by the msg.sender
   */
  function _burn(address _owner, uint256 _tokenId) internal {
    super._burn(_owner, _tokenId);

    // Clear metadata (if any)
    if (bytes(tokenURIs[_tokenId]).length != 0) {
      delete tokenURIs[_tokenId];
    }

    // Reorg all tokens array
    uint256 tokenIndex = allTokensIndex[_tokenId];
    uint256 lastTokenIndex = allTokens.length.sub(1);
    uint256 lastToken = allTokens[lastTokenIndex];

    allTokens[tokenIndex] = lastToken;
    allTokens[lastTokenIndex] = 0;

    allTokens.length--;
    allTokensIndex[_tokenId] = 0;
    allTokensIndex[lastToken] = tokenIndex;
  }

}

// File: contracts/openzeppelin-solidity/ownership/Ownable.sol

/**
 * @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;
  }
}

// File: contracts/ERC721TokenWithData.sol

// import "./ERC721SlimTokenArray.sol";



// an ERC721 token with additional data storage,
contract ERC721TokenWithData is ERC721Token("CryptoAssaultUnit", "CAU"), Ownable {

  /**
   * @dev Returns whether the given spender can transfer a given token ID
   * @param _spender address of the spender to query
   * @param _tokenId uint256 ID of the token to be transferred
   * @return bool whether the msg.sender is approved for the given token ID,
   *  is an operator of the owner, or is the owner of the token
   */
	function isApprovedOrOwner(
		address _spender,
		uint256 _tokenId
	)
		internal
		view
		returns (bool)
	{
		address owner = ownerOf(_tokenId);
		// Disable solium check because of
		// https://github.com/duaraghav8/Solium/issues/175
		// solium-disable-next-line operator-whitespace
		return (
			_spender == owner ||
			approvedContractAddresses[_spender] ||
			getApproved(_tokenId) == _spender ||
			isApprovedForAll(owner, _spender)
		);
	}

	mapping (address => bool) internal approvedContractAddresses;
	bool approvedContractsFinalized = false;

	/**
	* @notice Approve a contract address for minting tokens and transferring tokens, when approved by the owner
	* @param contractAddress The address that will be approved
	*/
	function addApprovedContractAddress(address contractAddress) public onlyOwner
	{
		require(!approvedContractsFinalized);
		approvedContractAddresses[contractAddress] = true;
	}

	/**
	* @notice Unapprove a contract address for minting tokens and transferring tokens
	* @param contractAddress The address that will be unapproved
	*/
	function removeApprovedContractAddress(address contractAddress) public onlyOwner
	{
		require(!approvedContractsFinalized);
		approvedContractAddresses[contractAddress] = false;
	}

	/**
	* @notice Finalize the contract so it will be forever impossible to change the approved contracts list
	*/
	function finalizeApprovedContracts() public onlyOwner {
		approvedContractsFinalized = true;
	}

	mapping(uint256 => mapping(uint256 => uint256)) data;

	function getData(uint256 _tokenId, uint256 _index) public view returns (uint256) {
		return data[_index][_tokenId];
	}

	function getData3(uint256 _tokenId1, uint256 _tokenId2, uint256 _tokenId3, uint256 _index) public view returns (uint256, uint256, uint256) {
		return (
			data[_index][_tokenId1],
			data[_index][_tokenId2],
			data[_index][_tokenId3]
		);
	}
	
	function getDataAndOwner3(uint256 _tokenId1, uint256 _tokenId2, uint256 _tokenId3, uint256 _index) public view returns (uint256, uint256, uint256, address, address, address) {
		return (
			data[_index][_tokenId1],
			data[_index][_tokenId2],
			data[_index][_tokenId3],
			ownerOf(_tokenId1),
			ownerOf(_tokenId2),
			ownerOf(_tokenId3)
		);
	}
	
	function _setData(uint256 _tokenId, uint256 _index, uint256 _data) internal {
		
		data[_index][_tokenId] = _data;
	}

	function setData(uint256 _tokenId, uint256 _index, uint256 _data) public {
		
		require(approvedContractAddresses[msg.sender], "not an approved sender");
		data[_index][_tokenId] = _data;
	}

	/**
	* @notice Gets the list of tokens owned by a given address
	* @param _owner address to query the tokens of
	* @return uint256[] representing the list of tokens owned by the passed address
	*/
	function tokensOfWithData(address _owner, uint256 _index) public view returns (uint256[], uint256[]) {
		uint256[] memory tokensList = ownedTokens[_owner];
		uint256[] memory dataList = new uint256[](tokensList.length);
		for (uint i=0; i<tokensList.length; i++) {
			dataList[i] = data[_index][tokensList[i]];
		}
		return (tokensList, dataList);
	}

	// The tokenId of the next minted token. It auto-increments.
	uint256 nextTokenId = 1;

	function getNextTokenId() public view returns (uint256) {
		return nextTokenId;
	}

	/**
	* @notice Mint token function
	* @param _to The address that will own the minted token
	*/
	function mintAndSetData(address _to, uint256 _data) public returns (uint256) {

		require(approvedContractAddresses[msg.sender], "not an approved sender");

		uint256 tokenId = nextTokenId;
		nextTokenId++;
		_mint(_to, tokenId);
		_setData(tokenId, 0, _data);

		return tokenId;
	}

	function burn(uint256 _tokenId) public {
		require(
			approvedContractAddresses[msg.sender] ||
			msg.sender == owner, "burner not approved"
		);

		_burn(ownerOf(_tokenId), _tokenId);
	}
	
	function burn3(uint256 _tokenId1, uint256 _tokenId2, uint256 _tokenId3) public {
		require(
			approvedContractAddresses[msg.sender] ||
			msg.sender == owner, "burner not approved"
		);

		_burn(ownerOf(_tokenId1), _tokenId1);
		_burn(ownerOf(_tokenId2), _tokenId2);
		_burn(ownerOf(_tokenId3), _tokenId3);
	}
}

// File: contracts/strings/Strings.sol

library Strings {
  // via https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.5.sol
  function strConcat(string _a, string _b, string _c, string _d, string _e) internal pure returns (string) {
      bytes memory _ba = bytes(_a);
      bytes memory _bb = bytes(_b);
      bytes memory _bc = bytes(_c);
      bytes memory _bd = bytes(_d);
      bytes memory _be = bytes(_e);
      string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length);
      bytes memory babcde = bytes(abcde);
      uint k = 0;
      for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i];
      for (i = 0; i < _bb.length; i++) babcde[k++] = _bb[i];
      for (i = 0; i < _bc.length; i++) babcde[k++] = _bc[i];
      for (i = 0; i < _bd.length; i++) babcde[k++] = _bd[i];
      for (i = 0; i < _be.length; i++) babcde[k++] = _be[i];
      return string(babcde);
    }

    function strConcat(string _a, string _b, string _c, string _d) internal pure returns (string) {
        return strConcat(_a, _b, _c, _d, "");
    }

    function strConcat(string _a, string _b, string _c) internal pure returns (string) {
        return strConcat(_a, _b, _c, "", "");
    }

    function strConcat(string _a, string _b) internal pure returns (string) {
        return strConcat(_a, _b, "", "", "");
    }

    function uint2str(uint i) internal pure returns (string) {
        if (i == 0) return "0";
        uint j = i;
        uint len;
        while (j != 0){
            len++;
            j /= 10;
        }
        bytes memory bstr = new bytes(len);
        uint k = len - 1;
        while (i != 0){
            bstr[k--] = byte(48 + i % 10);
            i /= 10;
        }
        return string(bstr);
    }
}

// File: contracts/Token.sol

contract Token is ERC721TokenWithData {

	string metadataUrlPrefix = "https://api.cryptoassault.io/unit/";

	/**
	* @dev Returns an URI for a given token ID
	* Throws if the token ID does not exist. May return an empty string.
	* @param _tokenId uint256 ID of the token to query
	*/
	function tokenURI(uint256 _tokenId) public view returns (string) {
		require(exists(_tokenId));
		return Strings.strConcat(metadataUrlPrefix, Strings.uint2str(_tokenId));
	}

	function setMetadataUrlPrefix(string _metadataUrlPrefix) public onlyOwner
	{
		metadataUrlPrefix = _metadataUrlPrefix;
	}
}

// File: contracts/openzeppelin-solidity/lifecycle/Pausable.sol

/**
 * @title Pausable
 * @dev Base contract which allows children to implement an emergency stop mechanism.
 */
contract Pausable is Ownable {
  event Pause();
  event Unpause();

  bool public paused = false;


  /**
   * @dev Modifier to make a function callable only when the contract is not paused.
   */
  modifier whenNotPaused() {
    require(!paused);
    _;
  }

  /**
   * @dev Modifier to make a function callable only when the contract is paused.
   */
  modifier whenPaused() {
    require(paused);
    _;
  }

  /**
   * @dev called by the owner to pause, triggers stopped state
   */
  function pause() onlyOwner whenNotPaused public {
    paused = true;
    emit Pause();
  }

  /**
   * @dev called by the owner to unpause, returns to normal state
   */
  function unpause() onlyOwner whenPaused public {
    paused = false;
    emit Unpause();
  }
}

// File: contracts/GachaSale.sol

contract GachaSale is Pausable {

	event Sold(address buyer, uint256 amount, uint256 totalPrice);
	event Hatched(address buyer, uint256 amount);

	uint256 constant PRESALE_START_TIME = 1541628000; //TODO: put in a real time.
	uint256 constant NUM_UNIT_TYPES = 30;

	Token token;

	function setTokenContractAddress(address newAddress) onlyOwner public {
		token = Token(newAddress);
	}
	
	// this is a continuously rotating FIFO.
	// to delete the first item, increment firstIndex,
	// mod by MAX_WAITING_TO_HATCH_ENTRIES,
	// and decrement num.
	struct WaitingToHatch {
		address owner;
		uint32 amount;
		uint16 rarity;
		uint16 sku;
		uint32 purchasedOnBlockNumber;
	}
	uint64 constant MAX_WAITING_TO_HATCH_ENTRIES = 256;
	WaitingToHatch[MAX_WAITING_TO_HATCH_ENTRIES] waitingToHatch;

	uint64 waitingToHatchFirstIndex;
	uint64 waitingToHatchNum;
	uint64 hatchNonce = 1;

	// maps amount to a price.
	mapping(uint256 => uint256) prices;

	uint256 constant NUM_RARITIES = 4;
	
	constructor() public {
	// 	// temp, to test gas prices after some usage.
	// 	for (uint256 i=0; i<MAX_WAITING_TO_HATCH_ENTRIES; i++) {
	// 		waitingToHatch[i].amount = 1;
	// 	}
	}
	
	function withdrawBalance() onlyOwner public {
		owner.transfer(address(this).balance);
	}

	function setPrice(uint32 sku, uint64 price) public onlyOwner {
		prices[sku] = price;
	}

	function getPrice(uint32 sku) public view returns (uint256)
	{
		require(now >= PRESALE_START_TIME, "The sale hasn't started yet");

		uint256 price = prices[sku];
		require (price > 0);

		// Apply the pre-sale discount
		uint256 intervalsSinceSaleStarted = (now - PRESALE_START_TIME) / (1 hours);
		// The discount starts at 30% and goes down 1% every 2 days.
		uint256 pricePercentage = 70 + intervalsSinceSaleStarted;
		if (pricePercentage < 100) {
			price = (price * pricePercentage) / 100;
		}

		return price;
	}

	function pushHatch(address to, uint32 amount, uint16 rarity, uint16 sku) private {

		require(waitingToHatchNum < MAX_WAITING_TO_HATCH_ENTRIES, "There are too many hatching gachas. Wait a bit.");

		uint256 index = waitingToHatchFirstIndex + waitingToHatchNum;
		index = index % MAX_WAITING_TO_HATCH_ENTRIES;
		waitingToHatch[index] = WaitingToHatch(to, amount, rarity, sku, uint32(block.number));
		waitingToHatchNum = waitingToHatchNum + 1;
	}

	function popHatch() private {

		waitingToHatchNum = waitingToHatchNum - 1;
		waitingToHatchFirstIndex = (waitingToHatchFirstIndex + 1) % MAX_WAITING_TO_HATCH_ENTRIES;
	}

	function peekHatch() private view returns (WaitingToHatch) {

		return waitingToHatch[waitingToHatchFirstIndex];
	}

	function buy(uint16 sku, address referral) external payable whenNotPaused {

		uint256 price = getPrice(sku);
		require(msg.value >= price, "Amount paid is too low");

		// push the purchase onto a FIFO, to be minted in a later transaction.

		if (sku == 1) {
			pushHatch(msg.sender, 1, 0, sku); // 1 common or better
		} else if (sku == 2) {
			pushHatch(msg.sender, 5, 0, sku); // 5 common or better
		} else if (sku == 3) {
			pushHatch(msg.sender, 10, 1, sku);  // 10 rare or better
		} else if (sku == 4) {
			// 50 common or better
			pushHatch(msg.sender, 10, 0, sku);
			pushHatch(msg.sender, 10, 0, sku);
			pushHatch(msg.sender, 10, 0, sku);
			pushHatch(msg.sender, 10, 0, sku);
			pushHatch(msg.sender, 10, 0, sku);
		} else if (sku == 5) {
			// 47 rare or better
			pushHatch(msg.sender, 10, 1, sku);
			pushHatch(msg.sender, 10, 1, sku);
			pushHatch(msg.sender, 10, 1, sku);
			pushHatch(msg.sender, 10, 1, sku);
			pushHatch(msg.sender, 7, 1, sku);
			// 3 epic or better
			pushHatch(msg.sender, 3, 2, sku);
		} else {
			require(false, "Invalid sku");
		}

		// Pay the referral 5%
		if (referral != address(0)) {
			referral.transfer(price / 20);
		}

		emit Sold(msg.sender, sku, price);
	}

	function giveFreeUnit(address to, uint16 minRarity) onlyOwner public
	{
		pushHatch(to, 1, minRarity, 0);
	}

	function getNumMyHatchingUnits() public view returns (uint256) {
		uint256 num = 0;
		for (uint256 i=waitingToHatchFirstIndex; i<waitingToHatchFirstIndex + waitingToHatchNum; i++) {
			uint256 indexModded = i % MAX_WAITING_TO_HATCH_ENTRIES;
			if (waitingToHatch[indexModded].owner == msg.sender) {
				num += waitingToHatch[indexModded].amount;
			}
		}
		return num;
	}

	function hatchingsNeeded() external view returns (uint256) {

		return waitingToHatchNum;
	}
	
	function getProjectedBlockHash(uint256 blockNumber) internal view returns (uint256) {

		uint256 blockToHash = blockNumber;
		uint256 blocksAgo = block.number - blockToHash;
		if (blocksAgo > 256) {
			blockToHash += (blocksAgo / 256) * 256;
		}
		return uint256(blockhash(blockToHash));
	}

	function getRandomType(uint16 rand) internal pure returns (uint8)
	{
		return uint8(rand % NUM_UNIT_TYPES);
	}
 
	function getRandomRarity(uint32 rand, uint256 minimumRarity) internal pure returns (uint256)
	{

		uint256 rarityRand;
		if (minimumRarity == 0) {
			rarityRand = rand % 100;
		} else if (minimumRarity == 1) {
			rarityRand = rand % 20 + 80;
		} else if (minimumRarity == 2) {
			rarityRand = rand % 5 + 95;
		} else if (minimumRarity == 3) {
			rarityRand = 99;
		} else {
			require(false, "Invalid minimumRarity");
		}

		if (rarityRand < 80) return 0;
		if (rarityRand < 95) return 1;
		if (rarityRand < 99) return 2;
		return 3;
	}

	function hatch() external whenNotPaused {

		require(waitingToHatchNum > 0, "nothing to hatch");

		WaitingToHatch memory w = peekHatch();
		
		// can't hatch on the same block. its block hash would be unknown.
		require (w.purchasedOnBlockNumber < block.number, "Can't hatch on the same block.");

		uint256 rand = getProjectedBlockHash(w.purchasedOnBlockNumber) + hatchNonce;

		for (uint256 i=0; i<w.amount; i++) {
			rand = uint256(keccak256(abi.encodePacked(rand)));
			uint256 thisRand = rand;
			uint8 unitType = getRandomType(uint16(thisRand));
			thisRand >>= 16;

			uint256 rarity = getRandomRarity(uint32(thisRand), w.rarity);
			thisRand >>= 32;

			// TPRDATEDARSKRANDOM__RANDOM__RANDOM__RANDOM__RAND0000000000000000

			uint256 data = unitType; // 8 bits

			data <<= 4;
			// data |= 0; // tier 0

			// birth timestamp
			data <<= 24;
			data |= now / (1 days);

			data <<= 4;
			data |= rarity;
			data <<= 8;
			data |= w.sku;
			data <<= 208;
			data |= thisRand & 0xffffffffffffffffffffffffffffffffffff0000000000000000;

			token.mintAndSetData(w.owner, data);
		}

		popHatch();

		hatchNonce++;

		emit Hatched(w.owner, w.amount);
	}

}

Contract ABI
[{"constant":true,"inputs":[],"name":"hatchingsNeeded","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"withdrawBalance","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getNumMyHatchingUnits","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"minRarity","type":"uint16"}],"name":"giveFreeUnit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"pause","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":"sku","type":"uint32"},{"name":"price","type":"uint64"}],"name":"setPrice","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newAddress","type":"address"}],"name":"setTokenContractAddress","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"hatch","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"sku","type":"uint32"}],"name":"getPrice","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"sku","type":"uint16"},{"name":"referral","type":"address"}],"name":"buy","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"buyer","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"totalPrice","type":"uint256"}],"name":"Sold","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"buyer","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"Hatched","type":"event"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","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
60806040526000805460a060020a60ff02191690556101028054608060020a60c060020a03191670010000000000000000000000000000000017905534801561004757600080fd5b5060008054600160a060020a03191633179055611284806100696000396000f3006080604052600436106100c15763ffffffff60e060020a6000350416633e3d64e281146100c65780633f4ba83a146100ed5780635c975abb146101045780635fd8c7101461012d57806366b567da14610142578063715018a614610157578063819abe801461016c5780638456cb59146101945780638da5cb5b146101a957806398764f22146101da578063b23d485414610205578063d0db508314610226578063da26663a1461023b578063e4bdaa6114610259578063f2fde38b14610274575b600080fd5b3480156100d257600080fd5b506100db610295565b60408051918252519081900360200190f35b3480156100f957600080fd5b506101026102b2565b005b34801561011057600080fd5b50610119610328565b604080519115158252519081900360200190f35b34801561013957600080fd5b50610102610338565b34801561014e57600080fd5b506100db61038d565b34801561016357600080fd5b50610102610428565b34801561017857600080fd5b50610102600160a060020a036004351661ffff60243516610494565b3480156101a057600080fd5b506101026104bd565b3480156101b557600080fd5b506101be610538565b60408051600160a060020a039092168252519081900360200190f35b3480156101e657600080fd5b5061010263ffffffff6004351667ffffffffffffffff60243516610547565b34801561021157600080fd5b50610102600160a060020a0360043516610585565b34801561023257600080fd5b506101026105cb565b34801561024757600080fd5b506100db63ffffffff600435166109a0565b61010261ffff60043516600160a060020a0360243516610a52565b34801561028057600080fd5b50610102600160a060020a0360043516610cbc565b6101025468010000000000000000900467ffffffffffffffff1690565b600054600160a060020a031633146102c957600080fd5b60005460a060020a900460ff1615156102e157600080fd5b6000805474ff0000000000000000000000000000000000000000191681556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b339190a1565b60005460a060020a900460ff1681565b600054600160a060020a0316331461034f57600080fd5b60008054604051600160a060020a0390911691303180156108fc02929091818181858888f1935050505015801561038a573d6000803e3d6000fd5b50565b61010254600090819067ffffffffffffffff16815b6101025467ffffffffffffffff8082166801000000000000000090920481169190910116821015610420575060ff81163360028261010081106103e157fe5b0154600160a060020a0316141561041557600281610100811061040057fe5b015460a060020a900463ffffffff1692909201915b6001909101906103a2565b509092915050565b600054600160a060020a0316331461043f57600080fd5b60008054604051600160a060020a03909116917ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482091a26000805473ffffffffffffffffffffffffffffffffffffffff19169055565b600054600160a060020a031633146104ab57600080fd5b6104b9826001836000610cdc565b5050565b600054600160a060020a031633146104d457600080fd5b60005460a060020a900460ff16156104eb57600080fd5b6000805474ff0000000000000000000000000000000000000000191660a060020a1781556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff6259190a1565b600054600160a060020a031681565b600054600160a060020a0316331461055e57600080fd5b63ffffffff90911660009081526101036020526040902067ffffffffffffffff9091169055565b600054600160a060020a0316331461059c57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6105d361122a565b600080600080600080600060149054906101000a900460ff161515156105f857600080fd5b6101025460006801000000000000000090910467ffffffffffffffff161161066a576040805160e560020a62461bcd02815260206004820152601060248201527f6e6f7468696e6720746f20686174636800000000000000000000000000000000604482015290519081900360640190fd5b610672610f64565b965043876080015163ffffffff161015156106d7576040805160e560020a62461bcd02815260206004820152601e60248201527f43616e2774206861746368206f6e207468652073616d6520626c6f636b2e0000604482015290519081900360640190fd5b61010260109054906101000a900467ffffffffffffffff1667ffffffffffffffff1661070c886080015163ffffffff16611016565b019550600094505b866020015163ffffffff168510156108ee5785604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b602083106107755780518252601f199092019160209182019101610756565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206001900495508593506107b48461103d565b604088015162010000909504949093506107d390859061ffff1661104a565b60608801516001548951604080517f6b3559e1000000000000000000000000000000000000000000000000000000008152600160a060020a039283166004820152631000000060ff8a16026201518042041760100286176101000261ffff909516949094177a0100000000000000000000000000000000000000000000000000000264010000000090990479ffffffffffffffffffffffffffffffffffff000000000000000081169990991760248501819052905194965094501691636b3559e1916044808201926020929091908290030181600087803b1580156108b757600080fd5b505af11580156108cb573d6000803e3d6000fd5b505050506040513d60208110156108e157600080fd5b5050600190940193610714565b6108f6611154565b6101028054600167ffffffffffffffff700100000000000000000000000000000000808404821692909201160277ffffffffffffffff0000000000000000000000000000000019909116179055865160208089015160408051600160a060020a03909416845263ffffffff9091169183019190915280517f226357a480bcab31fbd8f2663fe2a14c625d8bab5c1cc23f15afe0b914732cdf9281900390910190a150505050505050565b6000808080635be36060421015610a01576040805160e560020a62461bcd02815260206004820152601b60248201527f5468652073616c65206861736e27742073746172746564207965740000000000604482015290519081900360640190fd5b63ffffffff85166000908152610103602052604081205493508311610a2557600080fd5b5050610e1042635be3605f190104604681016064811015610a495760648382020492505b50909392505050565b6000805460a060020a900460ff1615610a6a57600080fd5b610a778361ffff166109a0565b905034811115610ad1576040805160e560020a62461bcd02815260206004820152601660248201527f416d6f756e74207061696420697320746f6f206c6f7700000000000000000000604482015290519081900360640190fd5b8261ffff1660011415610af157610aec336001600086610cdc565b610c2b565b8261ffff1660021415610b0c57610aec336005600086610cdc565b8261ffff1660031415610b2757610aec33600a600186610cdc565b8261ffff1660041415610b7a57610b4233600a600086610cdc565b610b5033600a600086610cdc565b610b5e33600a600086610cdc565b610b6c33600a600086610cdc565b610aec33600a600086610cdc565b8261ffff1660051415610bdb57610b9533600a600186610cdc565b610ba333600a600186610cdc565b610bb133600a600186610cdc565b610bbf33600a600186610cdc565b610bcd336007600186610cdc565b610aec336003600286610cdc565b6040805160e560020a62461bcd02815260206004820152600b60248201527f496e76616c696420736b75000000000000000000000000000000000000000000604482015290519081900360640190fd5b600160a060020a03821615610c7457604051600160a060020a038316906014830480156108fc02916000818181858888f19350505050158015610c72573d6000803e3d6000fd5b505b6040805133815261ffff8516602082015280820183905290517fbac9694ac0daa55169abd117086fe32c89401d9a3b15dd1d34e55e0aa4e47a9d9181900360600190a1505050565b600054600160a060020a03163314610cd357600080fd5b61038a816111ad565b610102546000906101006801000000000000000090910467ffffffffffffffff1610610d78576040805160e560020a62461bcd02815260206004820152602f60248201527f54686572652061726520746f6f206d616e79206861746368696e67206761636860448201527f61732e20576169742061206269742e0000000000000000000000000000000000606482015290519081900360840190fd5b506101025467ffffffffffffffff80821668010000000000000000909204811691909101166101008106905060a06040519081016040528086600160a060020a031681526020018563ffffffff1681526020018461ffff1681526020018361ffff1681526020014363ffffffff1681525060028261010081101515610df957fe5b82519101805460208401516040850151606086015160809096015173ffffffffffffffffffffffffffffffffffffffff19909316600160a060020a039095169490941777ffffffff0000000000000000000000000000000000000000191660a060020a63ffffffff928316021779ffff0000000000000000000000000000000000000000000000001916780100000000000000000000000000000000000000000000000061ffff95861602177fffffffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffff167a0100000000000000000000000000000000000000000000000000009490951693909302939093177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1660e060020a9290931691909102919091179055505061010280546fffffffffffffffff0000000000000000198116680100000000000000009182900467ffffffffffffffff90811660010116909102179055505050565b610f6c61122a565b6101025460029067ffffffffffffffff166101008110610f8857fe5b6040805160a0810182529290910154600160a060020a038116835263ffffffff60a060020a82048116602085015261ffff780100000000000000000000000000000000000000000000000083048116938501939093527a0100000000000000000000000000000000000000000000000000008204909216606084015260e060020a9004166080820152905090565b6000814381900361010081111561103557610100810461010002820191505b504092915050565b601e61ffff919091160690565b60008082151561106b57606463ffffffff85160663ffffffff169050611112565b826001141561108e57601463ffffffff85160660500163ffffffff169050611112565b82600214156110b157600563ffffffff851606605f0163ffffffff169050611112565b82600314156110c257506063611112565b6040805160e560020a62461bcd02815260206004820152601560248201527f496e76616c6964206d696e696d756d5261726974790000000000000000000000604482015290519081900360640190fd5b6050811015611124576000915061114d565b605f811015611136576001915061114d565b6063811015611148576002915061114d565b600391505b5092915050565b610102805467ffffffffffffffff196fffffffffffffffff0000000000000000198216680100000000000000009283900467ffffffffffffffff908116600019018116909302179081166001919092160160ff16179055565b600160a060020a03811615156111c257600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6040805160a081018252600080825260208201819052918101829052606081018290526080810191909152905600a165627a7a72305820ecdc4603e77d88d8d2b369907dffdbbce5d0906a6ba33ddaf149b08a86c186fc0029


   Swarm Source:
bzzr://ecdc4603e77d88d8d2b369907dffdbbce5d0906a6ba33ddaf149b08a86c186fc
Block Age Transaction Difficulty GasUsed Reward
Block Age Uncle Number Difficulty GasUsed Reward