Contract 0x9b00fC5dc3Bc5f6E6d016C19512d6d96767E319e

 
 
Txn Hash
Method
Block
From
To
Value
0x7d548185ea5737ae8f3924567730594b2479f2e9c2e37087505fe70c1e4ed11aPurchase70114622019-01-04 23:37:381423 days 10 hrs ago0x74666e2896ab9ec83a553ed2fdc594f2abf8395a IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0.262 Ether0.000046852
0xa043590861290f01f10a33378f8db21fbde8e261692c56d905283c8b88dfbcf3Purchase70114032019-01-04 23:20:581423 days 11 hrs ago0x74666e2896ab9ec83a553ed2fdc594f2abf8395a IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0.262 Ether0.000023421
0xa0464025fb55e79244bf1dae18c033f481347718d5f69e9f2e625714815ac5eaWithdraw67309542018-11-19 2:19:311470 days 8 hrs ago0x73becffc94187a53f6fb61b073125dc97a4a72bb IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0 Ether0.000092173
0xb558029247de53e31e873672898933fea6d294e6bd8e85ea94d914c899c9c0b9Withdraw67309322018-11-19 2:16:201470 days 8 hrs ago0x73becffc94187a53f6fb61b073125dc97a4a72bb IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0 Ether0.000091023
0xbd8dad1dbff1162785b0f0f58a3841b309589a0ca26fe913a1454d622e300252Withdraw67309082018-11-19 2:10:391470 days 8 hrs ago0x73becffc94187a53f6fb61b073125dc97a4a72bb IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0 Ether0.000091023
0x409ebfcd457884a3bec4e32c687dc8604c5678978a2e5508f52bbbaebdb462e0Purchase66408242018-11-04 8:03:151485 days 2 hrs ago0x218e14e3c895d37ed5754baffa6e41b6dff39ee0 IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0.367 Ether0.000114473.3
0x0aacd947c7a635cea87fdf4738b532c96526491a34f9d6dfe341eb8d8ac5bb91Purchase66393602018-11-04 2:27:381485 days 8 hrs ago0x0441143ead98542355ef877296832df2e9b068e0 IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0.362 Ether0.000953533
0x5b4535b25aec96568092007c4c2a491761d28fd18573a8500e2addd9b215de6dPurchase66390342018-11-04 1:11:491485 days 9 hrs ago0x0441143ead98542355ef877296832df2e9b068e0 IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0.361 Ether0.001079723
0x9ab7cd821af9a5f270208fa400dca27e5b552cfce52481d553eae6938d9a8ebaPurchase66381672018-11-03 21:38:331485 days 12 hrs ago0xc8a9698cefc08d86ed12ed0f4e58be75b13fa773 IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0.268 Ether0.000138754
0x750d5250639e4eeaf502f99b358daac9d2bea094a1f8ca5ee43ff7e725b593d3Purchase66294592018-11-02 11:40:591486 days 22 hrs ago0x85fc55f18eedfebc30a84535ce9d1077703eb2ea IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0.646 Ether0.005010728
0x7b9ac6fc9da263fe678d4c51bf12eb21915730369a9071607d27c557b176a4d9Set Addresses66293812018-11-02 11:21:591486 days 23 hrs agoCryptant Crab: Deployer IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0 Ether0.0002932110
0x7330a4f6ca5d46031cfc7e24a94f0b7a310eec14bbcf53073e546516e83d8a0bPurchase66268002018-11-02 1:05:121487 days 9 hrs ago0x0982174ca64cc8b07e41ebf2f3d4d3e700c08e99 IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0.313 Ether0.001423244
0x25aa12d9caf736f50ca3c5ac1f15080d19deda4feea80faad959db68d0d467f2Purchase66237402018-11-01 12:59:021487 days 21 hrs ago0x28af8bf322414c1492bd5d5b62d15cb1e47151d4 IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0.3 Ether0.003558110
0x945a61c3d115f13a8c3b040829d9181acd964603ede7cbdd95748b061c5dfd8cGenerate Giveawa...66231792018-11-01 10:44:021487 days 23 hrs agoCryptant Crab: Deployer IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0 Ether0.013353345
0x60b26c8042112bf9bb546f491ac13710fbaa15b3e8afda4b5d8c8ab0cf9d6cffGenerate Giveawa...66231652018-11-01 10:39:591487 days 23 hrs agoCryptant Crab: Deployer IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0 Ether0.01345085
0xdee5fd8f59a633305d3f5c5c668d03d396b48c3666c1274a493f88d6994dc288Generate Giveawa...66231522018-11-01 10:37:041487 days 23 hrs agoCryptant Crab: Deployer IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0 Ether0.013329845
0xbb8c7edc275ad773909a76feefac854585232868fb35bd00ce0fc585128fb806Generate Giveawa...66231112018-11-01 10:27:551488 days 7 mins agoCryptant Crab: Deployer IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0 Ether0.013329845
0xfc2c1bb39f3271d5fb553dd6d1e35641bbd83ed4ec84071ec527d97af11b9e84Generate Giveawa...66230942018-11-01 10:24:191488 days 11 mins agoCryptant Crab: Deployer IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0 Ether0.026718410
0x7a61f2351b2bfbe7cfbaab76eb5fc02cdb9eca8d2788cae68b4ae77739ba38bePurchase66206702018-11-01 0:52:321488 days 9 hrs ago0xbbb697ccc7470c8b4a5606c6c530c6b6aac48184 IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e2.88 Ether0.008625183
0x2e62fe40b15b2f39fa3b610f0d02ec270ef0f02d72dfa0c6e4c5cdc33df8f229Purchase66204472018-10-31 23:52:201488 days 10 hrs ago0x208379d7ac59eb79553bce816d1f8639d9bacdd8 IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e2.87 Ether0.008620083
0x595f35779742c713c892f8d79baecf37fffcba94f9d2165a5385fd31d798d5f3Purchase66169062018-10-31 9:53:501489 days 41 mins ago0x5911e6d239bab2825772149687f5d9a77f3be4b6 IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0.273 Ether0.001636415
0xbad8dc3f53bb139f0097ecbe68e5228de2cf8315ea70400c81876d3dc62e46d9Purchase66133232018-10-30 20:02:301489 days 14 hrs ago0xe0aa72f8570734f62f7234b2eafc1743c856c371 IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0.26 Ether0.001788095
0x248717329c3c0389a3fe2ffd1b0097d8d3b9a2b2269a06ea5796c86b6613b8c6Purchase66118592018-10-30 14:07:571489 days 20 hrs ago0x5911e6d239bab2825772149687f5d9a77f3be4b6 IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0.254 Ether0.002869968
0xbc45aaa4e736fef630272b0d5cd4df6ef38776fc576a847cebd2b0833c2a9388Purchase66095762018-10-30 5:13:421490 days 5 hrs ago0x13fb97da9d2407da6dbc2d6c175b51d0f5d9d903 IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0.245 Ether0.001071833
0x7a4f261da76000b0bdfa4fe02e7002a52a747c4fa6e32d09d0b0033a4a2b2019Purchase66095492018-10-30 5:07:271490 days 5 hrs ago0xbbb697ccc7470c8b4a5606c6c530c6b6aac48184 IN  0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e2.44 Ether0.000104063
[ Download CSV Export 
Latest 7 internal transactions
Parent Txn Hash Block From To Value
0xa0464025fb55e79244bf1dae18c033f481347718d5f69e9f2e625714815ac5ea67309542018-11-19 2:19:311470 days 8 hrs ago 0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0x73becffc94187a53f6fb61b073125dc97a4a72bb103.706 Ether
0xb558029247de53e31e873672898933fea6d294e6bd8e85ea94d914c899c9c0b967309322018-11-19 2:16:201470 days 8 hrs ago 0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0x73becffc94187a53f6fb61b073125dc97a4a72bb103 wei
0xbd8dad1dbff1162785b0f0f58a3841b309589a0ca26fe913a1454d622e30025267309082018-11-19 2:10:391470 days 8 hrs ago 0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0x73becffc94187a53f6fb61b073125dc97a4a72bb103 wei
0x1a05d3f554617e0d2cab6b1861a4e3aa0d1c0a1b2af99393efb8e894a3b9263365798282018-10-25 8:28:281495 days 2 hrs ago 0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319e0x73becffc94187a53f6fb61b073125dc97a4a72bb1 Ether
0x35e77272f4b196c275434ee152ad9746e57c5953eb55242963f3fefd6a55391965797932018-10-25 8:20:231495 days 2 hrs ago 0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319eCryptant Crab: Deployer1 Ether
0x20c796755c79d734f3af0e5d06a1a30e6416bffef0e7f465cdf41cc9d53d4afe65787672018-10-25 4:17:461495 days 6 hrs ago 0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319eCryptant Crab: Deployer0.001 Ether
0xb055067ff4bd7dfd09ad5d58777e560c108496b846b7ad547fa7178113f3f92e65753922018-10-24 15:02:521495 days 19 hrs ago 0x9b00fc5dc3bc5f6e6d016c19512d6d96767e319eCryptant Crab: Deployer3.6 Ether
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
CryptantCrabPresale

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-10-25
*/

pragma solidity 0.4.24;

contract CrabData {
  modifier crabDataLength(uint256[] memory _crabData) {
    require(_crabData.length == 8);
    _;
  }

  struct CrabPartData {
    uint256 hp;
    uint256 dps;
    uint256 blockRate;
    uint256 resistanceBonus;
    uint256 hpBonus;
    uint256 dpsBonus;
    uint256 blockBonus;
    uint256 mutiplierBonus;
  }

  function arrayToCrabPartData(
    uint256[] _partData
  ) 
    internal 
    pure 
    crabDataLength(_partData) 
    returns (CrabPartData memory _parsedData) 
  {
    _parsedData = CrabPartData(
      _partData[0],   // hp
      _partData[1],   // dps
      _partData[2],   // block rate
      _partData[3],   // resistance bonus
      _partData[4],   // hp bonus
      _partData[5],   // dps bonus
      _partData[6],   // block bonus
      _partData[7]);  // multiplier bonus
  }

  function crabPartDataToArray(CrabPartData _crabPartData) internal pure returns (uint256[] memory _resultData) {
    _resultData = new uint256[](8);
    _resultData[0] = _crabPartData.hp;
    _resultData[1] = _crabPartData.dps;
    _resultData[2] = _crabPartData.blockRate;
    _resultData[3] = _crabPartData.resistanceBonus;
    _resultData[4] = _crabPartData.hpBonus;
    _resultData[5] = _crabPartData.dpsBonus;
    _resultData[6] = _crabPartData.blockBonus;
    _resultData[7] = _crabPartData.mutiplierBonus;
  }
}

contract GeneSurgeon {
  //0 - filler, 1 - body, 2 - leg, 3 - left claw, 4 - right claw
  uint256[] internal crabPartMultiplier = [0, 10**9, 10**6, 10**3, 1];

  function extractElementsFromGene(uint256 _gene) internal view returns (uint256[] memory _elements) {
    _elements = new uint256[](4);
    _elements[0] = _gene / crabPartMultiplier[1] / 100 % 10;
    _elements[1] = _gene / crabPartMultiplier[2] / 100 % 10;
    _elements[2] = _gene / crabPartMultiplier[3] / 100 % 10;
    _elements[3] = _gene / crabPartMultiplier[4] / 100 % 10;
  }

  function extractPartsFromGene(uint256 _gene) internal view returns (uint256[] memory _parts) {
    _parts = new uint256[](4);
    _parts[0] = _gene / crabPartMultiplier[1] % 100;
    _parts[1] = _gene / crabPartMultiplier[2] % 100;
    _parts[2] = _gene / crabPartMultiplier[3] % 100;
    _parts[3] = _gene / crabPartMultiplier[4] % 100;
  }
}

interface GenesisCrabInterface {
  function generateCrabGene(bool isPresale, bool hasLegendaryPart) external returns (uint256 _gene, uint256 _skin, uint256 _heartValue, uint256 _growthValue);
  function mutateCrabPart(uint256 _part, uint256 _existingPartGene, uint256 _legendaryPercentage) external view returns (uint256);
  function generateCrabHeart() external view returns (uint256, uint256);
}

contract Randomable {
  // Generates a random number base on last block hash
  function _generateRandom(bytes32 seed) view internal returns (bytes32) {
    return keccak256(abi.encodePacked(blockhash(block.number-1), seed));
  }

  function _generateRandomNumber(bytes32 seed, uint256 max) view internal returns (uint256) {
    return uint256(_generateRandom(seed)) % max;
  }
}

contract CryptantCrabStoreInterface {
  function createAddress(bytes32 key, address value) external returns (bool);
  function createAddresses(bytes32[] keys, address[] values) external returns (bool);
  function updateAddress(bytes32 key, address value) external returns (bool);
  function updateAddresses(bytes32[] keys, address[] values) external returns (bool);
  function removeAddress(bytes32 key) external returns (bool);
  function removeAddresses(bytes32[] keys) external returns (bool);
  function readAddress(bytes32 key) external view returns (address);
  function readAddresses(bytes32[] keys) external view returns (address[]);
  // Bool related functions
  function createBool(bytes32 key, bool value) external returns (bool);
  function createBools(bytes32[] keys, bool[] values) external returns (bool);
  function updateBool(bytes32 key, bool value) external returns (bool);
  function updateBools(bytes32[] keys, bool[] values) external returns (bool);
  function removeBool(bytes32 key) external returns (bool);
  function removeBools(bytes32[] keys) external returns (bool);
  function readBool(bytes32 key) external view returns (bool);
  function readBools(bytes32[] keys) external view returns (bool[]);
  // Bytes32 related functions
  function createBytes32(bytes32 key, bytes32 value) external returns (bool);
  function createBytes32s(bytes32[] keys, bytes32[] values) external returns (bool);
  function updateBytes32(bytes32 key, bytes32 value) external returns (bool);
  function updateBytes32s(bytes32[] keys, bytes32[] values) external returns (bool);
  function removeBytes32(bytes32 key) external returns (bool);
  function removeBytes32s(bytes32[] keys) external returns (bool);
  function readBytes32(bytes32 key) external view returns (bytes32);
  function readBytes32s(bytes32[] keys) external view returns (bytes32[]);
  // uint256 related functions
  function createUint256(bytes32 key, uint256 value) external returns (bool);
  function createUint256s(bytes32[] keys, uint256[] values) external returns (bool);
  function updateUint256(bytes32 key, uint256 value) external returns (bool);
  function updateUint256s(bytes32[] keys, uint256[] values) external returns (bool);
  function removeUint256(bytes32 key) external returns (bool);
  function removeUint256s(bytes32[] keys) external returns (bool);
  function readUint256(bytes32 key) external view returns (uint256);
  function readUint256s(bytes32[] keys) external view returns (uint256[]);
  // int256 related functions
  function createInt256(bytes32 key, int256 value) external returns (bool);
  function createInt256s(bytes32[] keys, int256[] values) external returns (bool);
  function updateInt256(bytes32 key, int256 value) external returns (bool);
  function updateInt256s(bytes32[] keys, int256[] values) external returns (bool);
  function removeInt256(bytes32 key) external returns (bool);
  function removeInt256s(bytes32[] keys) external returns (bool);
  function readInt256(bytes32 key) external view returns (int256);
  function readInt256s(bytes32[] keys) external view returns (int256[]);
  // internal functions
  function parseKey(bytes32 key) internal pure returns (bytes32);
  function parseKeys(bytes32[] _keys) internal pure returns (bytes32[]);
}

library AddressUtils {

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

}

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

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

library SafeMath {

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

    c = a * b;
    assert(c / a == b);
    return c;
  }

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

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

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

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

contract CryptantCrabBase is Ownable {
  GenesisCrabInterface public genesisCrab;
  CryptantCrabNFT public cryptantCrabToken;
  CryptantCrabStoreInterface public cryptantCrabStorage;

  constructor(address _genesisCrabAddress, address _cryptantCrabTokenAddress, address _cryptantCrabStorageAddress) public {
    // constructor
    
    _setAddresses(_genesisCrabAddress, _cryptantCrabTokenAddress, _cryptantCrabStorageAddress);
  }

  function setAddresses(
    address _genesisCrabAddress, 
    address _cryptantCrabTokenAddress, 
    address _cryptantCrabStorageAddress
  ) 
  external onlyOwner {
    _setAddresses(_genesisCrabAddress, _cryptantCrabTokenAddress, _cryptantCrabStorageAddress);
  }

  function _setAddresses(
    address _genesisCrabAddress,
    address _cryptantCrabTokenAddress,
    address _cryptantCrabStorageAddress
  )
  internal 
  {
    if(_genesisCrabAddress != address(0)) {
      GenesisCrabInterface genesisCrabContract = GenesisCrabInterface(_genesisCrabAddress);
      genesisCrab = genesisCrabContract;
    }
    
    if(_cryptantCrabTokenAddress != address(0)) {
      CryptantCrabNFT cryptantCrabTokenContract = CryptantCrabNFT(_cryptantCrabTokenAddress);
      cryptantCrabToken = cryptantCrabTokenContract;
    }
    
    if(_cryptantCrabStorageAddress != address(0)) {
      CryptantCrabStoreInterface cryptantCrabStorageContract = CryptantCrabStoreInterface(_cryptantCrabStorageAddress);
      cryptantCrabStorage = cryptantCrabStorageContract;
    }
  }
}

contract CryptantCrabInformant is CryptantCrabBase{
  constructor
  (
    address _genesisCrabAddress, 
    address _cryptantCrabTokenAddress, 
    address _cryptantCrabStorageAddress
  ) 
  public 
  CryptantCrabBase
  (
    _genesisCrabAddress, 
    _cryptantCrabTokenAddress, 
    _cryptantCrabStorageAddress
  ) {
    // constructor

  }

  function _getCrabData(uint256 _tokenId) internal view returns 
  (
    uint256 _gene, 
    uint256 _level, 
    uint256 _exp, 
    uint256 _mutationCount,
    uint256 _trophyCount,
    uint256 _heartValue,
    uint256 _growthValue
  ) {
    require(cryptantCrabStorage != address(0));

    bytes32[] memory keys = new bytes32[](7);
    uint256[] memory values;

    keys[0] = keccak256(abi.encodePacked(_tokenId, "gene"));
    keys[1] = keccak256(abi.encodePacked(_tokenId, "level"));
    keys[2] = keccak256(abi.encodePacked(_tokenId, "exp"));
    keys[3] = keccak256(abi.encodePacked(_tokenId, "mutationCount"));
    keys[4] = keccak256(abi.encodePacked(_tokenId, "trophyCount"));
    keys[5] = keccak256(abi.encodePacked(_tokenId, "heartValue"));
    keys[6] = keccak256(abi.encodePacked(_tokenId, "growthValue"));

    values = cryptantCrabStorage.readUint256s(keys);

    // process heart value
    uint256 _processedHeartValue;
    for(uint256 i = 1 ; i <= 1000 ; i *= 10) {
      if(uint256(values[5]) / i % 10 > 0) {
        _processedHeartValue += i;
      }
    }

    _gene = values[0];
    _level = values[1];
    _exp = values[2];
    _mutationCount = values[3];
    _trophyCount = values[4];
    _heartValue = _processedHeartValue;
    _growthValue = values[6];
  }

  function _geneOfCrab(uint256 _tokenId) internal view returns (uint256 _gene) {
    require(cryptantCrabStorage != address(0));

    _gene = cryptantCrabStorage.readUint256(keccak256(abi.encodePacked(_tokenId, "gene")));
  }
}

contract CryptantCrabPurchasable is CryptantCrabInformant {
  using SafeMath for uint256;

  event CrabHatched(address indexed owner, uint256 tokenId, uint256 gene, uint256 specialSkin, uint256 crabPrice, uint256 growthValue);
  event CryptantFragmentsAdded(address indexed cryptantOwner, uint256 amount, uint256 newBalance);
  event CryptantFragmentsRemoved(address indexed cryptantOwner, uint256 amount, uint256 newBalance);
  event Refund(address indexed refundReceiver, uint256 reqAmt, uint256 paid, uint256 refundAmt);

  constructor
  (
    address _genesisCrabAddress, 
    address _cryptantCrabTokenAddress, 
    address _cryptantCrabStorageAddress
  ) 
  public 
  CryptantCrabInformant
  (
    _genesisCrabAddress, 
    _cryptantCrabTokenAddress, 
    _cryptantCrabStorageAddress
  ) {
    // constructor

  }

  function getCryptantFragments(address _sender) public view returns (uint256) {
    return cryptantCrabStorage.readUint256(keccak256(abi.encodePacked(_sender, "cryptant")));
  }

  function createCrab(uint256 _customTokenId, uint256 _crabPrice, uint256 _customGene, uint256 _customSkin, uint256 _customHeart, bool _hasLegendary) external onlyOwner {
    return _createCrab(false, _customTokenId, _crabPrice, _customGene, _customSkin, _customHeart, _hasLegendary);
  }

  function _addCryptantFragments(address _cryptantOwner, uint256 _amount) internal returns (uint256 _newBalance) {
    _newBalance = getCryptantFragments(_cryptantOwner).add(_amount);
    cryptantCrabStorage.updateUint256(keccak256(abi.encodePacked(_cryptantOwner, "cryptant")), _newBalance);
    emit CryptantFragmentsAdded(_cryptantOwner, _amount, _newBalance);
  }

  function _removeCryptantFragments(address _cryptantOwner, uint256 _amount) internal returns (uint256 _newBalance) {
    _newBalance = getCryptantFragments(_cryptantOwner).sub(_amount);
    cryptantCrabStorage.updateUint256(keccak256(abi.encodePacked(_cryptantOwner, "cryptant")), _newBalance);
    emit CryptantFragmentsRemoved(_cryptantOwner, _amount, _newBalance);
  }

  function _createCrab(bool _isPresale, uint256 _tokenId, uint256 _crabPrice, uint256 _customGene, uint256 _customSkin, uint256 _customHeart, bool _hasLegendary) internal {
    uint256[] memory _values = new uint256[](4);
    bytes32[] memory _keys = new bytes32[](4);

    uint256 _gene;
    uint256 _specialSkin;
    uint256 _heartValue;
    uint256 _growthValue;
    if(_customGene == 0) {
      (_gene, _specialSkin, _heartValue, _growthValue) = genesisCrab.generateCrabGene(_isPresale, _hasLegendary);
    } else {
      _gene = _customGene;
    }

    if(_customSkin != 0) {
      _specialSkin = _customSkin;
    }

    if(_customHeart != 0) {
      _heartValue = _customHeart;
    } else if (_heartValue == 0) {
      (_heartValue, _growthValue) = genesisCrab.generateCrabHeart();
    }
    
    cryptantCrabToken.mintToken(msg.sender, _tokenId, _specialSkin);

    // Gene pair
    _keys[0] = keccak256(abi.encodePacked(_tokenId, "gene"));
    _values[0] = _gene;

    // Level pair
    _keys[1] = keccak256(abi.encodePacked(_tokenId, "level"));
    _values[1] = 1;

    // Heart Value pair
    _keys[2] = keccak256(abi.encodePacked(_tokenId, "heartValue"));
    _values[2] = _heartValue;

    // Growth Value pair
    _keys[3] = keccak256(abi.encodePacked(_tokenId, "growthValue"));
    _values[3] = _growthValue;

    require(cryptantCrabStorage.createUint256s(_keys, _values));

    emit CrabHatched(msg.sender, _tokenId, _gene, _specialSkin, _crabPrice, _growthValue);
  }

  function _refundExceededValue(uint256 _senderValue, uint256 _requiredValue) internal {
    uint256 _exceededValue = _senderValue.sub(_requiredValue);

    if(_exceededValue > 0) {
      msg.sender.transfer(_exceededValue);

      emit Refund(msg.sender, _requiredValue, _senderValue, _exceededValue);
    } 
  }
}

contract Withdrawable is Ownable {
  address public withdrawer;

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

  function setWithdrawer(address _newWithdrawer) external onlyOwner {
    withdrawer = _newWithdrawer;
  }

  /**
   * @dev withdraw the specified amount of ether from contract.
   * @param _amount the amount of ether to withdraw. Units in wei.
   */
  function withdraw(uint256 _amount) external onlyWithdrawer returns(bool) {
    require(_amount <= address(this).balance);
    withdrawer.transfer(_amount);
    return true;
  }
}

contract HasNoEther is Ownable {

  /**
  * @dev Constructor that rejects incoming Ether
  * The `payable` flag is added so we can access `msg.value` without compiler warning. If we
  * leave out payable, then Solidity will allow inheriting contracts to implement a payable
  * constructor. By doing it this way we prevent a payable constructor from working. Alternatively
  * we could use assembly to access msg.value.
  */
  constructor() public payable {
    require(msg.value == 0);
  }

  /**
   * @dev Disallows direct send by settings a default function without the `payable` flag.
   */
  function() external {
  }

  /**
   * @dev Transfer all Ether held by the contract to the owner.
   */
  function reclaimEther() external onlyOwner {
    owner.transfer(address(this).balance);
  }
}

contract CryptantCrabPresale is CryptantCrabPurchasable, HasNoEther, Withdrawable, Randomable {
  event PresalePurchased(address indexed owner, uint256 amount, uint256 cryptant, uint256 refund);

  uint256 constant public PRICE_INCREMENT = 1 finney;

  uint256 constant public PRESALE_LIMIT = 5000;

  uint256 constant public PRESALE_MAX_PRICE = 490 finney;

  /**
   * @dev Currently is set to 17/11/2018 00:00:00
   */
  uint256 public presaleEndTime = 1542412800;

  /**
   * @dev Initial presale price is 0.12 ether
   */
  uint256 public currentPresalePrice = 120 finney;

  /**
   * @dev The number of seconds that the presale price will stay fixed. 
   */
  uint256 constant public presalePriceUpdatePeriod = 3600;

  /**
   * @dev Keep tracks on the presale price period.
   *  initial period = (GMT): Thursday, October 25, 2018 12:00:00 AM
   */
  uint256 public currentPresalePeriod = 427896;

  /** 
   * @dev tracks the current token id, starts from 10
   */
  uint256 public currentTokenId = 10;

  /** 
   * @dev tracks the current giveaway token id, starts from 5001
   */
  uint256 public giveawayTokenId = 5001;

  constructor
  (
    address _genesisCrabAddress, 
    address _cryptantCrabTokenAddress, 
    address _cryptantCrabStorageAddress
  ) 
  public 
  CryptantCrabPurchasable
  (
    _genesisCrabAddress, 
    _cryptantCrabTokenAddress, 
    _cryptantCrabStorageAddress
  ) {
    // constructor

  }

  function setPresaleEndtime(uint256 _newEndTime) external onlyOwner {
    presaleEndTime = _newEndTime;
  }

  function getPresalePrice() public returns (uint256) {
    uint256 _currentPresalePeriod = now / presalePriceUpdatePeriod;

    if(_currentPresalePeriod > currentPresalePeriod) {
      // need to update current presale price
      uint256 _periodDifference = _currentPresalePeriod - currentPresalePeriod;

      uint256 _newPrice = PRICE_INCREMENT * _periodDifference;

      if(_newPrice <= PRESALE_MAX_PRICE) {
        currentPresalePrice += _newPrice;
        currentPresalePeriod = _currentPresalePeriod;
      } else {
        if (currentPresalePrice != PRESALE_MAX_PRICE) {
          currentPresalePrice = PRESALE_MAX_PRICE;
          currentPresalePeriod = _currentPresalePeriod;
        }
      }

      return currentPresalePrice;
    } else {
      return currentPresalePrice;
    }
  }

  function purchase(uint256 _amount) external payable {
    require(genesisCrab != address(0));
    require(cryptantCrabToken != address(0));
    require(cryptantCrabStorage != address(0));
    require(_amount > 0 && _amount <= 10);
    require(isPresale());
    require(PRESALE_LIMIT >= currentTokenId + _amount);

    uint256 _value = msg.value;
    uint256 _currentPresalePrice = getPresalePrice();
    uint256 _totalRequiredAmount = _currentPresalePrice * _amount;

    require(_value >= _totalRequiredAmount);

    // Purchase 10 crabs will have 1 crab with legendary part
    // Default value for _crabWithLegendaryPart is just a unreacable number
    uint256 _crabWithLegendaryPart = 100;
    if(_amount == 10) {
      // decide which crab will have the legendary part
      _crabWithLegendaryPart = _generateRandomNumber(bytes32(currentTokenId), 10);
    }

    for(uint256 i = 0 ; i < _amount ; i++) {
      currentTokenId++;
      _createCrab(true, currentTokenId, _currentPresalePrice, 0, 0, 0, _crabWithLegendaryPart == i);
    }

    // Presale crab will get free cryptant fragments
    _addCryptantFragments(msg.sender, (i * 3000));

    // Refund exceeded value
    _refundExceededValue(_value, _totalRequiredAmount);

    emit PresalePurchased(msg.sender, _amount, i * 3000, _value - _totalRequiredAmount);
  }

  function createCrab(uint256 _customTokenId, uint256 _crabPrice, uint256 _customGene, uint256 _customSkin, uint256 _customHeart, bool _hasLegendary) external onlyOwner {
    return _createCrab(true, _customTokenId, _crabPrice, _customGene, _customSkin, _customHeart, _hasLegendary);
  }

  function generateGiveawayCrabs(uint256 _amount) external onlyOwner {
    for(uint256 i = 0 ; i < _amount ; i++) {
      _createCrab(false, giveawayTokenId++, 120 finney, 0, 0, 0, false);
    }
  }

  function isPresale() internal view returns (bool) {
    return now < presaleEndTime;
  }

  function setCurrentPresalePeriod(uint256 _newPresalePeriod) external onlyOwner {
    currentPresalePeriod = _newPresalePeriod;
  }
}

contract RBAC {
  using Roles for Roles.Role;

  mapping (string => Roles.Role) private roles;

  event RoleAdded(address indexed operator, string role);
  event RoleRemoved(address indexed operator, string role);

  /**
   * @dev reverts if addr does not have role
   * @param _operator address
   * @param _role the name of the role
   * // reverts
   */
  function checkRole(address _operator, string _role)
    view
    public
  {
    roles[_role].check(_operator);
  }

  /**
   * @dev determine if addr has role
   * @param _operator address
   * @param _role the name of the role
   * @return bool
   */
  function hasRole(address _operator, string _role)
    view
    public
    returns (bool)
  {
    return roles[_role].has(_operator);
  }

  /**
   * @dev add a role to an address
   * @param _operator address
   * @param _role the name of the role
   */
  function addRole(address _operator, string _role)
    internal
  {
    roles[_role].add(_operator);
    emit RoleAdded(_operator, _role);
  }

  /**
   * @dev remove a role from an address
   * @param _operator address
   * @param _role the name of the role
   */
  function removeRole(address _operator, string _role)
    internal
  {
    roles[_role].remove(_operator);
    emit RoleRemoved(_operator, _role);
  }

  /**
   * @dev modifier to scope access to a single role (uses msg.sender as addr)
   * @param _role the name of the role
   * // reverts
   */
  modifier onlyRole(string _role)
  {
    checkRole(msg.sender, _role);
    _;
  }

  /**
   * @dev modifier to scope access to a set of roles (uses msg.sender as addr)
   * @param _roles the names of the roles to scope access to
   * // reverts
   *
   * @TODO - when solidity supports dynamic arrays as arguments to modifiers, provide this
   *  see: https://github.com/ethereum/solidity/issues/2467
   */
  // modifier onlyRoles(string[] _roles) {
  //     bool hasAnyRole = false;
  //     for (uint8 i = 0; i < _roles.length; i++) {
  //         if (hasRole(msg.sender, _roles[i])) {
  //             hasAnyRole = true;
  //             break;
  //         }
  //     }

  //     require(hasAnyRole);

  //     _;
  // }
}

contract Whitelist is Ownable, RBAC {
  string public constant ROLE_WHITELISTED = "whitelist";

  /**
   * @dev Throws if operator is not whitelisted.
   * @param _operator address
   */
  modifier onlyIfWhitelisted(address _operator) {
    checkRole(_operator, ROLE_WHITELISTED);
    _;
  }

  /**
   * @dev add an address to the whitelist
   * @param _operator address
   * @return true if the address was added to the whitelist, false if the address was already in the whitelist
   */
  function addAddressToWhitelist(address _operator)
    onlyOwner
    public
  {
    addRole(_operator, ROLE_WHITELISTED);
  }

  /**
   * @dev getter to determine if address is in whitelist
   */
  function whitelist(address _operator)
    public
    view
    returns (bool)
  {
    return hasRole(_operator, ROLE_WHITELISTED);
  }

  /**
   * @dev add addresses to the whitelist
   * @param _operators addresses
   * @return true if at least one address was added to the whitelist,
   * false if all addresses were already in the whitelist
   */
  function addAddressesToWhitelist(address[] _operators)
    onlyOwner
    public
  {
    for (uint256 i = 0; i < _operators.length; i++) {
      addAddressToWhitelist(_operators[i]);
    }
  }

  /**
   * @dev remove an address from the whitelist
   * @param _operator address
   * @return true if the address was removed from the whitelist,
   * false if the address wasn't in the whitelist in the first place
   */
  function removeAddressFromWhitelist(address _operator)
    onlyOwner
    public
  {
    removeRole(_operator, ROLE_WHITELISTED);
  }

  /**
   * @dev remove addresses from the whitelist
   * @param _operators addresses
   * @return true if at least one address was removed from the whitelist,
   * false if all addresses weren't in the whitelist in the first place
   */
  function removeAddressesFromWhitelist(address[] _operators)
    onlyOwner
    public
  {
    for (uint256 i = 0; i < _operators.length; i++) {
      removeAddressFromWhitelist(_operators[i]);
    }
  }

}

library Roles {
  struct Role {
    mapping (address => bool) bearer;
  }

  /**
   * @dev give an address access to this role
   */
  function add(Role storage role, address addr)
    internal
  {
    role.bearer[addr] = true;
  }

  /**
   * @dev remove an address' access to this role
   */
  function remove(Role storage role, address addr)
    internal
  {
    role.bearer[addr] = false;
  }

  /**
   * @dev check if an address has this role
   * // reverts
   */
  function check(Role storage role, address addr)
    view
    internal
  {
    require(has(role, addr));
  }

  /**
   * @dev check if an address has this role
   * @return bool
   */
  function has(Role storage role, address addr)
    view
    internal
    returns (bool)
  {
    return role.bearer[addr];
  }
}

contract ERC721Basic is ERC165 {
  event Transfer(
    address indexed _from,
    address indexed _to,
    uint256 indexed _tokenId
  );
  event Approval(
    address indexed _owner,
    address indexed _approved,
    uint256 indexed _tokenId
  );
  event ApprovalForAll(
    address indexed _owner,
    address indexed _operator,
    bool _approved
  );

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

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

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

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

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

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

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

contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata {
}

contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic {

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

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

  using SafeMath for uint256;
  using AddressUtils for address;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    emit Transfer(_from, _to, _tokenId);
  }

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

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

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

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

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

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

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

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

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

contract ERC721Receiver {
  /**
   * @dev Magic value to be returned upon successful reception of an NFT
   *  Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`,
   *  which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
   */
  bytes4 internal constant ERC721_RECEIVED = 0x150b7a02;

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

contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 {

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

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

  // Token name
  string internal name_;

  // Token symbol
  string internal symbol_;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

}

contract CryptantCrabNFT is ERC721Token, Whitelist, CrabData, GeneSurgeon {
  event CrabPartAdded(uint256 hp, uint256 dps, uint256 blockAmount);
  event GiftTransfered(address indexed _from, address indexed _to, uint256 indexed _tokenId);
  event DefaultMetadataURIChanged(string newUri);

  /**
   * @dev Pre-generated keys to save gas
   * keys are generated with:
   * CRAB_BODY       = bytes4(keccak256("crab_body"))       = 0xc398430e
   * CRAB_LEG        = bytes4(keccak256("crab_leg"))        = 0x889063b1
   * CRAB_LEFT_CLAW  = bytes4(keccak256("crab_left_claw"))  = 0xdb6290a2
   * CRAB_RIGHT_CLAW = bytes4(keccak256("crab_right_claw")) = 0x13453f89
   */
  bytes4 internal constant CRAB_BODY = 0xc398430e;
  bytes4 internal constant CRAB_LEG = 0x889063b1;
  bytes4 internal constant CRAB_LEFT_CLAW = 0xdb6290a2;
  bytes4 internal constant CRAB_RIGHT_CLAW = 0x13453f89;

  /**
   * @dev Stores all the crab data
   */
  mapping(bytes4 => mapping(uint256 => CrabPartData[])) internal crabPartData;

  /**
   * @dev Mapping from tokenId to its corresponding special skin
   * tokenId with default skin will not be stored. 
   */
  mapping(uint256 => uint256) internal crabSpecialSkins;

  /**
   * @dev default MetadataURI
   */
  string public defaultMetadataURI = "https://www.cryptantcrab.io/md/";

  constructor(string _name, string _symbol) public ERC721Token(_name, _symbol) {
    // constructor
    initiateCrabPartData();
  }

  /**
   * @dev Returns an URI for a given token ID
   * Throws if the token ID does not exist.
   * Will return the token's metadata URL if it has one, 
   * otherwise will just return base on the default metadata URI
   * @param _tokenId uint256 ID of the token to query
   */
  function tokenURI(uint256 _tokenId) public view returns (string) {
    require(exists(_tokenId));

    string memory _uri = tokenURIs[_tokenId];

    if(bytes(_uri).length == 0) {
      _uri = getMetadataURL(bytes(defaultMetadataURI), _tokenId);
    }

    return _uri;
  }

  /**
   * @dev Returns the data of a specific parts
   * @param _partIndex the part to retrieve. 1 = Body, 2 = Legs, 3 = Left Claw, 4 = Right Claw
   * @param _element the element of part to retrieve. 1 = Fire, 2 = Earth, 3 = Metal, 4 = Spirit, 5 = Water
   * @param _setIndex the set index of for the specified part. This will starts from 1.
   */
  function dataOfPart(uint256 _partIndex, uint256 _element, uint256 _setIndex) public view returns (uint256[] memory _resultData) {
    bytes4 _key;
    if(_partIndex == 1) {
      _key = CRAB_BODY;
    } else if(_partIndex == 2) {
      _key = CRAB_LEG;
    } else if(_partIndex == 3) {
      _key = CRAB_LEFT_CLAW;
    } else if(_partIndex == 4) {
      _key = CRAB_RIGHT_CLAW;
    } else {
      revert();
    }

    CrabPartData storage _crabPartData = crabPartData[_key][_element][_setIndex];

    _resultData = crabPartDataToArray(_crabPartData);
  }

  /**
   * @dev Gift(Transfer) a token to another address. Caller must be token owner
   * @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 giftToken(address _from, address _to, uint256 _tokenId) external {
    safeTransferFrom(_from, _to, _tokenId);

    emit GiftTransfered(_from, _to, _tokenId);
  }

  /**
   * @dev External function to mint a new token, for whitelisted address only.
   * Reverts if the given token ID already exists
   * @param _tokenOwner address the beneficiary that will own the minted token
   * @param _tokenId uint256 ID of the token to be minted by the msg.sender
   * @param _skinId the skin ID to be applied for all the token minted
   */
  function mintToken(address _tokenOwner, uint256 _tokenId, uint256 _skinId) external onlyIfWhitelisted(msg.sender) {
    super._mint(_tokenOwner, _tokenId);

    if(_skinId > 0) {
      crabSpecialSkins[_tokenId] = _skinId;
    }
  }

  /**
   * @dev Returns crab data base on the gene provided
   * @param _gene the gene info where crab data will be retrieved base on it
   * @return 4 uint arrays:
   * 1st Array = Body's Data
   * 2nd Array = Leg's Data
   * 3rd Array = Left Claw's Data
   * 4th Array = Right Claw's Data
   */
  function crabPartDataFromGene(uint256 _gene) external view returns (
    uint256[] _bodyData,
    uint256[] _legData,
    uint256[] _leftClawData,
    uint256[] _rightClawData
  ) {
    uint256[] memory _parts = extractPartsFromGene(_gene);
    uint256[] memory _elements = extractElementsFromGene(_gene);

    _bodyData = dataOfPart(1, _elements[0], _parts[0]);
    _legData = dataOfPart(2, _elements[1], _parts[1]);
    _leftClawData = dataOfPart(3, _elements[2], _parts[2]);
    _rightClawData = dataOfPart(4, _elements[3], _parts[3]);
  }

  /**
   * @dev For developer to add new parts, notice that this is the only method to add crab data
   * so that developer can add extra content. there's no other method for developer to modify
   * the data. This is to assure token owner actually owns their data.
   * @param _partIndex the part to add. 1 = Body, 2 = Legs, 3 = Left Claw, 4 = Right Claw
   * @param _element the element of part to add. 1 = Fire, 2 = Earth, 3 = Metal, 4 = Spirit, 5 = Water
   * @param _partDataArray data of the parts.
   */
  function setPartData(uint256 _partIndex, uint256 _element, uint256[] _partDataArray) external onlyOwner {
    CrabPartData memory _partData = arrayToCrabPartData(_partDataArray);

    bytes4 _key;
    if(_partIndex == 1) {
      _key = CRAB_BODY;
    } else if(_partIndex == 2) {
      _key = CRAB_LEG;
    } else if(_partIndex == 3) {
      _key = CRAB_LEFT_CLAW;
    } else if(_partIndex == 4) {
      _key = CRAB_RIGHT_CLAW;
    }

    // if index 1 is empty will fill at index 1
    if(crabPartData[_key][_element][1].hp == 0 && crabPartData[_key][_element][1].dps == 0) {
      crabPartData[_key][_element][1] = _partData;
    } else {
      crabPartData[_key][_element].push(_partData);
    }

    emit CrabPartAdded(_partDataArray[0], _partDataArray[1], _partDataArray[2]);
  }

  /**
   * @dev Updates the default metadata URI
   * @param _defaultUri the new metadata URI
   */
  function setDefaultMetadataURI(string _defaultUri) external onlyOwner {
    defaultMetadataURI = _defaultUri;

    emit DefaultMetadataURIChanged(_defaultUri);
  }

  /**
   * @dev Updates the metadata URI for existing token
   * @param _tokenId the tokenID that metadata URI to be changed
   * @param _uri the new metadata URI for the specified token
   */
  function setTokenURI(uint256 _tokenId, string _uri) external onlyIfWhitelisted(msg.sender) {
    _setTokenURI(_tokenId, _uri);
  }

  /**
   * @dev Returns the special skin of the provided tokenId
   * @param _tokenId cryptant crab's tokenId
   * @return Special skin belongs to the _tokenId provided. 
   * 0 will be returned if no special skin found.
   */
  function specialSkinOfTokenId(uint256 _tokenId) external view returns (uint256) {
    return crabSpecialSkins[_tokenId];
  }

  /**
   * @dev This functions will adjust the length of crabPartData
   * so that when adding data the index can start with 1.
   * Reason of doing this is because gene cannot have parts with index 0.
   */
  function initiateCrabPartData() internal {
    require(crabPartData[CRAB_BODY][1].length == 0);

    for(uint256 i = 1 ; i <= 5 ; i++) {
      crabPartData[CRAB_BODY][i].length = 2;
      crabPartData[CRAB_LEG][i].length = 2;
      crabPartData[CRAB_LEFT_CLAW][i].length = 2;
      crabPartData[CRAB_RIGHT_CLAW][i].length = 2;
    }
  }

  /**
   * @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, 
   *  or has been whitelisted by contract owner
   */
  function isApprovedOrOwner(address _spender, uint256 _tokenId) internal view returns (bool) {
    address owner = ownerOf(_tokenId);
    return _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) || whitelist(_spender);
  }

  /**
   * @dev Will merge the uri and tokenId together. 
   * @param _uri URI to be merge. This will be the first part of the result URL.
   * @param _tokenId tokenID to be merge. This will be the last part of the result URL.
   * @return the merged urL
   */
  function getMetadataURL(bytes _uri, uint256 _tokenId) internal pure returns (string) {
    uint256 _tmpTokenId = _tokenId;
    uint256 _tokenLength;

    // Getting the length(number of digits) of token ID
    do {
      _tokenLength++;
      _tmpTokenId /= 10;
    } while (_tmpTokenId > 0);

    // creating a byte array with the length of URL + token digits
    bytes memory _result = new bytes(_uri.length + _tokenLength);

    // cloning the uri bytes into the result bytes
    for(uint256 i = 0 ; i < _uri.length ; i ++) {
      _result[i] = _uri[i];
    }

    // appending the tokenId to the end of the result bytes
    uint256 lastIndex = _result.length - 1;
    for(_tmpTokenId = _tokenId ; _tmpTokenId > 0 ; _tmpTokenId /= 10) {
      _result[lastIndex--] = byte(48 + _tmpTokenId % 10);
    }

    return string(_result);
  }
}

Contract Security Audit

Contract ABI

[{"constant":true,"inputs":[],"name":"currentTokenId","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newWithdrawer","type":"address"}],"name":"setWithdrawer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"PRESALE_LIMIT","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"presaleEndTime","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"presalePriceUpdatePeriod","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_genesisCrabAddress","type":"address"},{"name":"_cryptantCrabTokenAddress","type":"address"},{"name":"_cryptantCrabStorageAddress","type":"address"}],"name":"setAddresses","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"PRESALE_MAX_PRICE","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newEndTime","type":"uint256"}],"name":"setPresaleEndtime","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_customTokenId","type":"uint256"},{"name":"_crabPrice","type":"uint256"},{"name":"_customGene","type":"uint256"},{"name":"_customSkin","type":"uint256"},{"name":"_customHeart","type":"uint256"},{"name":"_hasLegendary","type":"bool"}],"name":"createCrab","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"PRICE_INCREMENT","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":"getPresalePrice","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"genesisCrab","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"reclaimEther","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"currentPresalePeriod","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_sender","type":"address"}],"name":"getCryptantFragments","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"giveawayTokenId","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"withdrawer","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"cryptantCrabStorage","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"cryptantCrabToken","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newPresalePeriod","type":"uint256"}],"name":"setCurrentPresalePeriod","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_amount","type":"uint256"}],"name":"generateGiveawayCrabs","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"currentPresalePrice","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_amount","type":"uint256"}],"name":"purchase","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_genesisCrabAddress","type":"address"},{"name":"_cryptantCrabTokenAddress","type":"address"},{"name":"_cryptantCrabStorageAddress","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":false,"stateMutability":"nonpayable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"cryptant","type":"uint256"},{"indexed":false,"name":"refund","type":"uint256"}],"name":"PresalePurchased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"gene","type":"uint256"},{"indexed":false,"name":"specialSkin","type":"uint256"},{"indexed":false,"name":"crabPrice","type":"uint256"},{"indexed":false,"name":"growthValue","type":"uint256"}],"name":"CrabHatched","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"cryptantOwner","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"newBalance","type":"uint256"}],"name":"CryptantFragmentsAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"cryptantOwner","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"newBalance","type":"uint256"}],"name":"CryptantFragmentsRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"refundReceiver","type":"address"},{"indexed":false,"name":"reqAmt","type":"uint256"},{"indexed":false,"name":"paid","type":"uint256"},{"indexed":false,"name":"refundAmt","type":"uint256"}],"name":"Refund","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"}]

6080604052635bef5a006005556701aa535d3d0c000060065562068778600755600a60085561138960095534801561003657600080fd5b5060405160608061172c83398101604090815281516020830151919092015160008054600160a060020a031916331790558282828282828282826100848383836401000000006100a2810204565b50503415965061009a9550505050505057600080fd5b505050610137565b60008080600160a060020a038616156100d45760018054600160a060020a031916600160a060020a0388161790558592505b600160a060020a038516156101025760028054600160a060020a031916600160a060020a0387161790558491505b600160a060020a0384161561012f575060038054600160a060020a031916600160a060020a038516179055825b505050505050565b6115e6806101466000396000f3006080604052600436106101445763ffffffff60e060020a6000350416629a9b7b81146101535780630d174c241461017a5780631aee3f911461019d578063249b7c19146101b257806326d75676146101c75780632e1a7d4d146101dc578063363bf964146102085780633deb217d146102355780634ecf30e41461024a57806364c3dae6146102625780636d25d8021461028b578063715018a6146102a057806377ee4b0f146102b55780637d9527d6146102ca5780638da5cb5b146102fb5780639f727c2714610310578063c6051b7e14610325578063cc89d5961461033a578063cd99754a1461035b578063cdc1842414610370578063dede553f14610385578063e43e9de01461039a578063e828eb2c146103af578063ec243555146103c7578063ef030012146103df578063efef39a1146103f4578063f2fde38b146103ff575b34801561015057600080fd5b50005b34801561015f57600080fd5b50610168610420565b60408051918252519081900360200190f35b34801561018657600080fd5b5061019b600160a060020a0360043516610426565b005b3480156101a957600080fd5b5061016861046c565b3480156101be57600080fd5b50610168610472565b3480156101d357600080fd5b50610168610478565b3480156101e857600080fd5b506101f460043561047e565b604080519115158252519081900360200190f35b34801561021457600080fd5b5061019b600160a060020a03600435811690602435811690604435166104e9565b34801561024157600080fd5b50610168610510565b34801561025657600080fd5b5061019b60043561051c565b34801561026e57600080fd5b5061019b60043560243560443560643560843560a4351515610538565b34801561029757600080fd5b50610168610567565b3480156102ac57600080fd5b5061019b610572565b3480156102c157600080fd5b506101686105de565b3480156102d657600080fd5b506102df610654565b60408051600160a060020a039092168252519081900360200190f35b34801561030757600080fd5b506102df610663565b34801561031c57600080fd5b5061019b610672565b34801561033157600080fd5b506101686106c7565b34801561034657600080fd5b50610168600160a060020a03600435166106cd565b34801561036757600080fd5b5061016861081e565b34801561037c57600080fd5b506102df610824565b34801561039157600080fd5b506102df610833565b3480156103a657600080fd5b506102df610842565b3480156103bb57600080fd5b5061019b600435610851565b3480156103d357600080fd5b5061019b60043561086d565b3480156103eb57600080fd5b506101686108c1565b61019b6004356108c7565b34801561040b57600080fd5b5061019b600160a060020a0360043516610a30565b60085481565b600054600160a060020a0316331461043d57600080fd5b6004805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b61138881565b60055481565b610e1081565b600454600090600160a060020a0316331461049857600080fd5b30318211156104a657600080fd5b600454604051600160a060020a039091169083156108fc029084906000818181858888f193505050501580156104e0573d6000803e3d6000fd5b50600192915050565b600054600160a060020a0316331461050057600080fd5b61050b838383610a50565b505050565b6706ccd46763f1000081565b600054600160a060020a0316331461053357600080fd5b600555565b600054600160a060020a0316331461054f57600080fd5b61055f6001878787878787610b0b565b505050505050565b66038d7ea4c6800081565b600054600160a060020a0316331461058957600080fd5b60008054604051600160a060020a03909116917ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482091a26000805473ffffffffffffffffffffffffffffffffffffffff19169055565b6000808080610e1042049250600754831115610649575050600754810366038d7ea4c6800081026706ccd46763f1000081116106265760068054820190556007839055610649565b6006546706ccd46763f1000014610649576706ccd46763f1000060065560078390555b600654935050505090565b600154600160a060020a031681565b600054600160a060020a031681565b600054600160a060020a0316331461068957600080fd5b60008054604051600160a060020a0390911691303180156108fc02929091818181858888f193505050501580156106c4573d6000803e3d6000fd5b50565b60075481565b6000600360009054906101000a9004600160a060020a0316600160a060020a03166389853691836040516020018082600160a060020a0316600160a060020a03166c01000000000000000000000000028152601401807f6372797074616e740000000000000000000000000000000000000000000000008152506008019150506040516020818303038152906040526040518082805190602001908083835b6020831061078b5780518252601f19909201916020918201910161076c565b51815160209384036101000a60001901801990921691161790526040805192909401829003822063ffffffff881660e060020a0283526004830152925160248083019650939450929083900301905081600087803b1580156107ec57600080fd5b505af1158015610800573d6000803e3d6000fd5b505050506040513d602081101561081657600080fd5b505192915050565b60095481565b600454600160a060020a031681565b600354600160a060020a031681565b600254600160a060020a031681565b600054600160a060020a0316331461086857600080fd5b600755565b60008054600160a060020a0316331461088557600080fd5b5060005b818110156108bd5760098054600181019091556108b5906000906701aa535d3d0c000082808080610b0b565b600101610889565b5050565b60065481565b6001546000908190819081908190600160a060020a031615156108e957600080fd5b600254600160a060020a0316151561090057600080fd5b600354600160a060020a0316151561091757600080fd5b6000861180156109285750600a8611155b151561093357600080fd5b61093b61123f565b151561094657600080fd5b6008548601611388101561095957600080fd5b3494506109646105de565b935085840292508285101561097857600080fd5b6064915085600a14156109965760085461099390600a611247565b91505b5060005b858110156109c857600880546001908101918290556109c0918660008080888814610b0b565b60010161099a565b6109d63382610bb802611264565b506109e185846113f9565b60408051878152610bb88302602082015284870381830152905133917f260ecffe36a912f3688d7fa915793137bbaf0980df289ffad7ae877d7ca0a23b919081900360600190a2505050505050565b600054600160a060020a03163314610a4757600080fd5b6106c48161148c565b60008080600160a060020a03861615610a8f576001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0388161790558592505b600160a060020a03851615610aca576002805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0387161790558491505b600160a060020a0384161561055f575060038054600160a060020a03851673ffffffffffffffffffffffffffffffffffffffff199091161790555050505050565b6060806000806000806004604051908082528060200260200182016040528015610b3f578160200160208202803883390190505b5060408051600480825260a0820190925291975060208201608080388339019050509450891515610c2657600154604080517f9d0c0c350000000000000000000000000000000000000000000000000000000081528f1515600482015289151560248201529051600160a060020a0390921691639d0c0c35916044808201926080929091908290030181600087803b158015610bda57600080fd5b505af1158015610bee573d6000803e3d6000fd5b505050506040513d6080811015610c0457600080fd5b5080516020820151604083015160609093015191965094509092509050610c2a565b8993505b8815610c34578892505b8715610c4257879150610cdf565b811515610cdf57600154604080517f6f9fbd7c0000000000000000000000000000000000000000000000000000000081528151600160a060020a0390931692636f9fbd7c926004808401939192918290030181600087803b158015610ca657600080fd5b505af1158015610cba573d6000803e3d6000fd5b505050506040513d6040811015610cd057600080fd5b50805160209091015190925090505b600254604080517f23a36d2b000000000000000000000000000000000000000000000000000000008152336004820152602481018f9052604481018690529051600160a060020a03909216916323a36d2b9160648082019260009290919082900301818387803b158015610d5257600080fd5b505af1158015610d66573d6000803e3d6000fd5b505050508b60405160200180828152602001807f67656e65000000000000000000000000000000000000000000000000000000008152506004019150506040516020818303038152906040526040518082805190602001908083835b60208310610de15780518252601f199092019160209182019101610dc2565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040518091039020856000815181101515610e1d57fe5b602090810290910101528551849087906000908110610e3857fe5b6020908102909101810191909152604080518083018f90527f6c6576656c0000000000000000000000000000000000000000000000000000008183015281516025818303018152604590910191829052805190928291908401908083835b60208310610eb55780518252601f199092019160209182019101610e96565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040518091039020856001815181101515610ef157fe5b602090810290910101528551600190879082908110610f0c57fe5b6020908102909101810191909152604080518083018f90527f686561727456616c756500000000000000000000000000000000000000000000818301528151602a818303018152604a90910191829052805190928291908401908083835b60208310610f895780518252601f199092019160209182019101610f6a565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040518091039020856002815181101515610fc557fe5b602090810290910101528551829087906002908110610fe057fe5b6020908102909101810191909152604080518083018f90527f67726f77746856616c7565000000000000000000000000000000000000000000818301528151602b818303018152604b90910191829052805190928291908401908083835b6020831061105d5780518252601f19909201916020918201910161103e565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902085600381518110151561109957fe5b6020908102909101015285518190879060039081106110b457fe5b6020908102909101810191909152600354604080517fedf87aff00000000000000000000000000000000000000000000000000000000815260048101918252885160448201528851600160a060020a039093169363edf87aff938a938c9390928392602483019260640191878101910280838360005b8381101561114257818101518382015260200161112a565b50505050905001838103825284818151815260200191508051906020019060200280838360005b83811015611181578181015183820152602001611169565b50505050905001945050505050602060405180830381600087803b1580156111a857600080fd5b505af11580156111bc573d6000803e3d6000fd5b505050506040513d60208110156111d257600080fd5b505115156111df57600080fd5b604080518d815260208101869052808201859052606081018d905260808101839052905133917f119326b1fd8ed92ff4f7d9da36e3caa7d39681c38d437053fe7e3965cf74aaf8919081900360a00190a250505050505050505050505050565b600554421090565b60008161125384611509565b81151561125c57fe5b069392505050565b600061127f82611273856106cd565b9063ffffffff61159516565b60035460408051600160a060020a038781166c01000000000000000000000000026020808401919091527f6372797074616e7400000000000000000000000000000000000000000000000060348401528351808403601c018152603c90930193849052825195965093169363adb44a32939192918291908401908083835b6020831061131c5780518252601f1990920191602091820191016112fd565b51815160209384036101000a60001901801990921691161790526040805192909401829003822063ffffffff881660e060020a028352600483015260248201899052925160448083019650939450929083900301905081600087803b15801561138457600080fd5b505af1158015611398573d6000803e3d6000fd5b505050506040513d60208110156113ae57600080fd5b505060408051838152602081018390528151600160a060020a038616927fed28291c8ece55af2a3498316da394241d9026fd7256843843d9f4fa0a56f1e0928290030190a292915050565b600061140b838363ffffffff6115a816565b9050600081111561050b57604051339082156108fc029083906000818181858888f19350505050158015611443573d6000803e3d6000fd5b506040805183815260208101859052808201839052905133917fb7048c2ad36aadee977bb16b4543a18866044d27a2ca753e1c7dbcfa7d7a6962919081900360600190a2505050565b600160a060020a03811615156114a157600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b604080516000194301406020808301919091528183018490528251808303840181526060909201928390528151600093918291908401908083835b602083106115635780518252601f199092019160209182019101611544565b5181516020939093036101000a6000190180199091169216919091179052604051920182900390912095945050505050565b818101828110156115a257fe5b92915050565b6000828211156115b457fe5b509003905600a165627a7a723058209e8b7ceccd038769766cdfcf3c18c3001db72f7e07ec60672c7ca58368aace420029000000000000000000000000837ddb7a9e71070848a545acb266997327a59413000000000000000000000000ecd6b4a2f82b0c9fb283a4a8a1ef5adf555f794b000000000000000000000000c58e24f5b05365aa21ded72111af939446d13b2e

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

000000000000000000000000837ddb7a9e71070848a545acb266997327a59413000000000000000000000000ecd6b4a2f82b0c9fb283a4a8a1ef5adf555f794b000000000000000000000000c58e24f5b05365aa21ded72111af939446d13b2e

-----Decoded View---------------
Arg [0] : _genesisCrabAddress (address): 0x837dDB7A9e71070848A545Acb266997327a59413
Arg [1] : _cryptantCrabTokenAddress (address): 0xECd6b4A2f82b0c9FB283A4a8a1ef5ADf555f794b
Arg [2] : _cryptantCrabStorageAddress (address): 0xc58e24f5B05365Aa21DED72111af939446D13B2e

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000837ddb7a9e71070848a545acb266997327a59413
Arg [1] : 000000000000000000000000ecd6b4a2f82b0c9fb283a4a8a1ef5adf555f794b
Arg [2] : 000000000000000000000000c58e24f5b05365aa21ded72111af939446d13b2e


Swarm Source

bzzr://9e8b7ceccd038769766cdfcf3c18c3001db72f7e07ec60672c7ca58368aace42
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.