Contract 0xe272fdDBD056240149c771F9fD917FA040dceB39 2

 

Contract Overview

Balance:
0.001542714770919521 Ether

EtherValue:
$2.63 (@ $1,706.04/ETH)

Token:
Txn Hash
Method
Block
From
To
Value
0x20f0e94bcf85d18bdab767e49a7f8e5de7c0838b8c7d411057e53de91fb322a7Buy Car88818812019-11-06 4:50:121005 days 12 hrs agoWar Riders: Deployer IN  0xe272fddbd056240149c771f9fd917fa040dceb390.14298141 Ether0.000135283
0xeed0119f99d35b60d17470b5ed6eed8ca34cc81abe43f2a3750a2bf9a91114e2Buy Car88818812019-11-06 4:50:121005 days 12 hrs agoWar Riders: Deployer IN  0xe272fddbd056240149c771f9fd917fa040dceb390.0844135 Ether0.000135253
0xbdcd263d4dee00969cef7a00c0c785f074e9087327874859eafc5387b6cb79c3Buy Car87586602019-10-17 12:59:321025 days 3 hrs agoWar Riders: Deployer IN  0xe272fddbd056240149c771f9fd917fa040dceb390.08150755 Ether0.000450431.2
0x08fb9e17b638c81fa281e356ba9ea2d530bef12a8f869cc1decd201201cad868Buy Bulk Premium...87152882019-10-10 17:06:501031 days 23 hrs ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb391.35471773 Ether0.0034521
0x7790f60c1212b3f5fbaf6dd64ed13a077fc999224c7b746e7b9d6e8721947436Buy Bulk Premium...87152742019-10-10 17:01:501031 days 23 hrs ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb390.76915351 Ether0.003451781
0x6590819031eefe21eb62e04a96879e7e6fb1587cb5d90a67e3520fc9e5677e06Buy Bulk Premium...87152702019-10-10 17:01:081031 days 23 hrs ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb391.35272629 Ether0.003451411
0x26192632e6ee79c3a73d8d8bf089dbefa792ae7cc8ff1ade88705865c31c86c5Buy Bulk Premium...87152672019-10-10 17:00:551031 days 23 hrs ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb390.76915351 Ether0.003451191
0x25a851bbe45fb58430adfca5db916c6a4b4e703e797a8d1c9fa7f6bb76b4a229Buy Bulk Premium...87152592019-10-10 16:59:061031 days 23 hrs ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb391.35073784 Ether0.003452591
0x17ae09b61fc994157299016cdc89c865f7ddd0abcce38ba70964f8459f6a5261Buy Bulk Premium...87152472019-10-10 16:56:121031 days 23 hrs ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb390.76855925 Ether0.003451781
0x89864e46f337487a94b473a4e24691ec3f4a076283643e28608b591aa09b73ebBuy Bulk Premium...87152392019-10-10 16:54:121032 days ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb391.34875238 Ether0.0034521
0x97b21c788b91a5e45f3918ae294a722083a77f58168d720daf726d95776d005cBuy Bulk Premium...87152322019-10-10 16:52:501032 days 1 min ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb391.34676988 Ether0.003451411
0x48e95fe93cfffb95617b986f1c570b9d859ba8c8b9c4a4a07d9391c06c06d108Buy Bulk Premium...87152252019-10-10 16:51:291032 days 2 mins ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb391.34281381 Ether0.003452591
0xd13a27001a344e5fae98baf58d7c09ce93b4ddb1b2b19bd5d5ad603092f37775Buy Bulk Premium...87152222019-10-10 16:51:081032 days 3 mins ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb391.34281381 Ether0.0034521
0x4caca6166f5c54ad80cae95e592aa470c605cd701aaeae1b24e344adf536972dBuy Bulk Premium...87152112019-10-10 16:47:211032 days 7 mins ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb390.76796546 Ether0.003451191
0x954efff74025d4ddc2494b151184df0db2eed6668d8d822c5ac925f46f08e78cBuy Bulk Premium...87152032019-10-10 16:46:481032 days 7 mins ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb390.76737215 Ether0.003451781
0x31a40129e1ade0af87a560ac2f6f469b7d11e7c7fda0ed34a23077c2086f45afBuy Bulk Premium...87151952019-10-10 16:45:221032 days 9 mins ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb390.76559506 Ether0.003451781
0xf25b392bb74d56b7dc6e9be6c07ff677cac4e1ab190cce5444eae9865d81d9d8Buy Bulk Premium...87151902019-10-10 16:44:291032 days 9 mins ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb391.34084022 Ether0.0034521
0xa98820cf089e235d68cf17a49e5fe19071d5962ea3aa2e0267cc14bc9f0df5ccBuy Bulk Premium...87151842019-10-10 16:43:271032 days 10 mins ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb390.76500365 Ether0.003451781
0x20f21244541f62e976553592db28eea9e87ad51adbb47453de44ddfa496d0d8cBuy Bulk Premium...87151772019-10-10 16:41:341032 days 12 mins ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb390.76500365 Ether0.003452371
0xc46af8e1bfb64447be0d37625eb1060a45639508d8484a0ff7040f01a8aa2fc5Buy Bulk Premium...87151572019-10-10 16:35:351032 days 18 mins ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb390.76500365 Ether0.003451781
0xfb239fdb97d48375d3ad77e281c7dc35daa91968769412abad9e111e78f88a01Buy Bulk Premium...87151332019-10-10 16:28:281032 days 25 mins ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb390.76441271 Ether0.003452371
0xa0ee3d21e0cc32d4ca97d6ffc46a60d8bcb55797d77f1311dc5b07d10cae1cbaBuy Bulk Premium...86258122019-09-26 17:26:321045 days 23 hrs ago0x0985224a811e65c235dbf4a2c2117712aabe4e39 IN  0xe272fddbd056240149c771f9fd917fa040dceb390.53623753 Ether0.0354689215
0xd757e9b31c89d69fe1175c716f6bed6d40c42f8a3c4071984d4eda2fd24e8bd1Buy Bulk Premium...85502952019-09-14 22:12:071057 days 18 hrs ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb391.33493717 Ether0.02759718
0xe5d2abba8154299471a70b89b80f189e4665794294791e4e9be1c1707dbb90b6Buy Bulk Premium...85502872019-09-14 22:10:471057 days 18 hrs ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb391.33493717 Ether0.027611288
0x1bb8d247dd5b97456cf1ba8d376074b3ce97629c76a0a4c5b5b0f7f11e621b7dBuy Bulk Premium...85311902019-09-11 22:33:081060 days 18 hrs ago0xfcc60e3ba8e753f131032f26b0179bac332551c9 IN  0xe272fddbd056240149c771f9fd917fa040dceb391.33493717 Ether0.0379720211
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x26a7bbd63cc71334f08060baf4e3e86f8ad753241881b3b90af13f9cec51245a124838302021-05-22 11:27:40442 days 5 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb39 0x4472a4b8f2194788dbfc717811392e0aa6b30bf510.08 Ether
0x5aa8bba7a7a3c521fc73025301e6d37f61af90da50322b41720c1ec19374a94b106555352020-08-14 2:54:44723 days 13 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb39 0x4472a4b8f2194788dbfc717811392e0aa6b30bf510.6 Ether
0x4a90c6cb0c06e9ce3fbd2d10cc041d4857dd772c225c4a617bcc3446172ee42895337282020-02-22 14:42:17897 days 2 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb39 0x4472a4b8f2194788dbfc717811392e0aa6b30bf510 Ether
0xdcbe70f707663b7a9cae513a76ddfffcb3251a52394fc62ee950a15b115c554a92934302020-01-16 16:59:11933 days 23 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb39 0x4472a4b8f2194788dbfc717811392e0aa6b30bf510 Ether
0xc0524b6458e17fd1a43dff71530abae81862c209e95912fb56922838910bbd4492272502020-01-06 13:41:10944 days 3 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb39 0x4472a4b8f2194788dbfc717811392e0aa6b30bf58 Ether
0xcf324ecfbf1ca1598abed0357a96ffbeafe89aacba30f5de187a31a2bc3767aa91827002019-12-29 21:29:01951 days 19 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb39 0x4472a4b8f2194788dbfc717811392e0aa6b30bf52 Ether
0x023f2473e1eb16c874096fc1fb026a1946e5e46a08bf5cb4366b4341b835945991826422019-12-29 21:07:09951 days 19 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb39 0x4472a4b8f2194788dbfc717811392e0aa6b30bf510 Ether
0x4c43c465081bba5c243ede4b9259c6ffa16f2d788b23b9f47b14a283c33c2f3391378382019-12-20 23:13:19960 days 17 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb39 0x4472a4b8f2194788dbfc717811392e0aa6b30bf56 Ether
0x1612131d22f7f194a78a5889f0d3fda5fcc14590d3574c9612dd40cd972a73e990387682019-12-02 15:27:50979 days 1 hr ago 0xe272fddbd056240149c771f9fd917fa040dceb39 0x4472a4b8f2194788dbfc717811392e0aa6b30bf510 Ether
0x4fc17e685723189531de23477bb66d941b512b61948f00d1bdd44f8daac76af089829512019-11-22 22:40:48988 days 18 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb39 0x4472a4b8f2194788dbfc717811392e0aa6b30bf510 Ether
0x1add1a2d4fde381ca1065b0555f9da17ed15528394b37c264ec28101bf743dee88816372019-11-06 3:57:551005 days 12 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb39 0x4472a4b8f2194788dbfc717811392e0aa6b30bf520 Ether
0xffd8619a53ce18a43f8bf8d81bb69519b7182e343630eb10b38ce2918e1bc79f88793042019-11-05 19:12:101005 days 21 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb39 0x4472a4b8f2194788dbfc717811392e0aa6b30bf510 Ether
0xbdcd263d4dee00969cef7a00c0c785f074e9087327874859eafc5387b6cb79c387586602019-10-17 12:59:321025 days 3 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb390x0de6aeef3c9e5f3417ac2a64ef1c0185030ddc1e0.0699431 Ether
0xbdcd263d4dee00969cef7a00c0c785f074e9087327874859eafc5387b6cb79c387586602019-10-17 12:59:321025 days 3 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb39War Riders: Deployer0.0071 Ether
0x08fb9e17b638c81fa281e356ba9ea2d530bef12a8f869cc1decd201201cad86887152882019-10-10 17:06:501031 days 23 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb390x0de6aeef3c9e5f3417ac2a64ef1c0185030ddc1e0.12498378 Ether
0x08fb9e17b638c81fa281e356ba9ea2d530bef12a8f869cc1decd201201cad86887152882019-10-10 17:06:501031 days 23 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb390x0de6aeef3c9e5f3417ac2a64ef1c0185030ddc1e0.12496503 Ether
0x08fb9e17b638c81fa281e356ba9ea2d530bef12a8f869cc1decd201201cad86887152882019-10-10 17:06:501031 days 23 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb390x0de6aeef3c9e5f3417ac2a64ef1c0185030ddc1e0.12494629 Ether
0x08fb9e17b638c81fa281e356ba9ea2d530bef12a8f869cc1decd201201cad86887152882019-10-10 17:06:501031 days 23 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb390x0de6aeef3c9e5f3417ac2a64ef1c0185030ddc1e0.12492755 Ether
0x08fb9e17b638c81fa281e356ba9ea2d530bef12a8f869cc1decd201201cad86887152882019-10-10 17:06:501031 days 23 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb390x0de6aeef3c9e5f3417ac2a64ef1c0185030ddc1e0.12490882 Ether
0x08fb9e17b638c81fa281e356ba9ea2d530bef12a8f869cc1decd201201cad86887152882019-10-10 17:06:501031 days 23 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb390x0de6aeef3c9e5f3417ac2a64ef1c0185030ddc1e0.12489008 Ether
0x08fb9e17b638c81fa281e356ba9ea2d530bef12a8f869cc1decd201201cad86887152882019-10-10 17:06:501031 days 23 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb390x0de6aeef3c9e5f3417ac2a64ef1c0185030ddc1e0.12487135 Ether
0x08fb9e17b638c81fa281e356ba9ea2d530bef12a8f869cc1decd201201cad86887152882019-10-10 17:06:501031 days 23 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb390x0de6aeef3c9e5f3417ac2a64ef1c0185030ddc1e0.12485263 Ether
0x08fb9e17b638c81fa281e356ba9ea2d530bef12a8f869cc1decd201201cad86887152882019-10-10 17:06:501031 days 23 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb390x0de6aeef3c9e5f3417ac2a64ef1c0185030ddc1e0.1248339 Ether
0x08fb9e17b638c81fa281e356ba9ea2d530bef12a8f869cc1decd201201cad86887152882019-10-10 17:06:501031 days 23 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb390x0de6aeef3c9e5f3417ac2a64ef1c0185030ddc1e0.12481518 Ether
0x7790f60c1212b3f5fbaf6dd64ed13a077fc999224c7b746e7b9d6e872194743687152742019-10-10 17:01:501031 days 23 hrs ago 0xe272fddbd056240149c771f9fd917fa040dceb390x0de6aeef3c9e5f3417ac2a64ef1c0185030ddc1e0.0699375 Ether
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PreOrder

Compiler Version
v0.4.24+commit.e67f0147

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2018-08-21
*/

pragma solidity ^0.4.22;

/**
 * @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 Destructible
 * @dev Base contract that can be destroyed by owner. All funds in contract will be sent to the owner.
 */
contract Destructible is Ownable {
  /**
   * @dev Transfers the current balance to the owner and terminates the contract.
   */
  function destroy() public onlyOwner {
    selfdestruct(owner);
  }

  function destroyAndSend(address _recipient) public onlyOwner {
    selfdestruct(_recipient);
  }
}

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

/**
 * @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 {

  bytes4 internal 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 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63;
  /**
   * 0x780e9d63 ===
   *   bytes4(keccak256('totalSupply()')) ^
   *   bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^
   *   bytes4(keccak256('tokenByIndex(uint256)'))
   */

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

  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 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;
}

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

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

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

  /**
  * @dev Multiplies two numbers, reverts on overflow.
  */
  function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
    // Gas optimization: this is cheaper than requiring '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;
    }

    uint256 c = _a * _b;
    require(c / _a == _b);

    return c;
  }

  /**
  * @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
  */
  function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
    require(_b > 0); // Solidity only automatically asserts 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 c;
  }

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

    return c;
  }

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

    return c;
  }

  /**
  * @dev Divides two numbers and returns the remainder (unsigned integer modulo),
  * reverts when dividing by zero.
  */
  function mod(uint256 a, uint256 b) internal pure returns (uint256) {
    require(b != 0);
    return a % b;
  }
}

/**
 * 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 _account address of the account to check
   * @return whether the target address is a contract
   */
  function isContract(address _account) 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(_account) }
    return size > 0;
  }

}

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

/**
 * @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 {

  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;

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

  /**
   * @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 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
  {
    require(isApprovedOrOwner(msg.sender, _tokenId));
    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
  {
    // 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
  {
    transferFrom(_from, _to, _tokenId);
    // solium-disable-next-line arg-overflow
    require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data));
  }

  /**
   * @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) internal view returns (bool) {
    address owner = tokenOwner[_tokenId];
    return owner != address(0);
  }

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

/**
 * @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 {

  // 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);

    // To prevent a gap in the array, we store the last token in the index of the token to delete, and
    // then delete the last slot.
    uint256 tokenIndex = ownedTokensIndex[_tokenId];
    uint256 lastTokenIndex = ownedTokens[_from].length.sub(1);
    uint256 lastToken = ownedTokens[_from][lastTokenIndex];

    ownedTokens[_from][tokenIndex] = lastToken;
    // This also deletes the contents at the last position of the array
    ownedTokens[_from].length--;

    // 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

    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;
  }

}



/*
 * @title String & slice utility library for Solidity contracts.
 * @author Nick Johnson <[email protected]>
 *
 * @dev Functionality in this library is largely implemented using an
 *      abstraction called a 'slice'. A slice represents a part of a string -
 *      anything from the entire string to a single character, or even no
 *      characters at all (a 0-length slice). Since a slice only has to specify
 *      an offset and a length, copying and manipulating slices is a lot less
 *      expensive than copying and manipulating the strings they reference.
 *
 *      To further reduce gas costs, most functions on slice that need to return
 *      a slice modify the original one instead of allocating a new one; for
 *      instance, `s.split(".")` will return the text up to the first '.',
 *      modifying s to only contain the remainder of the string after the '.'.
 *      In situations where you do not want to modify the original slice, you
 *      can make a copy first with `.copy()`, for example:
 *      `s.copy().split(".")`. Try and avoid using this idiom in loops; since
 *      Solidity has no memory management, it will result in allocating many
 *      short-lived slices that are later discarded.
 *
 *      Functions that return two slices come in two versions: a non-allocating
 *      version that takes the second slice as an argument, modifying it in
 *      place, and an allocating version that allocates and returns the second
 *      slice; see `nextRune` for example.
 *
 *      Functions that have to copy string data will return strings rather than
 *      slices; these can be cast back to slices for further processing if
 *      required.
 *
 *      For convenience, some functions are provided with non-modifying
 *      variants that create a new slice and return both; for instance,
 *      `s.splitNew('.')` leaves s unmodified, and returns two values
 *      corresponding to the left and right parts of the string.
 */

library strings {
    struct slice {
        uint _len;
        uint _ptr;
    }

    function memcpy(uint dest, uint src, uint len) private pure {
        // Copy word-length chunks while possible
        for(; len >= 32; len -= 32) {
            assembly {
                mstore(dest, mload(src))
            }
            dest += 32;
            src += 32;
        }

        // Copy remaining bytes
        uint mask = 256 ** (32 - len) - 1;
        assembly {
            let srcpart := and(mload(src), not(mask))
            let destpart := and(mload(dest), mask)
            mstore(dest, or(destpart, srcpart))
        }
    }

    /*
     * @dev Returns a slice containing the entire string.
     * @param self The string to make a slice from.
     * @return A newly allocated slice containing the entire string.
     */
    function toSlice(string memory self) internal pure returns (slice memory) {
        uint ptr;
        assembly {
            ptr := add(self, 0x20)
        }
        return slice(bytes(self).length, ptr);
    }

    /*
     * @dev Returns the length of a null-terminated bytes32 string.
     * @param self The value to find the length of.
     * @return The length of the string, from 0 to 32.
     */
    function len(bytes32 self) internal pure returns (uint) {
        uint ret;
        if (self == 0)
            return 0;
        if (self & 0xffffffffffffffffffffffffffffffff == 0) {
            ret += 16;
            self = bytes32(uint(self) / 0x100000000000000000000000000000000);
        }
        if (self & 0xffffffffffffffff == 0) {
            ret += 8;
            self = bytes32(uint(self) / 0x10000000000000000);
        }
        if (self & 0xffffffff == 0) {
            ret += 4;
            self = bytes32(uint(self) / 0x100000000);
        }
        if (self & 0xffff == 0) {
            ret += 2;
            self = bytes32(uint(self) / 0x10000);
        }
        if (self & 0xff == 0) {
            ret += 1;
        }
        return 32 - ret;
    }

    /*
     * @dev Returns a slice containing the entire bytes32, interpreted as a
     *      null-terminated utf-8 string.
     * @param self The bytes32 value to convert to a slice.
     * @return A new slice containing the value of the input argument up to the
     *         first null.
     */
    function toSliceB32(bytes32 self) internal pure returns (slice memory ret) {
        // Allocate space for `self` in memory, copy it there, and point ret at it
        assembly {
            let ptr := mload(0x40)
            mstore(0x40, add(ptr, 0x20))
            mstore(ptr, self)
            mstore(add(ret, 0x20), ptr)
        }
        ret._len = len(self);
    }

    /*
     * @dev Returns a new slice containing the same data as the current slice.
     * @param self The slice to copy.
     * @return A new slice containing the same data as `self`.
     */
    function copy(slice memory self) internal pure returns (slice memory) {
        return slice(self._len, self._ptr);
    }

    /*
     * @dev Copies a slice to a new string.
     * @param self The slice to copy.
     * @return A newly allocated string containing the slice's text.
     */
    function toString(slice memory self) internal pure returns (string memory) {
        string memory ret = new string(self._len);
        uint retptr;
        assembly { retptr := add(ret, 32) }

        memcpy(retptr, self._ptr, self._len);
        return ret;
    }

    /*
     * @dev Returns the length in runes of the slice. Note that this operation
     *      takes time proportional to the length of the slice; avoid using it
     *      in loops, and call `slice.empty()` if you only need to know whether
     *      the slice is empty or not.
     * @param self The slice to operate on.
     * @return The length of the slice in runes.
     */
    function len(slice memory self) internal pure returns (uint l) {
        // Starting at ptr-31 means the LSB will be the byte we care about
        uint ptr = self._ptr - 31;
        uint end = ptr + self._len;
        for (l = 0; ptr < end; l++) {
            uint8 b;
            assembly { b := and(mload(ptr), 0xFF) }
            if (b < 0x80) {
                ptr += 1;
            } else if(b < 0xE0) {
                ptr += 2;
            } else if(b < 0xF0) {
                ptr += 3;
            } else if(b < 0xF8) {
                ptr += 4;
            } else if(b < 0xFC) {
                ptr += 5;
            } else {
                ptr += 6;
            }
        }
    }

    /*
     * @dev Returns true if the slice is empty (has a length of 0).
     * @param self The slice to operate on.
     * @return True if the slice is empty, False otherwise.
     */
    function empty(slice memory self) internal pure returns (bool) {
        return self._len == 0;
    }

    /*
     * @dev Returns a positive number if `other` comes lexicographically after
     *      `self`, a negative number if it comes before, or zero if the
     *      contents of the two slices are equal. Comparison is done per-rune,
     *      on unicode codepoints.
     * @param self The first slice to compare.
     * @param other The second slice to compare.
     * @return The result of the comparison.
     */
    function compare(slice memory self, slice memory other) internal pure returns (int) {
        uint shortest = self._len;
        if (other._len < self._len)
            shortest = other._len;

        uint selfptr = self._ptr;
        uint otherptr = other._ptr;
        for (uint idx = 0; idx < shortest; idx += 32) {
            uint a;
            uint b;
            assembly {
                a := mload(selfptr)
                b := mload(otherptr)
            }
            if (a != b) {
                // Mask out irrelevant bytes and check again
                uint256 mask = uint256(-1); // 0xffff...
                if(shortest < 32) {
                  mask = ~(2 ** (8 * (32 - shortest + idx)) - 1);
                }
                uint256 diff = (a & mask) - (b & mask);
                if (diff != 0)
                    return int(diff);
            }
            selfptr += 32;
            otherptr += 32;
        }
        return int(self._len) - int(other._len);
    }

    /*
     * @dev Returns true if the two slices contain the same text.
     * @param self The first slice to compare.
     * @param self The second slice to compare.
     * @return True if the slices are equal, false otherwise.
     */
    function equals(slice memory self, slice memory other) internal pure returns (bool) {
        return compare(self, other) == 0;
    }

    /*
     * @dev Extracts the first rune in the slice into `rune`, advancing the
     *      slice to point to the next rune and returning `self`.
     * @param self The slice to operate on.
     * @param rune The slice that will contain the first rune.
     * @return `rune`.
     */
    function nextRune(slice memory self, slice memory rune) internal pure returns (slice memory) {
        rune._ptr = self._ptr;

        if (self._len == 0) {
            rune._len = 0;
            return rune;
        }

        uint l;
        uint b;
        // Load the first byte of the rune into the LSBs of b
        assembly { b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) }
        if (b < 0x80) {
            l = 1;
        } else if(b < 0xE0) {
            l = 2;
        } else if(b < 0xF0) {
            l = 3;
        } else {
            l = 4;
        }

        // Check for truncated codepoints
        if (l > self._len) {
            rune._len = self._len;
            self._ptr += self._len;
            self._len = 0;
            return rune;
        }

        self._ptr += l;
        self._len -= l;
        rune._len = l;
        return rune;
    }

    /*
     * @dev Returns the first rune in the slice, advancing the slice to point
     *      to the next rune.
     * @param self The slice to operate on.
     * @return A slice containing only the first rune from `self`.
     */
    function nextRune(slice memory self) internal pure returns (slice memory ret) {
        nextRune(self, ret);
    }

    /*
     * @dev Returns the number of the first codepoint in the slice.
     * @param self The slice to operate on.
     * @return The number of the first codepoint in the slice.
     */
    function ord(slice memory self) internal pure returns (uint ret) {
        if (self._len == 0) {
            return 0;
        }

        uint word;
        uint length;
        uint divisor = 2 ** 248;

        // Load the rune into the MSBs of b
        assembly { word:= mload(mload(add(self, 32))) }
        uint b = word / divisor;
        if (b < 0x80) {
            ret = b;
            length = 1;
        } else if(b < 0xE0) {
            ret = b & 0x1F;
            length = 2;
        } else if(b < 0xF0) {
            ret = b & 0x0F;
            length = 3;
        } else {
            ret = b & 0x07;
            length = 4;
        }

        // Check for truncated codepoints
        if (length > self._len) {
            return 0;
        }

        for (uint i = 1; i < length; i++) {
            divisor = divisor / 256;
            b = (word / divisor) & 0xFF;
            if (b & 0xC0 != 0x80) {
                // Invalid UTF-8 sequence
                return 0;
            }
            ret = (ret * 64) | (b & 0x3F);
        }

        return ret;
    }

    /*
     * @dev Returns the keccak-256 hash of the slice.
     * @param self The slice to hash.
     * @return The hash of the slice.
     */
    function keccak(slice memory self) internal pure returns (bytes32 ret) {
        assembly {
            ret := keccak256(mload(add(self, 32)), mload(self))
        }
    }

    /*
     * @dev Returns true if `self` starts with `needle`.
     * @param self The slice to operate on.
     * @param needle The slice to search for.
     * @return True if the slice starts with the provided text, false otherwise.
     */
    function startsWith(slice memory self, slice memory needle) internal pure returns (bool) {
        if (self._len < needle._len) {
            return false;
        }

        if (self._ptr == needle._ptr) {
            return true;
        }

        bool equal;
        assembly {
            let length := mload(needle)
            let selfptr := mload(add(self, 0x20))
            let needleptr := mload(add(needle, 0x20))
            equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
        }
        return equal;
    }

    /*
     * @dev If `self` starts with `needle`, `needle` is removed from the
     *      beginning of `self`. Otherwise, `self` is unmodified.
     * @param self The slice to operate on.
     * @param needle The slice to search for.
     * @return `self`
     */
    function beyond(slice memory self, slice memory needle) internal pure returns (slice memory) {
        if (self._len < needle._len) {
            return self;
        }

        bool equal = true;
        if (self._ptr != needle._ptr) {
            assembly {
                let length := mload(needle)
                let selfptr := mload(add(self, 0x20))
                let needleptr := mload(add(needle, 0x20))
                equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
            }
        }

        if (equal) {
            self._len -= needle._len;
            self._ptr += needle._len;
        }

        return self;
    }

    /*
     * @dev Returns true if the slice ends with `needle`.
     * @param self The slice to operate on.
     * @param needle The slice to search for.
     * @return True if the slice starts with the provided text, false otherwise.
     */
    function endsWith(slice memory self, slice memory needle) internal pure returns (bool) {
        if (self._len < needle._len) {
            return false;
        }

        uint selfptr = self._ptr + self._len - needle._len;

        if (selfptr == needle._ptr) {
            return true;
        }

        bool equal;
        assembly {
            let length := mload(needle)
            let needleptr := mload(add(needle, 0x20))
            equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
        }

        return equal;
    }

    /*
     * @dev If `self` ends with `needle`, `needle` is removed from the
     *      end of `self`. Otherwise, `self` is unmodified.
     * @param self The slice to operate on.
     * @param needle The slice to search for.
     * @return `self`
     */
    function until(slice memory self, slice memory needle) internal pure returns (slice memory) {
        if (self._len < needle._len) {
            return self;
        }

        uint selfptr = self._ptr + self._len - needle._len;
        bool equal = true;
        if (selfptr != needle._ptr) {
            assembly {
                let length := mload(needle)
                let needleptr := mload(add(needle, 0x20))
                equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
            }
        }

        if (equal) {
            self._len -= needle._len;
        }

        return self;
    }

    // Returns the memory address of the first byte of the first occurrence of
    // `needle` in `self`, or the first byte after `self` if not found.
    function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) {
        uint ptr = selfptr;
        uint idx;

        if (needlelen <= selflen) {
            if (needlelen <= 32) {
                bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1));

                bytes32 needledata;
                assembly { needledata := and(mload(needleptr), mask) }

                uint end = selfptr + selflen - needlelen;
                bytes32 ptrdata;
                assembly { ptrdata := and(mload(ptr), mask) }

                while (ptrdata != needledata) {
                    if (ptr >= end)
                        return selfptr + selflen;
                    ptr++;
                    assembly { ptrdata := and(mload(ptr), mask) }
                }
                return ptr;
            } else {
                // For long needles, use hashing
                bytes32 hash;
                assembly { hash := keccak256(needleptr, needlelen) }

                for (idx = 0; idx <= selflen - needlelen; idx++) {
                    bytes32 testHash;
                    assembly { testHash := keccak256(ptr, needlelen) }
                    if (hash == testHash)
                        return ptr;
                    ptr += 1;
                }
            }
        }
        return selfptr + selflen;
    }

    // Returns the memory address of the first byte after the last occurrence of
    // `needle` in `self`, or the address of `self` if not found.
    function rfindPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) {
        uint ptr;

        if (needlelen <= selflen) {
            if (needlelen <= 32) {
                bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1));

                bytes32 needledata;
                assembly { needledata := and(mload(needleptr), mask) }

                ptr = selfptr + selflen - needlelen;
                bytes32 ptrdata;
                assembly { ptrdata := and(mload(ptr), mask) }

                while (ptrdata != needledata) {
                    if (ptr <= selfptr)
                        return selfptr;
                    ptr--;
                    assembly { ptrdata := and(mload(ptr), mask) }
                }
                return ptr + needlelen;
            } else {
                // For long needles, use hashing
                bytes32 hash;
                assembly { hash := keccak256(needleptr, needlelen) }
                ptr = selfptr + (selflen - needlelen);
                while (ptr >= selfptr) {
                    bytes32 testHash;
                    assembly { testHash := keccak256(ptr, needlelen) }
                    if (hash == testHash)
                        return ptr + needlelen;
                    ptr -= 1;
                }
            }
        }
        return selfptr;
    }

    /*
     * @dev Modifies `self` to contain everything from the first occurrence of
     *      `needle` to the end of the slice. `self` is set to the empty slice
     *      if `needle` is not found.
     * @param self The slice to search and modify.
     * @param needle The text to search for.
     * @return `self`.
     */
    function find(slice memory self, slice memory needle) internal pure returns (slice memory) {
        uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr);
        self._len -= ptr - self._ptr;
        self._ptr = ptr;
        return self;
    }

    /*
     * @dev Modifies `self` to contain the part of the string from the start of
     *      `self` to the end of the first occurrence of `needle`. If `needle`
     *      is not found, `self` is set to the empty slice.
     * @param self The slice to search and modify.
     * @param needle The text to search for.
     * @return `self`.
     */
    function rfind(slice memory self, slice memory needle) internal pure returns (slice memory) {
        uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr);
        self._len = ptr - self._ptr;
        return self;
    }

    /*
     * @dev Splits the slice, setting `self` to everything after the first
     *      occurrence of `needle`, and `token` to everything before it. If
     *      `needle` does not occur in `self`, `self` is set to the empty slice,
     *      and `token` is set to the entirety of `self`.
     * @param self The slice to split.
     * @param needle The text to search for in `self`.
     * @param token An output parameter to which the first token is written.
     * @return `token`.
     */
    function split(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) {
        uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr);
        token._ptr = self._ptr;
        token._len = ptr - self._ptr;
        if (ptr == self._ptr + self._len) {
            // Not found
            self._len = 0;
        } else {
            self._len -= token._len + needle._len;
            self._ptr = ptr + needle._len;
        }
        return token;
    }

    /*
     * @dev Splits the slice, setting `self` to everything after the first
     *      occurrence of `needle`, and returning everything before it. If
     *      `needle` does not occur in `self`, `self` is set to the empty slice,
     *      and the entirety of `self` is returned.
     * @param self The slice to split.
     * @param needle The text to search for in `self`.
     * @return The part of `self` up to the first occurrence of `delim`.
     */
    function split(slice memory self, slice memory needle) internal pure returns (slice memory token) {
        split(self, needle, token);
    }

    /*
     * @dev Splits the slice, setting `self` to everything before the last
     *      occurrence of `needle`, and `token` to everything after it. If
     *      `needle` does not occur in `self`, `self` is set to the empty slice,
     *      and `token` is set to the entirety of `self`.
     * @param self The slice to split.
     * @param needle The text to search for in `self`.
     * @param token An output parameter to which the first token is written.
     * @return `token`.
     */
    function rsplit(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) {
        uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr);
        token._ptr = ptr;
        token._len = self._len - (ptr - self._ptr);
        if (ptr == self._ptr) {
            // Not found
            self._len = 0;
        } else {
            self._len -= token._len + needle._len;
        }
        return token;
    }

    /*
     * @dev Splits the slice, setting `self` to everything before the last
     *      occurrence of `needle`, and returning everything after it. If
     *      `needle` does not occur in `self`, `self` is set to the empty slice,
     *      and the entirety of `self` is returned.
     * @param self The slice to split.
     * @param needle The text to search for in `self`.
     * @return The part of `self` after the last occurrence of `delim`.
     */
    function rsplit(slice memory self, slice memory needle) internal pure returns (slice memory token) {
        rsplit(self, needle, token);
    }

    /*
     * @dev Counts the number of nonoverlapping occurrences of `needle` in `self`.
     * @param self The slice to search.
     * @param needle The text to search for in `self`.
     * @return The number of occurrences of `needle` found in `self`.
     */
    function count(slice memory self, slice memory needle) internal pure returns (uint cnt) {
        uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len;
        while (ptr <= self._ptr + self._len) {
            cnt++;
            ptr = findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) + needle._len;
        }
    }

    /*
     * @dev Returns True if `self` contains `needle`.
     * @param self The slice to search.
     * @param needle The text to search for in `self`.
     * @return True if `needle` is found in `self`, false otherwise.
     */
    function contains(slice memory self, slice memory needle) internal pure returns (bool) {
        return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr;
    }

    /*
     * @dev Returns a newly allocated string containing the concatenation of
     *      `self` and `other`.
     * @param self The first slice to concatenate.
     * @param other The second slice to concatenate.
     * @return The concatenation of the two strings.
     */
    function concat(slice memory self, slice memory other) internal pure returns (string memory) {
        string memory ret = new string(self._len + other._len);
        uint retptr;
        assembly { retptr := add(ret, 32) }
        memcpy(retptr, self._ptr, self._len);
        memcpy(retptr + self._len, other._ptr, other._len);
        return ret;
    }

    /*
     * @dev Joins an array of slices, using `self` as a delimiter, returning a
     *      newly allocated string.
     * @param self The delimiter to use.
     * @param parts A list of slices to join.
     * @return A newly allocated string containing all the slices in `parts`,
     *         joined with `self`.
     */
    function join(slice memory self, slice[] memory parts) internal pure returns (string memory) {
        if (parts.length == 0)
            return "";

        uint length = self._len * (parts.length - 1);
        for(uint i = 0; i < parts.length; i++)
            length += parts[i]._len;

        string memory ret = new string(length);
        uint retptr;
        assembly { retptr := add(ret, 32) }

        for(i = 0; i < parts.length; i++) {
            memcpy(retptr, parts[i]._ptr, parts[i]._len);
            retptr += parts[i]._len;
            if (i < parts.length - 1) {
                memcpy(retptr, self._ptr, self._len);
                retptr += self._len;
            }
        }

        return ret;
    }
}

contract CarFactory is Ownable {
    using strings for *;

    uint256 public constant MAX_CARS = 30000 + 150000 + 1000000;
    uint256 public mintedCars = 0;
    address preOrderAddress;
    CarToken token;

    mapping(uint256 => uint256) public tankSizes;
    mapping(uint256 => uint) public savedTypes;
    mapping(uint256 => bool) public giveawayCar;
    
    mapping(uint => uint256[]) public availableIds;
    mapping(uint => uint256) public idCursor;

    event CarMinted(uint256 _tokenId, string _metadata, uint cType);
    event CarSellingBeings();



    modifier onlyPreOrder {
        require(msg.sender == preOrderAddress, "Not authorized");
        _;
    }

    modifier isInitialized {
        require(preOrderAddress != address(0), "No linked preorder");
        require(address(token) != address(0), "No linked token");
        _;
    }

    function uintToString(uint v) internal pure returns (string) {
        uint maxlength = 100;
        bytes memory reversed = new bytes(maxlength);
        uint i = 0;
        while (v != 0) {
            uint remainder = v % 10;
            v = v / 10;
            reversed[i++] = byte(48 + remainder);
        }
        bytes memory s = new bytes(i); // i + 1 is inefficient
        for (uint j = 0; j < i; j++) {
            s[j] = reversed[i - j - 1]; // to avoid the off-by-one error
        }
        string memory str = string(s);  // memory isn't implicitly convertible to storage
        return str; // this was missing
    }

    function mintFor(uint cType, address newOwner) public onlyPreOrder isInitialized returns (uint256) {
        require(mintedCars < MAX_CARS, "Factory has minted the max number of cars");
        
        uint256 _tokenId = nextAvailableId(cType);
        require(!token.exists(_tokenId), "Token already exists");

        string memory id = uintToString(_tokenId).toSlice().concat(".json".toSlice());

        uint256 tankSize = tankSizes[_tokenId];
        string memory _metadata = "https://vault.warriders.com/".toSlice().concat(id.toSlice());

        token.mint(_tokenId, _metadata, cType, tankSize, newOwner);
        mintedCars++;
        
        return _tokenId;
    }

    function giveaway(uint256 _tokenId, uint256 _tankSize, uint cType, bool markCar, address dst) public onlyOwner isInitialized {
        require(dst != address(0), "No destination address given");
        require(!token.exists(_tokenId), "Token already exists");
        require(dst != owner);
        require(dst != address(this));
        require(_tankSize <= token.maxTankSizes(cType));
            
        tankSizes[_tokenId] = _tankSize;
        savedTypes[_tokenId] = cType;

        string memory id = uintToString(_tokenId).toSlice().concat(".json".toSlice());
        string memory _metadata = "https://vault.warriders.com/".toSlice().concat(id.toSlice());

        token.mint(_tokenId, _metadata, cType, _tankSize, dst);
        mintedCars++;

        giveawayCar[_tokenId] = markCar;
    }

    function setTokenMeta(uint256[] _tokenIds, uint256[] ts, uint[] cTypes) public onlyOwner isInitialized {
        for (uint i = 0; i < _tokenIds.length; i++) {
            uint256 _tokenId = _tokenIds[i];
            uint cType = cTypes[i];
            uint256 _tankSize = ts[i];

            require(_tankSize <= token.maxTankSizes(cType));
            
            tankSizes[_tokenId] = _tankSize;
            savedTypes[_tokenId] = cType;
            
            
            availableIds[cTypes[i]].push(_tokenId);
        }
    }
    
    function nextAvailableId(uint cType) private returns (uint256) {
        uint256 currentCursor = idCursor[cType];
        
        require(currentCursor < availableIds[cType].length);
        
        uint256 nextId = availableIds[cType][currentCursor];
        idCursor[cType] = currentCursor + 1;
        return nextId;
    }

    /**
    Attach the preOrder that will be receiving tokens being marked for sale by the
    sellCar function
    */
    function attachPreOrder(address dst) public onlyOwner {
        require(preOrderAddress == address(0));
        require(dst != address(0));

        //Enforce that address is indeed a preorder
        PreOrder preOrder = PreOrder(dst);

        preOrderAddress = address(preOrder);
    }

    /**
    Attach the token being used for things
    */
    function attachToken(address dst) public onlyOwner {
        require(address(token) == address(0));
        require(dst != address(0));

        //Enforce that address is indeed a preorder
        CarToken ct = CarToken(dst);

        token = ct;
    }
}

contract CarToken is ERC721Token, Ownable {
    using strings for *;
    
    address factory;

    /*
    * Car Types:
    * 0 - Unknown
    * 1 - SUV
    * 2 - Truck
    * 3 - Hovercraft
    * 4 - Tank
    * 5 - Lambo
    * 6 - Buggy
    * 7 - midgrade type 2
    * 8 - midgrade type 3
    * 9 - Hatchback
    * 10 - regular type 2
    * 11 - regular type 3
    */
    uint public constant UNKNOWN_TYPE = 0;
    uint public constant SUV_TYPE = 1;
    uint public constant TANKER_TYPE = 2;
    uint public constant HOVERCRAFT_TYPE = 3;
    uint public constant TANK_TYPE = 4;
    uint public constant LAMBO_TYPE = 5;
    uint public constant DUNE_BUGGY = 6;
    uint public constant MIDGRADE_TYPE2 = 7;
    uint public constant MIDGRADE_TYPE3 = 8;
    uint public constant HATCHBACK = 9;
    uint public constant REGULAR_TYPE2 = 10;
    uint public constant REGULAR_TYPE3 = 11;
    
    string public constant METADATA_URL = "https://vault.warriders.com/";
    
    //Number of premium type cars
    uint public PREMIUM_TYPE_COUNT = 5;
    //Number of midgrade type cars
    uint public MIDGRADE_TYPE_COUNT = 3;
    //Number of regular type cars
    uint public REGULAR_TYPE_COUNT = 3;

    mapping(uint256 => uint256) public maxBznTankSizeOfPremiumCarWithIndex;
    mapping(uint256 => uint256) public maxBznTankSizeOfMidGradeCarWithIndex;
    mapping(uint256 => uint256) public maxBznTankSizeOfRegularCarWithIndex;

    /**
     * Whether any given car (tokenId) is special
     */
    mapping(uint256 => bool) public isSpecial;
    /**
     * The type of any given car (tokenId)
     */
    mapping(uint256 => uint) public carType;
    /**
     * The total supply for any given type (int)
     */
    mapping(uint => uint256) public carTypeTotalSupply;
    /**
     * The current supply for any given type (int)
     */
    mapping(uint => uint256) public carTypeSupply;
    /**
     * Whether any given type (int) is special
     */
    mapping(uint => bool) public isTypeSpecial;

    /**
    * How much BZN any given car (tokenId) can hold
    */
    mapping(uint256 => uint256) public tankSizes;
    
    /**
     * Given any car type (uint), get the max tank size for that type (uint256)
     */
    mapping(uint => uint256) public maxTankSizes;
    
    mapping (uint => uint[]) public premiumTotalSupplyForCar;
    mapping (uint => uint[]) public midGradeTotalSupplyForCar;
    mapping (uint => uint[]) public regularTotalSupplyForCar;

    modifier onlyFactory {
        require(msg.sender == factory, "Not authorized");
        _;
    }

    constructor(address factoryAddress) public ERC721Token("WarRiders", "WR") {
        factory = factoryAddress;

        carTypeTotalSupply[UNKNOWN_TYPE] = 0; //Unknown
        carTypeTotalSupply[SUV_TYPE] = 20000; //SUV
        carTypeTotalSupply[TANKER_TYPE] = 9000; //Tanker
        carTypeTotalSupply[HOVERCRAFT_TYPE] = 600; //Hovercraft
        carTypeTotalSupply[TANK_TYPE] = 300; //Tank
        carTypeTotalSupply[LAMBO_TYPE] = 100; //Lambo
        carTypeTotalSupply[DUNE_BUGGY] = 40000; //migrade type 1
        carTypeTotalSupply[MIDGRADE_TYPE2] = 50000; //midgrade type 2
        carTypeTotalSupply[MIDGRADE_TYPE3] = 60000; //midgrade type 3
        carTypeTotalSupply[HATCHBACK] = 200000; //regular type 1
        carTypeTotalSupply[REGULAR_TYPE2] = 300000; //regular type 2
        carTypeTotalSupply[REGULAR_TYPE3] = 500000; //regular type 3
        
        maxTankSizes[SUV_TYPE] = 200; //SUV tank size
        maxTankSizes[TANKER_TYPE] = 450; //Tanker tank size
        maxTankSizes[HOVERCRAFT_TYPE] = 300; //Hovercraft tank size
        maxTankSizes[TANK_TYPE] = 200; //Tank tank size
        maxTankSizes[LAMBO_TYPE] = 250; //Lambo tank size
        maxTankSizes[DUNE_BUGGY] = 120; //migrade type 1 tank size
        maxTankSizes[MIDGRADE_TYPE2] = 110; //midgrade type 2 tank size
        maxTankSizes[MIDGRADE_TYPE3] = 100; //midgrade type 3 tank size
        maxTankSizes[HATCHBACK] = 90; //regular type 1 tank size
        maxTankSizes[REGULAR_TYPE2] = 70; //regular type 2 tank size
        maxTankSizes[REGULAR_TYPE3] = 40; //regular type 3 tank size
        
        maxBznTankSizeOfPremiumCarWithIndex[1] = 200; //SUV tank size
        maxBznTankSizeOfPremiumCarWithIndex[2] = 450; //Tanker tank size
        maxBznTankSizeOfPremiumCarWithIndex[3] = 300; //Hovercraft tank size
        maxBznTankSizeOfPremiumCarWithIndex[4] = 200; //Tank tank size
        maxBznTankSizeOfPremiumCarWithIndex[5] = 250; //Lambo tank size
        maxBznTankSizeOfMidGradeCarWithIndex[1] = 100; //migrade type 1 tank size
        maxBznTankSizeOfMidGradeCarWithIndex[2] = 110; //midgrade type 2 tank size
        maxBznTankSizeOfMidGradeCarWithIndex[3] = 120; //midgrade type 3 tank size
        maxBznTankSizeOfRegularCarWithIndex[1] = 40; //regular type 1 tank size
        maxBznTankSizeOfRegularCarWithIndex[2] = 70; //regular type 2 tank size
        maxBznTankSizeOfRegularCarWithIndex[3] = 90; //regular type 3 tank size

        isTypeSpecial[HOVERCRAFT_TYPE] = true;
        isTypeSpecial[TANK_TYPE] = true;
        isTypeSpecial[LAMBO_TYPE] = true;
    }

    function isCarSpecial(uint256 tokenId) public view returns (bool) {
        return isSpecial[tokenId];
    }

    function getCarType(uint256 tokenId) public view returns (uint) {
        return carType[tokenId];
    }

    function mint(uint256 _tokenId, string _metadata, uint cType, uint256 tankSize, address newOwner) public onlyFactory {
        //Since any invalid car type would have a total supply of 0 
        //This require will also enforce that a valid cType is given
        require(carTypeSupply[cType] < carTypeTotalSupply[cType], "This type has reached total supply");
        
        //This will enforce the tank size is less than the max
        require(tankSize <= maxTankSizes[cType], "Tank size provided bigger than max for this type");
        
        if (isPremium(cType)) {
            premiumTotalSupplyForCar[cType].push(_tokenId);
        } else if (isMidGrade(cType)) {
            midGradeTotalSupplyForCar[cType].push(_tokenId);
        } else {
            regularTotalSupplyForCar[cType].push(_tokenId);
        }

        super._mint(newOwner, _tokenId);
        super._setTokenURI(_tokenId, _metadata);

        carType[_tokenId] = cType;
        isSpecial[_tokenId] = isTypeSpecial[cType];
        carTypeSupply[cType] = carTypeSupply[cType] + 1;
        tankSizes[_tokenId] = tankSize;
    }
    
    function isPremium(uint cType) public pure returns (bool) {
        return cType == SUV_TYPE || cType == TANKER_TYPE || cType == HOVERCRAFT_TYPE || cType == TANK_TYPE || cType == LAMBO_TYPE;
    }
    
    function isMidGrade(uint cType) public pure returns (bool) {
        return cType == DUNE_BUGGY || cType == MIDGRADE_TYPE2 || cType == MIDGRADE_TYPE3;
    }
    
    function isRegular(uint cType) public pure returns (bool) {
        return cType == HATCHBACK || cType == REGULAR_TYPE2 || cType == REGULAR_TYPE3;
    }
    
    function getTotalSupplyForType(uint cType) public view returns (uint256) {
        return carTypeSupply[cType];
    }
    
    function getPremiumCarsForVariant(uint variant) public view returns (uint[]) {
        return premiumTotalSupplyForCar[variant];
    }
    
    function getMidgradeCarsForVariant(uint variant) public view returns (uint[]) {
        return midGradeTotalSupplyForCar[variant];
    }

    function getRegularCarsForVariant(uint variant) public view returns (uint[]) {
        return regularTotalSupplyForCar[variant];
    }

    function getPremiumCarSupply(uint variant) public view returns (uint) {
        return premiumTotalSupplyForCar[variant].length;
    }
    
    function getMidgradeCarSupply(uint variant) public view returns (uint) {
        return midGradeTotalSupplyForCar[variant].length;
    }

    function getRegularCarSupply(uint variant) public view returns (uint) {
        return regularTotalSupplyForCar[variant].length;
    }
    
    function exists(uint256 _tokenId) public view returns (bool) {
        return super._exists(_tokenId);
    }
}

contract PreOrder is Destructible {
    /**
     * The current price for any given type (int)
     */
    mapping(uint => uint256) public currentTypePrice;

    // Maps Premium car variants to the tokens minted for their description
    // INPUT: variant #
    // OUTPUT: list of cars
    mapping(uint => uint256[]) public premiumCarsBought;
    mapping(uint => uint256[]) public midGradeCarsBought;
    mapping(uint => uint256[]) public regularCarsBought;
    mapping(uint256 => address) public tokenReserve;

    event consumerBulkBuy(uint256[] variants, address reserver, uint category);
    event CarBought(uint256 carId, uint256 value, address purchaser, uint category);
    event Withdrawal(uint256 amount);

    uint256 public constant COMMISSION_PERCENT = 5;

    //Max number of premium cars
    uint256 public constant MAX_PREMIUM = 30000;
    //Max number of midgrade cars
    uint256 public constant MAX_MIDGRADE = 150000;
    //Max number of regular cars
    uint256 public constant MAX_REGULAR = 1000000;

    //Max number of premium type cars
    uint public PREMIUM_TYPE_COUNT = 5;
    //Max number of midgrade type cars
    uint public MIDGRADE_TYPE_COUNT = 3;
    //Max number of regular type cars
    uint public REGULAR_TYPE_COUNT = 3;

    uint private midgrade_offset = 5;
    uint private regular_offset = 6;

    uint256 public constant GAS_REQUIREMENT = 250000;

    //Premium type id
    uint public constant PREMIUM_CATEGORY = 1;
    //Midgrade type id
    uint public constant MID_GRADE_CATEGORY = 2;
    //Regular type id
    uint public constant REGULAR_CATEGORY = 3;
    
    mapping(address => uint256) internal commissionRate;
    
    address internal constant OPENSEA = 0x5b3256965e7C3cF26E11FCAf296DfC8807C01073;

    //The percent increase for any given type
    mapping(uint => uint256) internal percentIncrease;
    mapping(uint => uint256) internal percentBase;
    //uint public constant PERCENT_INCREASE = 101;

    //How many car is in each category currently
    uint256 public premiumHold = 30000;
    uint256 public midGradeHold = 150000;
    uint256 public regularHold = 1000000;

    bool public premiumOpen = false;
    bool public midgradeOpen = false;
    bool public regularOpen = false;

    //Reference to other contracts
    CarToken public token;
    //AuctionManager public auctionManager;
    CarFactory internal factory;

    address internal escrow;

    modifier premiumIsOpen {
        //Ensure we are selling at least 1 car
        require(premiumHold > 0, "No more premium cars");
        require(premiumOpen, "Premium store not open for sale");
        _;
    }

    modifier midGradeIsOpen {
        //Ensure we are selling at least 1 car
        require(midGradeHold > 0, "No more midgrade cars");
        require(midgradeOpen, "Midgrade store not open for sale");
        _;
    }

    modifier regularIsOpen {
        //Ensure we are selling at least 1 car
        require(regularHold > 0, "No more regular cars");
        require(regularOpen, "Regular store not open for sale");
        _;
    }

    modifier onlyFactory {
        //Only factory can use this function
        require(msg.sender == address(factory), "Not authorized");
        _;
    }

    modifier onlyFactoryOrOwner {
        //Only factory or owner can use this function
        require(msg.sender == address(factory) || msg.sender == owner, "Not authorized");
        _;
    }

    function() public payable { }

    constructor(
        address tokenAddress,
        address tokenFactory,
        address e
    ) public {
        token = CarToken(tokenAddress);

        factory = CarFactory(tokenFactory);

        escrow = e;

        //Set percent increases
        percentIncrease[1] = 100008;
        percentBase[1] = 100000;
        percentIncrease[2] = 100015;
        percentBase[2] = 100000;
        percentIncrease[3] = 1002;
        percentBase[3] = 1000;
        percentIncrease[4] = 1004;
        percentBase[4] = 1000;
        percentIncrease[5] = 102;
        percentBase[5] = 100;
        
        commissionRate[OPENSEA] = 10;
    }
    
    function setCommission(address referral, uint256 percent) public onlyOwner {
        require(percent > COMMISSION_PERCENT);
        require(percent < 95);
        percent = percent - COMMISSION_PERCENT;
        
        commissionRate[referral] = percent;
    }
    
    function setPercentIncrease(uint256 increase, uint256 base, uint cType) public onlyOwner {
        require(increase > base);
        
        percentIncrease[cType] = increase;
        percentBase[cType] = base;
    }

    function openShop(uint category) public onlyOwner {
        require(category == 1 || category == 2 || category == 3, "Invalid category");

        if (category == PREMIUM_CATEGORY) {
            premiumOpen = true;
        } else if (category == MID_GRADE_CATEGORY) {
            midgradeOpen = true;
        } else if (category == REGULAR_CATEGORY) {
            regularOpen = true;
        }
    }

    /**
     * Set the starting price for any given type. Can only be set once, and value must be greater than 0
     */
    function setTypePrice(uint cType, uint256 price) public onlyOwner {
        if (currentTypePrice[cType] == 0) {
            require(price > 0, "Price already set");
            currentTypePrice[cType] = price;
        }
    }

    /**
    Withdraw the amount from the contract's balance. Only the contract owner can execute this function
    */
    function withdraw(uint256 amount) public onlyOwner {
        uint256 balance = address(this).balance;

        require(amount <= balance, "Requested to much");
        owner.transfer(amount);

        emit Withdrawal(amount);
    }

    function reserveManyTokens(uint[] cTypes, uint category) public payable returns (bool) {
        if (category == PREMIUM_CATEGORY) {
            require(premiumOpen, "Premium is not open for sale");
        } else if (category == MID_GRADE_CATEGORY) {
            require(midgradeOpen, "Midgrade is not open for sale");
        } else if (category == REGULAR_CATEGORY) {
            require(regularOpen, "Regular is not open for sale");
        } else {
            revert();
        }

        address reserver = msg.sender;

        uint256 ether_required = 0;
        for (uint i = 0; i < cTypes.length; i++) {
            uint cType = cTypes[i];

            uint256 price = priceFor(cType);

            ether_required += (price + GAS_REQUIREMENT);

            currentTypePrice[cType] = price;
        }

        require(msg.value >= ether_required);

        uint256 refundable = msg.value - ether_required;

        escrow.transfer(ether_required);

        if (refundable > 0) {
            reserver.transfer(refundable);
        }

        emit consumerBulkBuy(cTypes, reserver, category);
    }

     function buyBulkPremiumCar(address referal, uint[] variants, address new_owner) public payable premiumIsOpen returns (bool) {
         uint n = variants.length;
         require(n <= 10, "Max bulk buy is 10 cars");

         for (uint i = 0; i < n; i++) {
             buyCar(referal, variants[i], false, new_owner, PREMIUM_CATEGORY);
         }
     }

     function buyBulkMidGradeCar(address referal, uint[] variants, address new_owner) public payable midGradeIsOpen returns (bool) {
         uint n = variants.length;
         require(n <= 10, "Max bulk buy is 10 cars");

         for (uint i = 0; i < n; i++) {
             buyCar(referal, variants[i], false, new_owner, MID_GRADE_CATEGORY);
         }
     }

     function buyBulkRegularCar(address referal, uint[] variants, address new_owner) public payable regularIsOpen returns (bool) {
         uint n = variants.length;
         require(n <= 10, "Max bulk buy is 10 cars");

         for (uint i = 0; i < n; i++) {
             buyCar(referal, variants[i], false, new_owner, REGULAR_CATEGORY);
         }
     }

    function buyCar(address referal, uint cType, bool give_refund, address new_owner, uint category) public payable returns (bool) {
        require(category == PREMIUM_CATEGORY || category == MID_GRADE_CATEGORY || category == REGULAR_CATEGORY);
        if (category == PREMIUM_CATEGORY) {
            require(cType == 1 || cType == 2 || cType == 3 || cType == 4 || cType == 5, "Invalid car type");
            require(premiumHold > 0, "No more premium cars");
            require(premiumOpen, "Premium store not open for sale");
        } else if (category == MID_GRADE_CATEGORY) {
            require(cType == 6 || cType == 7 || cType == 8, "Invalid car type");
            require(midGradeHold > 0, "No more midgrade cars");
            require(midgradeOpen, "Midgrade store not open for sale");
        } else if (category == REGULAR_CATEGORY) {
            require(cType == 9 || cType == 10 || cType == 11, "Invalid car type");
            require(regularHold > 0, "No more regular cars");
            require(regularOpen, "Regular store not open for sale");
        }

        uint256 price = priceFor(cType);
        require(price > 0, "Price not yet set");
        require(msg.value >= price, "Not enough ether sent");
        /*if (tokenReserve[_tokenId] != address(0)) {
            require(new_owner == tokenReserve[_tokenId], "You don't have the rights to buy this token");
        }*/
        currentTypePrice[cType] = price; //Set new type price

        uint256 _tokenId = factory.mintFor(cType, new_owner); //Now mint the token
        
        if (category == PREMIUM_CATEGORY) {
            premiumCarsBought[cType].push(_tokenId);
            premiumHold--;
        } else if (category == MID_GRADE_CATEGORY) {
            midGradeCarsBought[cType - 5].push(_tokenId);
            midGradeHold--;
        } else if (category == REGULAR_CATEGORY) {
            regularCarsBought[cType - 8].push(_tokenId);
            regularHold--;
        }

        if (give_refund && msg.value > price) {
            uint256 change = msg.value - price;

            msg.sender.transfer(change);
        }

        if (referal != address(0)) {
            require(referal != msg.sender, "The referal cannot be the sender");
            require(referal != tx.origin, "The referal cannot be the tranaction origin");
            require(referal != new_owner, "The referal cannot be the new owner");

            //The commissionRate map adds any partner bonuses, or 0 if a normal user referral
            uint256 totalCommision = COMMISSION_PERCENT + commissionRate[referal];

            uint256 commision = (price * totalCommision) / 100;

            referal.transfer(commision);
        }

        emit CarBought(_tokenId, price, new_owner, category);
    }

    /**
    Get the price for any car with the given _tokenId
    */
    function priceFor(uint cType) public view returns (uint256) {
        uint256 percent = percentIncrease[cType];
        uint256 base = percentBase[cType];

        uint256 currentPrice = currentTypePrice[cType];
        uint256 nextPrice = (currentPrice * percent);

        //Return the next price, as this is the true price
        return nextPrice / base;
    }

    function sold(uint256 _tokenId) public view returns (bool) {
        return token.exists(_tokenId);
    }
}

Contract Security Audit

Contract ABI

[{"constant":false,"inputs":[{"name":"referal","type":"address"},{"name":"variants","type":"uint256[]"},{"name":"new_owner","type":"address"}],"name":"buyBulkMidGradeCar","outputs":[{"name":"","type":"bool"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"midgradeOpen","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MIDGRADE_TYPE_COUNT","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"regularOpen","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"regularHold","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"premiumOpen","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"MAX_REGULAR","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"referral","type":"address"},{"name":"percent","type":"uint256"}],"name":"setCommission","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"MID_GRADE_CATEGORY","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MAX_MIDGRADE","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"GAS_REQUIREMENT","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MAX_PREMIUM","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"referal","type":"address"},{"name":"variants","type":"uint256[]"},{"name":"new_owner","type":"address"}],"name":"buyBulkPremiumCar","outputs":[{"name":"","type":"bool"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"REGULAR_TYPE_COUNT","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"PREMIUM_CATEGORY","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":"destroy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"cType","type":"uint256"},{"name":"price","type":"uint256"}],"name":"setTypePrice","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"cTypes","type":"uint256[]"},{"name":"category","type":"uint256"}],"name":"reserveManyTokens","outputs":[{"name":"","type":"bool"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"cType","type":"uint256"}],"name":"priceFor","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"tokenReserve","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"name":"regularCarsBought","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"sold","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"COMMISSION_PERCENT","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"referal","type":"address"},{"name":"cType","type":"uint256"},{"name":"give_refund","type":"bool"},{"name":"new_owner","type":"address"},{"name":"category","type":"uint256"}],"name":"buyCar","outputs":[{"name":"","type":"bool"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"premiumHold","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"name":"premiumCarsBought","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"midGradeHold","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"REGULAR_CATEGORY","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"name":"midGradeCarsBought","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"PREMIUM_TYPE_COUNT","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"currentTypePrice","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"category","type":"uint256"}],"name":"openShop","outputs":[],"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":"increase","type":"uint256"},{"name":"base","type":"uint256"},{"name":"cType","type":"uint256"}],"name":"setPercentIncrease","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_recipient","type":"address"}],"name":"destroyAndSend","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"token","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"referal","type":"address"},{"name":"variants","type":"uint256[]"},{"name":"new_owner","type":"address"}],"name":"buyBulkRegularCar","outputs":[{"name":"","type":"bool"}],"payable":true,"stateMutability":"payable","type":"function"},{"inputs":[{"name":"tokenAddress","type":"address"},{"name":"tokenFactory","type":"address"},{"name":"e","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"variants","type":"uint256[]"},{"indexed":false,"name":"reserver","type":"address"},{"indexed":false,"name":"category","type":"uint256"}],"name":"consumerBulkBuy","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"carId","type":"uint256"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":false,"name":"purchaser","type":"address"},{"indexed":false,"name":"category","type":"uint256"}],"name":"CarBought","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"amount","type":"uint256"}],"name":"Withdrawal","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"}]

60806040526005600681815560036007819055600855600991909155600a55617530600e55620249f0600f55620f42406010556011805462ffffff1916905534801561004a57600080fd5b50604051606080611f698339810160409081528151602080840151929093015160008054600160a060020a03199081163317825560118054600160a060020a03958616630100000002630100000060b860020a03199091161790556012805495851695821695909517909455601380549390921692909316919091179055620186a87fd421a5181c571bba3f01190c922c3b2a896fc1d84e86c9f17ac10e67ebef8b5c55620186a07ffd54ff1ed53f34a900b24c5ba64f85761163b5d82d98a47b9bd80e45466993c5819055620186af7f5d6016397a73f5e079297ac5a36fef17b4d9c3831618e63ab105738020ddd720557f10a81eed9d63d16face5e76357905348e6253d3394086026bb2bf2145d7cc249556103ea7fc0da782485e77ae272268ae0a3ff44c1552ecb60b3743924de17a815e0a3cfd7556103e87f26b4a10d0f0b04925c23bd4480ee147c916e5e87a7d68206a533dad160ac81e28190556103ec7f5b84bb9e0f5aa9cc45a8bb66468db5d4816d1e75ff86b5e1f1dd8d144dab8097557fafafe8948a4ed9d478b1e9a5780b119b5edd00ea7d07bc35bef7c814824eb94b5560667f2cd9ebf6ff19cdd7ffcc447d7c7d47b5991f5c7392a04512134e765802361fa65560647fa5049387d9cb649c59f4bda666105ba636c2a103d8e2b232ba4d125737cd214955735b3256965e7c3cf26e11fcaf296dfc8807c010739052600b9052600a7ff2d65821f8e72b8d2f20ddb68bdc750775322350fa13862067b34299630e0f4355611ce2806102876000396000f3006080604052600436106101ed5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166303ef03b481146101ef5780630d14ed4f146102645780631dbdd7921461027957806328a5e6f0146102a05780632d6e2bb0146102b55780632dbacf5f146102ca5780632e1a7d4d146102df578063300240d6146102f757806331729a451461030c57806335fe36601461033057806345b6ccfd1461034557806346a2b53e1461035a5780634cdabb161461036f5780634cf52fa2146103845780634d6c3427146103e55780636dac8bea146103fa578063715018a61461040f57806383197ef0146104245780638ab5fcc5146104395780638bad8d8e146104545780638d5555f21461049e5780638da5cb5b146104b657806390e563b3146104e75780639a8b0ce0146104ff5780639c03facb1461051a578063b404e00114610532578063b7d6f43214610547578063b91e34221461056e578063b9293e3314610583578063bfe3e03a1461059e578063ca5b8a52146105b3578063cf5ab68b146105c8578063d2b001fb146105e3578063deb5bf0b146105f8578063e2fa9ee014610610578063f2fde38b14610628578063f32e803814610649578063f5074f4114610667578063fc0c546a14610688578063fe9d744d1461069d575b005b604080516020600460248035828101358481028087018601909752808652610250968435600160a060020a03169636966044959194909101929182918501908490808284375094975050509235600160a060020a031693506106fe92505050565b604080519115158252519081900360200190f35b34801561027057600080fd5b50610250610860565b34801561028557600080fd5b5061028e61086e565b60408051918252519081900360200190f35b3480156102ac57600080fd5b50610250610874565b3480156102c157600080fd5b5061028e610883565b3480156102d657600080fd5b50610250610889565b3480156102eb57600080fd5b506101ed600435610892565b34801561030357600080fd5b5061028e610976565b34801561031857600080fd5b506101ed600160a060020a036004351660243561097d565b34801561033c57600080fd5b5061028e6109d1565b34801561035157600080fd5b5061028e6109d6565b34801561036657600080fd5b5061028e6109dd565b34801561037b57600080fd5b5061028e6109e4565b604080516020600460248035828101358481028087018601909752808652610250968435600160a060020a03169636966044959194909101929182918501908490808284375094975050509235600160a060020a031693506109ea92505050565b3480156103f157600080fd5b5061028e610b3e565b34801561040657600080fd5b5061028e610b44565b34801561041b57600080fd5b506101ed610b49565b34801561043057600080fd5b506101ed610bb5565b34801561044557600080fd5b506101ed600435602435610bda565b60408051602060048035808201358381028086018501909652808552610250953695939460249493850192918291850190849080828437509497505093359450610c749350505050565b3480156104aa57600080fd5b5061028e600435610f54565b3480156104c257600080fd5b506104cb610f93565b60408051600160a060020a039092168252519081900360200190f35b3480156104f357600080fd5b506104cb600435610fa2565b34801561050b57600080fd5b5061028e600435602435610fbd565b34801561052657600080fd5b50610250600435610fed565b34801561053e57600080fd5b5061028e61108c565b610250600160a060020a036004358116906024359060443515159060643516608435611091565b34801561057a57600080fd5b5061028e611907565b34801561058f57600080fd5b5061028e60043560243561190d565b3480156105aa57600080fd5b5061028e611928565b3480156105bf57600080fd5b5061028e61192e565b3480156105d457600080fd5b5061028e600435602435611933565b3480156105ef57600080fd5b5061028e61194e565b34801561060457600080fd5b5061028e600435611954565b34801561061c57600080fd5b506101ed600435611966565b34801561063457600080fd5b506101ed600160a060020a0360043516611a43565b34801561065557600080fd5b506101ed600435602435604435611a63565b34801561067357600080fd5b506101ed600160a060020a0360043516611aa6565b34801561069457600080fd5b506104cb611ac9565b604080516020600460248035828101358481028087018601909752808652610250968435600160a060020a03169636966044959194909101929182918501908490808284375094975050509235600160a060020a03169350611adf92505050565b600080600080600f5411151561075e576040805160e560020a62461bcd02815260206004820152601560248201527f4e6f206d6f7265206d6964677261646520636172730000000000000000000000604482015290519081900360640190fd5b601154610100900460ff1615156107bf576040805160e560020a62461bcd02815260206004820181905260248201527f4d696467726164652073746f7265206e6f74206f70656e20666f722073616c65604482015290519081900360640190fd5b84519150600a82111561081c576040805160e560020a62461bcd02815260206004820152601760248201527f4d61782062756c6b206275792069732031302063617273000000000000000000604482015290519081900360640190fd5b5060005b818110156108575761084e86868381518110151561083a57fe5b906020019060200201516000876002611091565b50600101610820565b50509392505050565b601154610100900460ff1681565b60075481565b60115462010000900460ff1681565b60105481565b60115460ff1681565b60008054600160a060020a031633146108aa57600080fd5b50303180821115610905576040805160e560020a62461bcd02815260206004820152601160248201527f52657175657374656420746f206d756368000000000000000000000000000000604482015290519081900360640190fd5b60008054604051600160a060020a039091169184156108fc02918591818181858888f1935050505015801561093e573d6000803e3d6000fd5b506040805183815290517f4e70a604b23a8edee2b1d0a656e9b9c00b73ad8bb1afc2c59381ee9f69197de79181900360200190a15050565b620f424081565b600054600160a060020a0316331461099457600080fd5b600581116109a157600080fd5b605f81106109ae57600080fd5b600160a060020a039091166000908152600b602052604090206004199091019055565b600281565b620249f081565b6203d09081565b61753081565b600080600080600e54111515610a4a576040805160e560020a62461bcd02815260206004820152601460248201527f4e6f206d6f7265207072656d69756d2063617273000000000000000000000000604482015290519081900360640190fd5b60115460ff161515610aa6576040805160e560020a62461bcd02815260206004820152601f60248201527f5072656d69756d2073746f7265206e6f74206f70656e20666f722073616c6500604482015290519081900360640190fd5b84519150600a821115610b03576040805160e560020a62461bcd02815260206004820152601760248201527f4d61782062756c6b206275792069732031302063617273000000000000000000604482015290519081900360640190fd5b5060005b8181101561085757610b35868683815181101515610b2157fe5b906020019060200201516000876001611091565b50600101610b07565b60085481565b600181565b600054600160a060020a03163314610b6057600080fd5b60008054604051600160a060020a03909116917ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482091a26000805473ffffffffffffffffffffffffffffffffffffffff19169055565b600054600160a060020a03163314610bcc57600080fd5b600054600160a060020a0316ff5b600054600160a060020a03163314610bf157600080fd5b6000828152600160205260409020541515610c705760008111610c5e576040805160e560020a62461bcd02815260206004820152601160248201527f507269636520616c726561647920736574000000000000000000000000000000604482015290519081900360640190fd5b60008281526001602052604090208190555b5050565b60008060008060008060006001881415610ce95760115460ff161515610ce4576040805160e560020a62461bcd02815260206004820152601c60248201527f5072656d69756d206973206e6f74206f70656e20666f722073616c6500000000604482015290519081900360640190fd5b610dc3565b6002881415610d5357601154610100900460ff161515610ce4576040805160e560020a62461bcd02815260206004820152601d60248201527f4d69646772616465206973206e6f74206f70656e20666f722073616c65000000604482015290519081900360640190fd5b6003881415610dbe5760115462010000900460ff161515610ce4576040805160e560020a62461bcd02815260206004820152601c60248201527f526567756c6172206973206e6f74206f70656e20666f722073616c6500000000604482015290519081900360640190fd5b600080fd5b33955060009450600093505b8851841015610e24578884815181101515610de657fe5b906020019060200201519250610dfb83610f54565b60008481526001602081905260409091208290559581016203d090019594909401939150610dcf565b34851115610e3157600080fd5b506013546040513486900391600160a060020a03169086156108fc029087906000818181858888f19350505050158015610e6f573d6000803e3d6000fd5b506000811115610eb157604051600160a060020a0387169082156108fc029083906000818181858888f19350505050158015610eaf573d6000803e3d6000fd5b505b7fe7fcfd53b35dc3cd28f6fbedac8299e4dd5dfc503f623849f21e1b646e78287a89878a604051808060200184600160a060020a0316600160a060020a03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b83811015610f33578181015183820152602001610f1b565b5050505090500194505050505060405180910390a150505050505092915050565b6000818152600c6020908152604080832054600d8352818420546001909352908320549091908083028281811515610f8857fe5b049695505050505050565b600054600160a060020a031681565b600560205260009081526040902054600160a060020a031681565b600460205281600052604060002081815481101515610fd857fe5b90600052602060002001600091509150505481565b601154604080517f4f558e7900000000000000000000000000000000000000000000000000000000815260048101849052905160009263010000009004600160a060020a031691634f558e7991602480830192602092919082900301818787803b15801561105a57600080fd5b505af115801561106e573d6000803e3d6000fd5b505050506040513d602081101561108457600080fd5b505192915050565b600581565b60008060008060008060018714806110a95750600287145b806110b45750600387145b15156110bf57600080fd5b60018714156112095789600114806110d75750896002145b806110e25750896003145b806110ed5750896004145b806110f85750896005145b151561114e576040805160e560020a62461bcd02815260206004820152601060248201527f496e76616c696420636172207479706500000000000000000000000000000000604482015290519081900360640190fd5b600e546000106111a8576040805160e560020a62461bcd02815260206004820152601460248201527f4e6f206d6f7265207072656d69756d2063617273000000000000000000000000604482015290519081900360640190fd5b60115460ff161515611204576040805160e560020a62461bcd02815260206004820152601f60248201527f5072656d69756d2073746f7265206e6f74206f70656e20666f722073616c6500604482015290519081900360640190fd5b611472565b600287141561133d5789600614806112215750896007145b8061122c5750896008145b1515611282576040805160e560020a62461bcd02815260206004820152601060248201527f496e76616c696420636172207479706500000000000000000000000000000000604482015290519081900360640190fd5b600f546000106112dc576040805160e560020a62461bcd02815260206004820152601560248201527f4e6f206d6f7265206d6964677261646520636172730000000000000000000000604482015290519081900360640190fd5b601154610100900460ff161515611204576040805160e560020a62461bcd02815260206004820181905260248201527f4d696467726164652073746f7265206e6f74206f70656e20666f722073616c65604482015290519081900360640190fd5b6003871415611472578960091480611355575089600a145b80611360575089600b145b15156113b6576040805160e560020a62461bcd02815260206004820152601060248201527f496e76616c696420636172207479706500000000000000000000000000000000604482015290519081900360640190fd5b601054600010611410576040805160e560020a62461bcd02815260206004820152601460248201527f4e6f206d6f726520726567756c61722063617273000000000000000000000000604482015290519081900360640190fd5b60115462010000900460ff161515611472576040805160e560020a62461bcd02815260206004820152601f60248201527f526567756c61722073746f7265206e6f74206f70656e20666f722073616c6500604482015290519081900360640190fd5b61147b8a610f54565b9450600085116114d5576040805160e560020a62461bcd02815260206004820152601160248201527f5072696365206e6f742079657420736574000000000000000000000000000000604482015290519081900360640190fd5b3485111561152d576040805160e560020a62461bcd02815260206004820152601560248201527f4e6f7420656e6f7567682065746865722073656e740000000000000000000000604482015290519081900360640190fd5b60008a815260016020908152604080832088905560125481517fad62f1ca000000000000000000000000000000000000000000000000000000008152600481018f9052600160a060020a038d811660248301529251929091169363ad62f1ca9360448084019491939192918390030190829087803b1580156115ae57600080fd5b505af11580156115c2573d6000803e3d6000fd5b505050506040513d60208110156115d857600080fd5b5051935060018714156116155760008a815260026020908152604082208054600181018255908352912001849055600e805460001901905561168d565b6002871415611653576004198a01600090815260036020908152604082208054600181018255908352912001849055600f805460001901905561168d565b600387141561168d576007198a01600090815260046020908152604082208054600181018255908352912001849055601080546000190190555b88801561169957508434115b156116d357604051348690039350339084156108fc029085906000818181858888f193505050501580156116d1573d6000803e3d6000fd5b505b600160a060020a038b16156118aa57600160a060020a038b16331415611743576040805160e560020a62461bcd02815260206004820181905260248201527f546865207265666572616c2063616e6e6f74206265207468652073656e646572604482015290519081900360640190fd5b600160a060020a038b163214156117ca576040805160e560020a62461bcd02815260206004820152602b60248201527f546865207265666572616c2063616e6e6f7420626520746865207472616e616360448201527f74696f6e206f726967696e000000000000000000000000000000000000000000606482015290519081900360840190fd5b600160a060020a038b81169089161415611854576040805160e560020a62461bcd02815260206004820152602360248201527f546865207265666572616c2063616e6e6f7420626520746865206e6577206f7760448201527f6e65720000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b5050600160a060020a0389166000818152600b602052604080822054905160059091019260648785020492909183156108fc0291849190818181858888f193505050501580156118a8573d6000803e3d6000fd5b505b6040805185815260208101879052600160a060020a038a16818301526060810189905290517f40f9951671cfd039715478cc01395832fea6d3f8a84ea788d189363d59a798ac9181900360800190a1505050505095945050505050565b600e5481565b600260205281600052604060002081815481101515610fd857fe5b600f5481565b600381565b600360205281600052604060002081815481101515610fd857fe5b60065481565b60016020526000908152604090205481565b600054600160a060020a0316331461197d57600080fd5b806001148061198c5750806002145b806119975750806003145b15156119ed576040805160e560020a62461bcd02815260206004820152601060248201527f496e76616c69642063617465676f727900000000000000000000000000000000604482015290519081900360640190fd5b6001811415611a08576011805460ff19166001179055611a40565b6002811415611a25576011805461ff001916610100179055611a40565b6003811415611a40576011805462ff00001916620100001790555b50565b600054600160a060020a03163314611a5a57600080fd5b611a4081611c39565b600054600160a060020a03163314611a7a57600080fd5b818311611a8657600080fd5b6000908152600c6020908152604080832094909455600d90529190912055565b600054600160a060020a03163314611abd57600080fd5b80600160a060020a0316ff5b60115463010000009004600160a060020a031681565b600080600080601054111515611b3f576040805160e560020a62461bcd02815260206004820152601460248201527f4e6f206d6f726520726567756c61722063617273000000000000000000000000604482015290519081900360640190fd5b60115462010000900460ff161515611ba1576040805160e560020a62461bcd02815260206004820152601f60248201527f526567756c61722073746f7265206e6f74206f70656e20666f722073616c6500604482015290519081900360640190fd5b84519150600a821115611bfe576040805160e560020a62461bcd02815260206004820152601760248201527f4d61782062756c6b206275792069732031302063617273000000000000000000604482015290519081900360640190fd5b5060005b8181101561085757611c30868683815181101515611c1c57fe5b906020019060200201516000876003611091565b50600101611c02565b600160a060020a0381161515611c4e57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a72305820dd7901b0c939cc8402be22ff659de81781d2ea0ad036301b89e5c7db68ae141200290000000000000000000000005caebd3b32e210e85ce3e9d51638b9c445481567000000000000000000000000e6963576e14aad7743ef627b1ada417fc4c8d32100000000000000000000000040b046d0563c498e5b13414ba9e41ed60291f5b9

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000005caebd3b32e210e85ce3e9d51638b9c445481567000000000000000000000000e6963576e14aad7743ef627b1ada417fc4c8d32100000000000000000000000040b046d0563c498e5b13414ba9e41ed60291f5b9

-----Decoded View---------------
Arg [0] : tokenAddress (address): 0x5caebd3b32e210e85ce3e9d51638b9c445481567
Arg [1] : tokenFactory (address): 0xe6963576e14aad7743ef627b1ada417fc4c8d321
Arg [2] : e (address): 0x40b046d0563c498e5b13414ba9e41ed60291f5b9

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000005caebd3b32e210e85ce3e9d51638b9c445481567
Arg [1] : 000000000000000000000000e6963576e14aad7743ef627b1ada417fc4c8d321
Arg [2] : 00000000000000000000000040b046d0563c498e5b13414ba9e41ed60291f5b9


Swarm Source

bzzr://dd7901b0c939cc8402be22ff659de81781d2ea0ad036301b89e5c7db68ae1412
Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.