Contract 0xFe53D681D34CF379782d25AF69990F6A707D30d8 1

 
Txn Hash
Method
Block
From
To
Value
0xfca80805fd03f53b1569c6ae967ea170a9939ffb35a21ea133094b9d87ebfac9Create Auction83856012019-08-20 6:20:071132 days 20 hrs agoENS Name martianv2.eth IN  0xfe53d681d34cf379782d25af69990f6a707d30d80 Ether0.00148688
0x383673fddd00041c3cbc0b71d045803a4cf6ebd7d4ce0df1d44b645ab07cc9d4Cancel Auction83564752019-08-15 17:44:481137 days 8 hrs ago0x70a7c5104f8c4cb202b9161657b5fa79cd44c4c4 IN  0xfe53d681d34cf379782d25af69990f6a707d30d80 Ether0.000155014
0x43b64d734410e4f1d1f7d65814444b187c849c276c12a5f17f56d780922964fbCancel Auction83529162019-08-15 4:10:291137 days 22 hrs ago0x70a7c5104f8c4cb202b9161657b5fa79cd44c4c4 IN  0xfe53d681d34cf379782d25af69990f6a707d30d80 Ether0.000155014
0x6ac7903a50bbdfbc920c0ad9c8b0133f2589a0094577617546dcde66c01ca659Create Auction79859652019-06-19 2:08:241195 days 35 mins ago0x70a7c5104f8c4cb202b9161657b5fa79cd44c4c4 IN  0xfe53d681d34cf379782d25af69990f6a707d30d80 Ether0.000341572
0x5cca07f11310c1fdfbf08977d7de72c8e4a5c976cd1d390ce4444cf51ebe38ffCreate Auction79859582019-06-19 2:06:511195 days 36 mins ago0x70a7c5104f8c4cb202b9161657b5fa79cd44c4c4 IN  0xfe53d681d34cf379782d25af69990f6a707d30d80 Ether0.000371572
0x8fc250a48039a813aee77523bbd7386518d457a2adb3b91c98aa10f8ff9b5355Withdraw Balance77550172019-05-13 23:40:531231 days 3 hrs ago0xb6052a08ffad405ce2bffd714c580447afe20c80 IN  0xfe53d681d34cf379782d25af69990f6a707d30d80 Ether0.0006003620
0xb892c527d2df0253b098a1c35804f9cb10989b7f3278be34bc50789be7560408Buy77482992019-05-12 22:17:201232 days 4 hrs ago0x302378226b52644c86213992449d77cb74357b99 IN  0xfe53d681d34cf379782d25af69990f6a707d30d80.5 Ether0.000043751
0xac17efcb7524829fe25e5168a1781b399cb4ebd4a9cb85b4dfa38458aa2d1e12Buy77482902019-05-12 22:16:041232 days 4 hrs ago0x302378226b52644c86213992449d77cb74357b99 IN  0xfe53d681d34cf379782d25af69990f6a707d30d80.5 Ether0.000047441
0x58c06310a651fe568c02d32b96d077a673f2898f3a4ad0020b80abdc2b330aa7Buy77306022019-05-10 4:17:511234 days 22 hrs ago0xa5efec267243e8eb39bb14655a5f2079dcc1135d IN  0xfe53d681d34cf379782d25af69990f6a707d30d80.3 Ether0.000119833
0x4a2a7d82f67e2caa4bca2ab21f7430aa1225fddcd0141ff197f73a25d09c81e5Cancel Auction77097202019-05-06 21:32:161238 days 5 hrs ago0x99bf78c7351f01f3d2fac4b301d9fe7dabf7b0f3 IN  0xfe53d681d34cf379782d25af69990f6a707d30d80 Ether0.000116263
0x51e8f1c35f1d9fac83efdfde58c2c15eb2451ac4f0e4c990a97130644693a6dbWithdraw Balance77078862019-05-06 14:50:181238 days 11 hrs ago0xb6052a08ffad405ce2bffd714c580447afe20c80 IN  0xfe53d681d34cf379782d25af69990f6a707d30d80 Ether0.0006904123
0x1974edc57a56c161142e6a6b35320cc1db08e3953f84859dad0308e1cc99aedaCreate Auction77015552019-05-05 14:49:351239 days 11 hrs ago0xf8be37cf74a05b96ca40e7998b08f237f0f8b80b IN  0xfe53d681d34cf379782d25af69990f6a707d30d80 Ether0.000512363
0x1642caf2a98bb3711be595a21bc02ddbf294e1fd438b167825478e9996de1733Create Auction77015502019-05-05 14:48:291239 days 11 hrs ago0xf8be37cf74a05b96ca40e7998b08f237f0f8b80b IN  0xfe53d681d34cf379782d25af69990f6a707d30d80 Ether0.000512363
0x2d8c651f17282a4b20b2af74fdde89c1f54efbc2b8d60326cbb356ad19ffe9ddCreate Auction77015482019-05-05 14:48:141239 days 11 hrs ago0xf8be37cf74a05b96ca40e7998b08f237f0f8b80b IN  0xfe53d681d34cf379782d25af69990f6a707d30d80 Ether0.000512363
0xc706bac2fab212c55c30c5576c3a9da6c104ce44232979081eed256d722affabCreate Auction77015462019-05-05 14:47:391239 days 11 hrs ago0xf8be37cf74a05b96ca40e7998b08f237f0f8b80b IN  0xfe53d681d34cf379782d25af69990f6a707d30d80 Ether0.000512363
0x3bf28042ef15c87d417bb75cb62690eff97fe1634ead1613954ba02812b73993Create Auction77015442019-05-05 14:47:111239 days 11 hrs ago0xf8be37cf74a05b96ca40e7998b08f237f0f8b80b IN  0xfe53d681d34cf379782d25af69990f6a707d30d80 Ether0.000512363
0x6b739ad035ab7df897d421340f88e12710879ddfcacf27d2db2dac14b13c7147Create Auction77015402019-05-05 14:46:071239 days 11 hrs ago0xf8be37cf74a05b96ca40e7998b08f237f0f8b80b IN  0xfe53d681d34cf379782d25af69990f6a707d30d80 Ether0.000557363
0xc0081e7b3d1830fb7d71d3eb98fd03215e3ad12864dea2da03f65f2edd66cc3bCreate Auction76968722019-05-04 21:11:441240 days 5 hrs ago0x99bf78c7351f01f3d2fac4b301d9fe7dabf7b0f3 IN  0xfe53d681d34cf379782d25af69990f6a707d30d80 Ether0.000371572
0xda93e932d4f2d2488ad4292985cd8e640da94c933900b9acf3056e8eaf35de41Buy76849402019-05-03 0:45:141242 days 1 hr ago0xa5efec267243e8eb39bb14655a5f2079dcc1135d IN  0xfe53d681d34cf379782d25af69990f6a707d30d80.5 Ether0.000119833
0x6371d7309c9bb336e24cfcb8578df4374b90ee5cd4ee2c29ad894ae36663d15cBuy76677942019-04-30 8:47:191244 days 17 hrs ago0xb08185651d1ecefe451e4fb1eacd58378c41f9aa IN  0xfe53d681d34cf379782d25af69990f6a707d30d80.3 Ether0.000142333
0x8255f13a5eb0fc13e3f433502cd5454b67371877e7b5eaf84f153c370b83045bBuy76615322019-04-29 9:23:041245 days 17 hrs agoENS Name tazzy.eth IN  0xfe53d681d34cf379782d25af69990f6a707d30d80.3 Ether0.000142333
0xc4b0adfa9fb5bf46c576586340eaee13d22c769e969f51eaea0de8ff883bdb5fBuy76591782019-04-29 0:45:041246 days 1 hr agoENS Name martianv2.eth IN  0xfe53d681d34cf379782d25af69990f6a707d30d80.6 Ether0.000119833
0xc167fb7b4487ac79197bc469b33ac1b4847eccb55acfc29a99439550d52f4d82Buy76591692019-04-29 0:42:581246 days 2 hrs agoENS Name martianv2.eth IN  0xfe53d681d34cf379782d25af69990f6a707d30d80.45 Ether0.000119833
0xa3aafcd37070e46bae88ab229cf855561af38f5c61dced45757efa468651e1f0Withdraw Balance76202432019-04-22 22:56:191252 days 3 hrs ago0xb6052a08ffad405ce2bffd714c580447afe20c80 IN  0xfe53d681d34cf379782d25af69990f6a707d30d80 Ether0.000030011
0xf78b660bffbd73a1df9de69e7c321d2ecdaa37160f001d55da8e99417fa6ca59Buy75289022019-04-08 17:50:121266 days 8 hrs agoENS Name kingslamma.eth IN  0xfe53d681d34cf379782d25af69990f6a707d30d80.2 Ether0.000079952
[ Download CSV Export 
Latest 22 internal transactions
Parent Txn Hash Block From To Value
0x8fc250a48039a813aee77523bbd7386518d457a2adb3b91c98aa10f8ff9b535577550172019-05-13 23:40:531231 days 3 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xb6052a08ffad405ce2bffd714c580447afe20c800.85 Ether
0xb892c527d2df0253b098a1c35804f9cb10989b7f3278be34bc50789be756040877482992019-05-12 22:17:201232 days 4 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80x1c03985ccc528ce23e9358edb495824447127f460.45 Ether
0x51e8f1c35f1d9fac83efdfde58c2c15eb2451ac4f0e4c990a97130644693a6db77078862019-05-06 14:50:181238 days 11 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xb6052a08ffad405ce2bffd714c580447afe20c802.15 Ether
0xa3aafcd37070e46bae88ab229cf855561af38f5c61dced45757efa468651e1f076202432019-04-22 22:56:191252 days 3 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xb6052a08ffad405ce2bffd714c580447afe20c800.2 Ether
0x768d4dd2a3aa6cd4b4f01a2ed5a2afd83f9bbd44d7298701687eba9258f09b7875051932019-04-05 1:34:321270 days 1 hr ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xb6052a08ffad405ce2bffd714c580447afe20c800.3 Ether
0x87b11952c71011da88b28d346be18e57ee4643429301d1d55eb0788dfc09036274553882019-03-28 6:24:411277 days 20 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xb6052a08ffad405ce2bffd714c580447afe20c802.35 Ether
0xc88b870c71273735043323204cb736cbdbe8b0cb07689c1b7a058a2a245aecba72328752019-02-17 18:04:391316 days 8 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xb6052a08ffad405ce2bffd714c580447afe20c800.35 Ether
0xa418c231a2f130a9c8ba5b81020217a16df2108820b3bee000f3c2e6f611524f71938912019-02-08 16:58:531325 days 9 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xb6052a08ffad405ce2bffd714c580447afe20c8012.85 Ether
0x6522f8f90c0932808ff1775b97700046498813f3175c1aefafa21d9ac70f780b71807402019-02-06 0:31:331328 days 2 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80x76a21710676b853e6fff47f1b1ac2b59b6f4dcbf0.45 Ether
0x7b75bf909f2c7f97a356fe0df3ec109ff39ec34d54524a57f36cd7b0a10a027d71750712019-02-04 20:50:431329 days 5 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xb6052a08ffad405ce2bffd714c580447afe20c802.539 Ether
0x3c092b8edc32f67a8123f76d44977da84dd1c6af6b273ec36252d8886c3fd9e571554662019-01-31 20:37:431333 days 6 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80x492bd2fb3d738fc69d9bde076badbbc645d448250.18 Ether
0x514d7961810fb7e13b45463dca5e410edd674f410fdcf794bd18f734d0b66b0571554552019-01-31 20:35:121333 days 6 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xcf0e9b4746cfb97bae329fe5f696969f6564566a0.171 Ether
0xe6827be23155c2f041dd75ee8f45f5d178f779092effe0d383729547577b653b71490362019-01-30 13:46:041334 days 12 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xb6052a08ffad405ce2bffd714c580447afe20c809 Ether
0xd175db3e6175ab287be94491bb8f2f5c220e2e26620706c162bd32e5b4e941ba71394182019-01-28 14:17:201336 days 12 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xb6052a08ffad405ce2bffd714c580447afe20c8018.95 Ether
0x1a894cb5158d2a5401b255f55d6fbb202cc908763b7214b049824c53eacc940964173522018-09-28 21:23:481458 days 5 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xb6052a08ffad405ce2bffd714c580447afe20c800.25 Ether
0x0b1824ced1208cac9abfaa87c016cb01f471bd602082fd5c648de10b46cd66cd63197612018-09-12 19:13:061474 days 7 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xb6052a08ffad405ce2bffd714c580447afe20c801.5 Ether
0x41fa3d23511668fe2409a592e19649d70436fa4d20a433ce78e64e1927bd548e61524762018-08-15 14:59:391502 days 11 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xb6052a08ffad405ce2bffd714c580447afe20c801.065 Ether
0x463610abbde4c1dd04c383793bcc3cb077c0b977099c8cb684bc5e889836fb4860612732018-07-31 4:57:431517 days 21 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xd04c453461a77b342fea9d1fec558613994011220.135 Ether
0x3da3b7478ec9904f1420ebada697977cd776ecfe48d791d10ce95af39155958e58120722018-06-18 17:30:511560 days 9 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xb6052a08ffad405ce2bffd714c580447afe20c8056.35 Ether
0x1f958d7194ee919bbc6ad860a00c3a25f77920befb694519b556a081c3c276e954759812018-04-20 20:05:391619 days 6 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xb6052a08ffad405ce2bffd714c580447afe20c803.1 Ether
0x2c80a6e2a0e886c821abe23d9718a25f9b4932ac84feeaf145c042fd55fe1ccc54582222018-04-17 18:33:261622 days 8 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xd658f5d40bb13df4244da85f2daba82467b22edd0.18 Ether
0xe25e554ecd54d4e6f86bcd6f297b67af2315aafb78c5ff01b260937316192d1452427172018-03-12 15:18:401658 days 11 hrs ago 0xfe53d681d34cf379782d25af69990f6a707d30d80xb6052a08ffad405ce2bffd714c580447afe20c801.45 Ether
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MonsterAuction

Compiler Version
v0.4.18+commit.9cf6e910

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2018-02-17
*/

pragma solidity ^0.4.18;

/// @title Interface for contracts conforming to ERC-721: Deed Standard
/// @author William Entriken (https://phor.net), et. al.
/// @dev Specification at https://github.com/ethereum/eips/XXXFinalUrlXXX
interface ERC721 {

    // COMPLIANCE WITH ERC-165 (DRAFT) /////////////////////////////////////////

    /// @dev ERC-165 (draft) interface signature for itself
    // bytes4 internal constant INTERFACE_SIGNATURE_ERC165 = // 0x01ffc9a7
    //     bytes4(keccak256('supportsInterface(bytes4)'));

    /// @dev ERC-165 (draft) interface signature for ERC721
    // bytes4 internal constant INTERFACE_SIGNATURE_ERC721 = // 0xda671b9b
    //     bytes4(keccak256('ownerOf(uint256)')) ^
    //     bytes4(keccak256('countOfDeeds()')) ^
    //     bytes4(keccak256('countOfDeedsByOwner(address)')) ^
    //     bytes4(keccak256('deedOfOwnerByIndex(address,uint256)')) ^
    //     bytes4(keccak256('approve(address,uint256)')) ^
    //     bytes4(keccak256('takeOwnership(uint256)'));

    /// @notice Query a contract to see if it supports a certain interface
    /// @dev Returns `true` the interface is supported and `false` otherwise,
    ///  returns `true` for INTERFACE_SIGNATURE_ERC165 and
    ///  INTERFACE_SIGNATURE_ERC721, see ERC-165 for other interface signatures.
    function supportsInterface(bytes4 _interfaceID) external pure returns (bool);

    // PUBLIC QUERY FUNCTIONS //////////////////////////////////////////////////

    /// @notice Find the owner of a deed
    /// @param _deedId The identifier for a deed we are inspecting
    /// @dev Deeds assigned to zero address are considered invalid, and
    ///  queries about them do throw.
    /// @return The non-zero address of the owner of deed `_deedId`, or `throw`
    ///  if deed `_deedId` is not tracked by this contract
    function ownerOf(uint256 _deedId) external view returns (address _owner);

    /// @notice Count deeds tracked by this contract
    /// @return A count of valid deeds tracked by this contract, where each one of
    ///  them has an assigned and queryable owner not equal to the zero address
    function countOfDeeds() external view returns (uint256 _count);

    /// @notice Count all deeds assigned to an owner
    /// @dev Throws if `_owner` is the zero address, representing invalid deeds.
    /// @param _owner An address where we are interested in deeds owned by them
    /// @return The number of deeds owned by `_owner`, possibly zero
    function countOfDeedsByOwner(address _owner) external view returns (uint256 _count);

    /// @notice Enumerate deeds assigned to an owner
    /// @dev Throws if `_index` >= `countOfDeedsByOwner(_owner)` or if
    ///  `_owner` is the zero address, representing invalid deeds.
    /// @param _owner An address where we are interested in deeds owned by them
    /// @param _index A counter less than `countOfDeedsByOwner(_owner)`
    /// @return The identifier for the `_index`th deed assigned to `_owner`,
    ///   (sort order not specified)
    function deedOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256 _deedId);

    // TRANSFER MECHANISM //////////////////////////////////////////////////////

    /// @dev This event emits when ownership of any deed changes by any
    ///  mechanism. This event emits when deeds are created (`from` == 0) and
    ///  destroyed (`to` == 0). Exception: during contract creation, any
    ///  transfers may occur without emitting `Transfer`. At the time of any transfer,
    ///  the "approved taker" is implicitly reset to the zero address.
    event Transfer(address indexed from, address indexed to, uint256 indexed deedId);

    /// @dev The Approve event emits to log the "approved taker" for a deed -- whether
    ///  set for the first time, reaffirmed by setting the same value, or setting to
    ///  a new value. The "approved taker" is the zero address if nobody can take the
    ///  deed now or it is an address if that address can call `takeOwnership` to attempt
    ///  taking the deed. Any change to the "approved taker" for a deed SHALL cause
    ///  Approve to emit. However, an exception, the Approve event will not emit when
    ///  Transfer emits, this is because Transfer implicitly denotes the "approved taker"
    ///  is reset to the zero address.
    event Approval(address indexed owner, address indexed approved, uint256 indexed deedId);

    /// @notice Set the "approved taker" for your deed, or revoke approval by
    ///  setting the zero address. You may `approve` any number of times while
    ///  the deed is assigned to you, only the most recent approval matters. Emits
    ///  an Approval event.
    /// @dev Throws if `msg.sender` does not own deed `_deedId` or if `_to` ==
    ///  `msg.sender` or if `_deedId` is not a valid deed.
    /// @param _deedId The deed for which you are granting approval
    function approve(address _to, uint256 _deedId) external payable;

    /// @notice Become owner of a deed for which you are currently approved
    /// @dev Throws if `msg.sender` is not approved to become the owner of
    ///  `deedId` or if `msg.sender` currently owns `_deedId` or if `_deedId is not a
    ///  valid deed.
    /// @param _deedId The deed that is being transferred
    function takeOwnership(uint256 _deedId) external payable;
}

contract Ownable {
    address public owner;

    /**
    * @dev The Ownable constructor sets the original `owner` of the contract to the sender
    * account.
    */
    function Ownable() 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 transfer control of the contract to a newOwner.
    * @param newOwner The address to transfer ownership to.
    */
    function transferOwnership(address newOwner) public onlyOwner {
        if (newOwner != address(0)) {
            owner = newOwner;
        }
    }
}

contract MonsterAccessControl {
    event ContractUpgrade(address newContract);

     // The addresses of the accounts (or contracts) that can execute actions within each roles.
    address public adminAddress;

    /// @dev Access modifier for CEO-only functionality
    modifier onlyAdmin() {
        require(msg.sender == adminAddress);
        _;
    }
}

// This contract stores all data on the blockchain
// only our other contracts can interact with this
// the data here will be valid for all eternity even if other contracts get updated
// this way we can make sure that our Monsters have a hard-coded value attached to them
// that no one including us can change(!)
contract MonstersData {
    address coreContract;

    struct Monster {
        // timestamp of block when this monster was spawned/created
        uint64 birthTime;

        // generation number
        // gen0 is the very first generation - the later monster spawn the less likely they are to have
        // special attributes and stats
        uint16 generation;

        uint16 mID; // this id (from 1 to 151) is responsible for everything visually like showing the real deal!
        bool tradeable;

        // breeding
        bool female;

        // is this monster exceptionally rare?
        bool shiny;
    }

    // lv1 base stats
    struct MonsterBaseStats {
        uint16 hp;
        uint16 attack;
        uint16 defense;
        uint16 spAttack;
        uint16 spDefense;
        uint16 speed;
    }

    struct Trainer {
        // timestamp of block when this player/trainer was created
        uint64 birthTime;

        // add username
        string username;

        // current area in the "world"
        uint16 currArea;

        address owner;
    }

    // take timestamp of block this game was created on the blockchain
    uint64 creationBlock = uint64(now);
}

contract MonstersBase is MonsterAccessControl, MonstersData {
    /// @dev Transfer event as defined in current draft of ERC721. Emitted every time a monster
    ///  ownership is assigned, including births.
    event Transfer(address from, address to, uint256 tokenId);

    bool lockedMonsterCreator = false;

    MonsterAuction public monsterAuction;
    MonsterCreatorInterface public monsterCreator;

    function setMonsterCreatorAddress(address _address) external onlyAdmin {
        // only set this once so we (the devs) can't cheat!
        require(!lockedMonsterCreator);
        MonsterCreatorInterface candidateContract = MonsterCreatorInterface(_address);

        monsterCreator = candidateContract;
        lockedMonsterCreator = true;
    }

    // An approximation of currently how many seconds are in between blocks.
    uint256 public secondsPerBlock = 15;

    // array containing all monsters in existence
    Monster[] monsters;

    uint8[] areas;
    uint8 areaIndex = 0;

    mapping(address => Trainer) public addressToTrainer;
    /// @dev A mapping from monster IDs to the address that owns them. All monster have
    ///  some valid owner address, even gen0 monster are created with a non-zero owner.
    mapping (uint256 => address) public monsterIndexToOwner;
    // @dev A mapping from owner address to count of tokens that address owns.
    // Used internally inside balanceOf() to resolve ownership count.
    mapping (address => uint256) ownershipTokenCount;
    mapping (uint256 => address) public monsterIndexToApproved;
    mapping (uint256 => string) public monsterIdToNickname;
    mapping (uint256 => bool) public monsterIdToTradeable;
    mapping (uint256 => uint256) public monsterIdToGeneration;
    
    mapping (uint256 => uint8[7]) public monsterIdToIVs;

    // adds new area to world
    function _createArea() internal {
        areaIndex++;
        areas.push(areaIndex);
    }

    function _createMonster(uint256 _generation, address _owner, uint256 _mID, bool _tradeable,
        bool _female, bool _shiny) internal returns (uint)
    {

        Monster memory _monster = Monster({
            generation: uint16(_generation),
            birthTime: uint64(now),
            mID: uint16(_mID),
            tradeable: _tradeable,
            female: _female,
            shiny: _shiny
        });

        uint256 newMonsterId = monsters.push(_monster) - 1;

        require(newMonsterId == uint256(uint32(newMonsterId)));

        monsterIdToNickname[newMonsterId] = "";

        _transfer(0, _owner, newMonsterId);

        return newMonsterId;
    }

    function _createTrainer(string _username, uint16 _starterId, address _owner) internal returns (uint mon) {
        Trainer memory _trainer = Trainer({
            birthTime: uint64(now),
            username: string(_username),
             // sets to first area!,
            currArea: uint16(1),
            owner: address(_owner)
        });

        addressToTrainer[_owner] = _trainer;

        bool gender = monsterCreator.getMonsterGender();

        // starters cannot be traded and are not shiny
        if (_starterId == 1) {
            mon = _createMonster(0, _owner, 1, false, gender, false);
        } else if (_starterId == 2) {
            mon = _createMonster(0, _owner, 4, false, gender, false);
        } else if (_starterId == 3) {
            mon = _createMonster(0, _owner, 7, false, gender, false);
        }
    }

    function _moveToArea(uint16 _newArea, address player) internal {
        addressToTrainer[player].currArea = _newArea;
    }

    // assigns ownership of monster to address
    function _transfer(address _from, address _to, uint256 _tokenId) internal {
        ownershipTokenCount[_to]++;
        monsterIndexToOwner[_tokenId] = _to;

        if (_from != address(0)) {
            ownershipTokenCount[_from]--;

            // clear any previously approved ownership exchange
            delete monsterIndexToApproved[_tokenId];
        }

        // Emit Transfer event
        Transfer(_from, _to, _tokenId);
    }

    // Only admin can fix how many seconds per blocks are currently observed.
    function setSecondsPerBlock(uint256 secs) external onlyAdmin {
        //require(secs < cooldowns[0]);
        secondsPerBlock = secs;
    }
}

contract MonsterOwnership is MonstersBase, ERC721 {
    function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) {
        return monsterIndexToOwner[_tokenId] == _claimant;
    }

    function _isTradeable(uint256 _tokenId) public view returns (bool) {
        return monsterIdToTradeable[_tokenId];
    }

    /// @dev Checks if a given address currently has transferApproval for a particular monster.
    /// @param _claimant the address we are confirming monster is approved for.
    /// @param _tokenId monster id, only valid when > 0
    function _approvedFor(address _claimant, uint256 _tokenId) internal view returns (bool) {
        return monsterIndexToApproved[_tokenId] == _claimant;
    }

    function balanceOf(address _owner) public view returns (uint256 count) {
        return ownershipTokenCount[_owner];
    }

    function transfer(address _to, uint256 _tokenId) public payable {
        transferFrom(msg.sender, _to, _tokenId);
    }

    function transferFrom(address _from, address _to, uint256 _tokenId) public payable {
        require(monsterIdToTradeable[_tokenId]);
        // Safety check to prevent against an unexpected 0x0 default.
        require(_to != address(0));
        // Disallow transfers to this contract to prevent accidental misuse.
        // The contract should never own any monsters (except very briefly
        // after a gen0 monster is created and before it goes on auction).
        require(_to != address(this));
        // Check for approval and valid ownership
        
        require(_owns(_from, _tokenId));
        // checks if _to was aproved
        require(_from == msg.sender || msg.sender == address(monsterAuction) || _approvedFor(_to, _tokenId));

        // Reassign ownership (also clears pending approvals and emits Transfer event).
        _transfer(_from, _to, _tokenId);
    }

    function totalSupply() public view returns (uint) {
        return monsters.length;
    }

    function tokensOfOwner(address _owner) public view returns (uint256[] ownerTokens) {
        uint256 tokenCount = balanceOf(_owner);

        if (tokenCount > 0) {
            uint256[] memory result = new uint256[](tokenCount);
            uint256 totalMonsters = totalSupply();
            uint256 resultIndex = 0;

            uint256 monsterId;

            for (monsterId = 0; monsterId <= totalMonsters; monsterId++) {
                if (monsterIndexToOwner[monsterId] == _owner) {
                    result[resultIndex] = monsterId;
                    resultIndex++;
                }
            }

            return result;
        }

        return new uint256[](0);
    }

    bytes4 internal constant INTERFACE_SIGNATURE_ERC165 =
        bytes4(keccak256("supportsInterface(bytes4)"));

    bytes4 internal constant INTERFACE_SIGNATURE_ERC721 =
        bytes4(keccak256("ownerOf(uint256)")) ^
        bytes4(keccak256("countOfDeeds()")) ^
        bytes4(keccak256("countOfDeedsByOwner(address)")) ^
        bytes4(keccak256("deedOfOwnerByIndex(address,uint256)")) ^
        bytes4(keccak256("approve(address,uint256)")) ^
        bytes4(keccak256("takeOwnership(uint256)"));

    function supportsInterface(bytes4 _interfaceID) external pure returns (bool) {
        return _interfaceID == INTERFACE_SIGNATURE_ERC165 || _interfaceID == INTERFACE_SIGNATURE_ERC721;
    }

    function ownerOf(uint256 _deedId) external view returns (address _owner) {
        var owner = monsterIndexToOwner[_deedId];
        require(owner != address(0));
        return owner;
    }

    function _approve(uint256 _tokenId, address _approved) internal {
        monsterIndexToApproved[_tokenId] = _approved;
    }

    function countOfDeeds() external view returns (uint256 _count) {
        return totalSupply();
    }

    function countOfDeedsByOwner(address _owner) external view returns (uint256 _count) {
        var arr = tokensOfOwner(_owner);
        return arr.length;
    }

    function deedOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256 _deedId) {
        return tokensOfOwner(_owner)[_index];
    }

    function approve(address _to, uint256 _tokenId) external payable {
        // Only an owner can grant transfer approval.
        require(_owns(msg.sender, _tokenId));

        // Register the approval (replacing any previous approval).
        monsterIndexToApproved[_tokenId] = _to;

        // Emit approval event.
        Approval(msg.sender, _to, _tokenId);
    }

    function takeOwnership(uint256 _deedId) external payable {
        transferFrom(this.ownerOf(_deedId), msg.sender, _deedId);
    }
}

contract MonsterAuctionBase {

    // Reference to contract tracking NFT ownership
    MonsterOwnership public nonFungibleContract;
    ChainMonstersCore public core;

    struct Auction {
        // current owner
        address seller;
        // price in wei
        uint256 price;
        // time when auction started
        uint64 startedAt;
        uint256 id;
    }

    // Cut owner takes on each auction, measured in basis points (1/100 of a percent).
    // Values 0-10,000 map to 0%-100%
    uint256 public ownerCut;

    // Map from token ID to their corresponding auction.
    mapping(uint256 => Auction) tokenIdToAuction;
    mapping(uint256 => address) public auctionIdToSeller;
    mapping (address => uint256) public ownershipAuctionCount;

    event AuctionCreated(uint256 tokenId, uint256 price, uint256 uID, address seller);
    event AuctionSuccessful(uint256 tokenId, uint256 price, address newOwner, uint256 uID);
    event AuctionCancelled(uint256 tokenId, uint256 uID);

    function _transfer(address _receiver, uint256 _tokenId) internal {
        // it will throw if transfer fails
        nonFungibleContract.transfer(_receiver, _tokenId);
    }

    function _addAuction(uint256 _tokenId, Auction _auction) internal {
        tokenIdToAuction[_tokenId] = _auction;

        AuctionCreated(
            uint256(_tokenId),
            uint256(_auction.price),
            uint256(_auction.id),
            address(_auction.seller)
        );
    }

    function _cancelAuction(uint256 _tokenId, address _seller) internal {
        Auction storage _auction = tokenIdToAuction[_tokenId];

        uint256 uID = _auction.id;

        _removeAuction(_tokenId);
        ownershipAuctionCount[_seller]--;
        _transfer(_seller, _tokenId);

        AuctionCancelled(_tokenId, uID);
    }

    function _buy(uint256 _tokenId, uint256 _bidAmount) internal returns (uint256) {
        Auction storage auction = tokenIdToAuction[_tokenId];

        require(_isOnAuction(auction));

        uint256 price = auction.price;
        require(_bidAmount >= price);

        address seller = auction.seller;
        uint256 uID = auction.id;

        // Auction Bid looks fine! so remove
        _removeAuction(_tokenId);

        ownershipAuctionCount[seller]--;

        if (price > 0) {
            uint256 auctioneerCut = _computeCut(price);
            uint256 sellerProceeds = price - auctioneerCut;

            // NOTE: Doing a transfer() in the middle of a complex
            // method like this is generally discouraged because of
            // reentrancy attacks and DoS attacks if the seller is
            // a contract with an invalid fallback function. We explicitly
            // guard against reentrancy attacks by removing the auction
            // before calling transfer(), and the only thing the seller
            // can DoS is the sale of their own asset! (And if it's an
            // accident, they can call cancelAuction(). )
            if (seller != address(core)) {
                seller.transfer(sellerProceeds);
            }
        }

        // Calculate any excess funds included with the bid. If the excess
        // is anything worth worrying about, transfer it back to bidder.
        // NOTE: We checked above that the bid amount is greater than or
        // equal to the price so this cannot underflow.
        uint256 bidExcess = _bidAmount - price;

        // Return the funds. Similar to the previous transfer, this is
        // not susceptible to a re-entry attack because the auction is
        // removed before any transfers occur.
        msg.sender.transfer(bidExcess);

        // Tell the world!
        AuctionSuccessful(_tokenId, price, msg.sender, uID);

        return price;
    }

    function _removeAuction(uint256 _tokenId) internal {
        delete tokenIdToAuction[_tokenId];
    }

    function _isOnAuction(Auction storage _auction) internal view returns (bool) {
        return (_auction.startedAt > 0);
    }

     function _computeCut(uint256 _price) internal view returns (uint256) {
        // NOTE: We don't use SafeMath (or similar) in this function because
        //  all of our entry functions carefully cap the maximum values for
        //  currency (at 128-bits), and ownerCut <= 10000 (see the require()
        //  statement in the ClockAuction constructor). The result of this
        //  function is always guaranteed to be <= _price.
        return _price * ownerCut / 10000;
    }
}

contract MonsterAuction is  MonsterAuctionBase, Ownable {
    bool public isMonsterAuction = true;
    uint256 public auctionIndex = 0;

    function MonsterAuction(address _nftAddress, uint256 _cut) public {
        require(_cut <= 10000);
        ownerCut = _cut;

        var candidateContract = MonsterOwnership(_nftAddress);

        nonFungibleContract = candidateContract;
        ChainMonstersCore candidateCoreContract = ChainMonstersCore(_nftAddress);
        core = candidateCoreContract;
    }

    // only possible to decrease ownerCut!
    function setOwnerCut(uint256 _cut) external onlyOwner {
        require(_cut <= ownerCut);
        ownerCut = _cut;
    }

    function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) {
        return (nonFungibleContract.ownerOf(_tokenId) == _claimant);
    }

    function _escrow(address _owner, uint256 _tokenId) internal {
        // it will throw if transfer fails
        nonFungibleContract.transferFrom(_owner, this, _tokenId);
    }

    function withdrawBalance() external onlyOwner {
        uint256 balance = this.balance;
        owner.transfer(balance);
    }

    function tokensInAuctionsOfOwner(address _owner) external view returns(uint256[] auctionTokens) {
        uint256 numAuctions = ownershipAuctionCount[_owner];

        uint256[] memory result = new uint256[](numAuctions);
        uint256 totalAuctions = core.totalSupply();
        uint256 resultIndex = 0;

        uint256 auctionId;

        for (auctionId = 0; auctionId <= totalAuctions; auctionId++) {
            Auction storage auction = tokenIdToAuction[auctionId];
            if (auction.seller == _owner) {
                result[resultIndex] = auctionId;
                resultIndex++;
            }
        }

        return result;
    }

    function createAuction(uint256 _tokenId, uint256 _price, address _seller) external {
        require(_seller != address(0));
        require(_price == uint256(_price));
        require(core._isTradeable(_tokenId));
        require(_owns(msg.sender, _tokenId));

        
        _escrow(msg.sender, _tokenId);

        Auction memory auction = Auction(
            _seller,
            uint256(_price),
            uint64(now),
            uint256(auctionIndex)
        );

        auctionIdToSeller[auctionIndex] = _seller;
        ownershipAuctionCount[_seller]++;

        auctionIndex++;
        _addAuction(_tokenId, auction);
    }

    function buy(uint256 _tokenId) external payable {
        //delete auctionIdToSeller[_tokenId];
        // buy will throw if the bid or funds transfer fails
        _buy (_tokenId, msg.value);
        _transfer(msg.sender, _tokenId);
    }

    function cancelAuction(uint256 _tokenId) external {
        Auction storage auction = tokenIdToAuction[_tokenId];
        require(_isOnAuction(auction));

        address seller = auction.seller;
        require(msg.sender == seller);

        _cancelAuction(_tokenId, seller);
    }

    function getAuction(uint256 _tokenId) external view returns (address seller, uint256 price, uint256 startedAt) {
        Auction storage auction = tokenIdToAuction[_tokenId];
        require(_isOnAuction(auction));

        return (
            auction.seller,
            auction.price,
            auction.startedAt
        );
    }

    function getPrice(uint256 _tokenId) external view returns (uint256) {
        Auction storage auction = tokenIdToAuction[_tokenId];
        require(_isOnAuction(auction));
        return auction.price;
    }
}

contract ChainMonstersAuction is MonsterOwnership {
    bool lockedMonsterAuction = false;

    function setMonsterAuctionAddress(address _address) external onlyAdmin {
        require(!lockedMonsterAuction);
        MonsterAuction candidateContract = MonsterAuction(_address);

        require(candidateContract.isMonsterAuction());

        monsterAuction = candidateContract;
        lockedMonsterAuction = true;
    }

    uint256 public constant PROMO_CREATION_LIMIT = 5000;
    uint256 public constant GEN0_CREATION_LIMIT = 5000;

    // Counts the number of monster the contract owner has created.
    uint256 public promoCreatedCount;
    uint256 public gen0CreatedCount;

    // its stats are completely dependent on the spawn alghorithm
    function createPromoMonster(uint256 _mId, address _owner) external onlyAdmin {
        // during generation we have to keep in mind that we have only 10,000 tokens available
        // which have to be divided by 151 monsters, some rarer than others
        // see WhitePaper for gen0/promo monster plan
        
        // sanity check that this monster ID is actually in game yet
        require(monsterCreator.baseStats(_mId, 1) > 0);
        
        require(promoCreatedCount < PROMO_CREATION_LIMIT);

        promoCreatedCount++;

        uint8[7] memory ivs = uint8[7](monsterCreator.getGen0IVs());

        bool gender = monsterCreator.getMonsterGender();
        
        bool shiny = false;
        if (ivs[6] == 1) {
            shiny = true;
        }
        uint256 monsterId = _createMonster(0, _owner, _mId, true, gender, shiny);
        monsterIdToTradeable[monsterId] = true;

        monsterIdToIVs[monsterId] = ivs;
    }

    function createGen0Auction(uint256 _mId, uint256 price) external onlyAdmin {
         // sanity check that this monster ID is actually in game yet
        require(monsterCreator.baseStats(_mId, 1) > 0);
        
        require(gen0CreatedCount < GEN0_CREATION_LIMIT);

        uint8[7] memory ivs = uint8[7](monsterCreator.getGen0IVs());

        bool gender = monsterCreator.getMonsterGender();
        
        bool shiny = false;
        if (ivs[6] == 1) {
            shiny = true;
        }
        
        uint256 monsterId = _createMonster(0, this, _mId, true, gender, shiny);
        monsterIdToTradeable[monsterId] = true;

        _approve(monsterId, monsterAuction);

        monsterIdToIVs[monsterId] = ivs;

        monsterAuction.createAuction(monsterId, price, address(this));

        gen0CreatedCount++;
    }
}

// used during launch for world championship
// can and will be upgraded during development with new battle system!
// this is just to give players something to do and test their monsters
// also demonstrates how we can build up more mechanics on top of our locked core contract!
contract MonsterChampionship is Ownable {

    bool public isMonsterChampionship = true;

    ChainMonstersCore core;

    // list of top ten
    address[10] topTen;

    // holds the address current "world" champion
    address public currChampion;

    mapping (address => uint256) public addressToPowerlevel;
    mapping (uint256 => address) public rankToAddress;

    // try to beat every other player in the top10 with your strongest monster!
    // effectively looping through all top10 players, beating them one by one
    // and if strong enough placing your in the top10 as well
    function contestChampion(uint256 _tokenId) external {
        uint maxIndex = 9;

        // fail tx if player is already champion!
        // in theory players could increase their powerlevel by contesting themselves but
        // this check stops that from happening so other players have the chance to
        // become the temporary champion!
        if (currChampion == msg.sender) {
            revert();
        }

        require(core.isTrainer(msg.sender));
        require(core.monsterIndexToOwner(_tokenId) == msg.sender);

        uint myPowerlevel = 10; // todo add calculation method to this contract!

        // checks if this transaction is useless
        // since we can't fight against ourself!
        // also stops reentrancy attacks
        require(myPowerlevel > addressToPowerlevel[msg.sender]);

        uint myRank = 0;

        for (uint i = 0; i <= maxIndex; i++) {
            if (myPowerlevel > addressToPowerlevel[topTen[i]]) {
                // you have beaten this one so increase temporary rank
                myRank = i;

                if (myRank == maxIndex) {
                    currChampion = msg.sender;
                }
            }
        }

        addressToPowerlevel[msg.sender] = myPowerlevel;

        address[10] storage newTopTen = topTen;

        if (currChampion == msg.sender) {
            for (uint j = 0; j < maxIndex; j++) {
                // remove ourselves from this list in case
                if (newTopTen[j] == msg.sender) {
                    newTopTen[j] = 0x0;
                    break;
                }
            }
        }

        for (uint x = 0; x <= myRank; x++) {
            if (x == myRank) {
                newTopTen[x] = msg.sender;
            } else {
                if (x < maxIndex)
                    newTopTen[x] = topTen[x+1];
            }
        }

        topTen = newTopTen;
    }

    function getTopPlayers() external view returns (address[10] players) {
        players = topTen;
    }

    function MonsterChampionship(address coreContract) public {
        core = ChainMonstersCore(coreContract);
    }

    function withdrawBalance() external onlyOwner {
        uint256 balance = this.balance;
        owner.transfer(balance);
    }
}


// where the not-so-much "hidden" magic happens
contract MonsterCreatorInterface is Ownable {
    uint8 public lockedMonsterStatsCount = 0;
    uint nonce = 0;

    function rand(uint16 min, uint16 max) public returns (uint16) {
        nonce++;
        uint16 result = (uint16(keccak256(block.blockhash(block.number-1), nonce))%max);

        if (result < min) {
            result = result+min;
        }

        return result;
    }

    mapping(uint256 => uint8[8]) public baseStats;

    function addBaseStats(uint256 _mId, uint8[8] data) external onlyOwner {
        // lock" the stats down forever
        // since hp is never going to be 0 this is a valid check
        // so we have to be extra careful when adding new baseStats!
        require(data[0] > 0);
        require(baseStats[_mId][0] == 0);
        baseStats[_mId] = data;
    }

    function _addBaseStats(uint256 _mId, uint8[8] data) internal {
        baseStats[_mId] = data;
        lockedMonsterStatsCount++;
    }

    function MonsterCreatorInterface() public {
       // these monsters are already down and "locked" down stats/design wise
        _addBaseStats(1, [45, 49, 49, 65, 65, 45, 12, 4]);
        _addBaseStats(2, [60, 62, 63, 80, 80, 60, 12, 4]);
        _addBaseStats(3, [80, 82, 83, 100, 100, 80, 12, 4]);
        _addBaseStats(4, [39, 52, 43, 60, 50, 65, 10, 6]);
        _addBaseStats(5, [58, 64, 58, 80, 65, 80, 10, 6]);
        _addBaseStats(6, [78, 84, 78, 109, 85, 100, 10, 6]);
        _addBaseStats(7, [44, 48, 65, 50, 64, 43, 11, 14]);
        _addBaseStats(8, [59, 63, 80, 65, 80, 58, 11, 14]);
        _addBaseStats(9, [79, 83, 100, 85, 105, 78, 11, 14]);
        _addBaseStats(10, [40, 35, 30, 20, 20, 50, 7, 4]);

        _addBaseStats(149, [55, 50, 45, 135, 95, 120, 8, 14]);
        _addBaseStats(150, [91, 134, 95, 100, 100, 80, 2, 5]);
        _addBaseStats(151, [100, 100, 100, 100, 100, 100, 5, 19]);
    }

    // this serves as a lookup for new monsters to be generated since all monsters
    // of the same id share the base stats
    // also makes it possible to only store the monsterId on core and change this one
    // during evolution process to save gas and additional transactions
    function getMonsterStats( uint256 _mID) external constant returns(uint8[8] stats) {
        stats[0] = baseStats[_mID][0];
        stats[1] = baseStats[_mID][1];
        stats[2] = baseStats[_mID][2];
        stats[3] = baseStats[_mID][3];
        stats[4] = baseStats[_mID][4];
        stats[5] = baseStats[_mID][5];
        stats[6] = baseStats[_mID][6];
        stats[7] = baseStats[_mID][7];
    }

    function getMonsterGender () external returns(bool female) {
        uint16 femaleChance = rand(0, 100);

        if (femaleChance >= 50) {
            female = true;
        }
    }

    // generates randomized IVs for a new monster
    function getMonsterIVs() external returns(uint8[7] ivs) {
        bool shiny = false;

        uint16 chance = rand(1, 8192);

        if (chance == 42) {
            shiny = true;
        }

        // IVs range between 0 and 31
        // stat range modified for shiny monsters!
        if (shiny) {
            ivs[0] = uint8(rand(10, 31));
            ivs[1] = uint8(rand(10, 31));
            ivs[2] = uint8(rand(10, 31));
            ivs[3] = uint8(rand(10, 31));
            ivs[4] = uint8(rand(10, 31));
            ivs[5] = uint8(rand(10, 31));
            ivs[6] = 1;

        } else {
            ivs[0] = uint8(rand(0, 31));
            ivs[1] = uint8(rand(0, 31));
            ivs[2] = uint8(rand(0, 31));
            ivs[3] = uint8(rand(0, 31));
            ivs[4] = uint8(rand(0, 31));
            ivs[5] = uint8(rand(0, 31));
            ivs[6] = 0;
        }
    }

    // gen0 monsters profit from shiny boost while shiny gen0s have potentially even higher IVs!
    // further increasing the rarity by also doubling the shiny chance!
    function getGen0IVs() external returns (uint8[7] ivs) {
        bool shiny = false;

        uint16 chance = rand(1, 4096);

        if (chance == 42) {
            shiny = true;
        }

        if (shiny) {
            ivs[0] = uint8(rand(15, 31));
            ivs[1] = uint8(rand(15, 31));
            ivs[2] = uint8(rand(15, 31));
            ivs[3] = uint8(rand(15, 31));
            ivs[4] = uint8(rand(15, 31));
            ivs[5] = uint8(rand(15, 31));
            ivs[6] = 1;
        } else {
            ivs[0] = uint8(rand(10, 31));
            ivs[1] = uint8(rand(10, 31));
            ivs[2] = uint8(rand(10, 31));
            ivs[3] = uint8(rand(10, 31));
            ivs[4] = uint8(rand(10, 31));
            ivs[5] = uint8(rand(10, 31));
            ivs[6] = 0;
        }
    }

    function withdrawBalance() external onlyOwner {
        uint256 balance = this.balance;
        owner.transfer(balance);
    }
}

contract GameLogicContract {
    bool public isGameLogicContract = true;

    function GameLogicContract() public {

    }
}


contract OmegaContract {
    bool public isOmegaContract = true;

    function OmegaContract() public {

    }
}

contract ChainMonstersCore is ChainMonstersAuction, Ownable {
    // using a bool to enable us to prepare the game
    bool hasLaunched = false;

    // this address will hold future gamelogic in place
    address gameContract;

    // this contract
    address omegaContract;

    function ChainMonstersCore() public {
        adminAddress = msg.sender;

        _createArea(); // area 1
        _createArea(); // area 2
    }

    // we don't know the exact interfaces yet so use the lockedMonsterStats value to determine if the game is "ready"
    // see WhitePaper for explaination for our upgrade and development roadmap
    function setGameLogicContract(address _candidateContract) external onlyOwner {
        require(monsterCreator.lockedMonsterStatsCount() == 151);

        require(GameLogicContract(_candidateContract).isGameLogicContract());

        gameContract = _candidateContract;
    }

    function setOmegaContract(address _candidateContract) external onlyOwner {
        require(OmegaContract(_candidateContract).isOmegaContract());
        omegaContract = _candidateContract;
    }

    // omega contract takes care of all neccessary checks so assume that this is correct(!)
    function evolveMonster(uint256 _tokenId, uint16 _toMonsterId) external {
        require(msg.sender == omegaContract);

        // retrieve current monster struct
        Monster storage mon = monsters[_tokenId];

        // evolving only changes monster ID since this is responsible for base Stats
        // an evolved monster keeps its gender, generation, IVs and EVs
        mon.mID = _toMonsterId;
    }

    // only callable by gameContract after the full game is launched
    // since all additional monsters after the promo/gen0 ones need to use this coreContract
    // contract as well we have to prepare this core for our future updates where
    // players can freely roam the world and hunt ChainMonsters thus generating more
    function spawnMonster(uint256 _mId, address _owner) external {
        require(msg.sender == gameContract);

        uint8[7] memory ivs = uint8[7](monsterCreator.getMonsterIVs());

        bool gender = monsterCreator.getMonsterGender();

        bool shiny = false;
        if (ivs[6] == 1) {
            shiny = true;
        }
        
        // important to note that the IV generators do not use Gen0 methods and are Generation 1
        // this means there won't be more than the 10,000 Gen0 monsters sold during the development through the marketplace
        uint256 monsterId = _createMonster(1, _owner, _mId, false, gender, shiny);
        monsterIdToTradeable[monsterId] = true;

        monsterIdToIVs[monsterId] = ivs;
    }

    // used to add playable content to the game
    // monsters will only spawn in certain areas so some are locked on release
    // due to the game being in active development on "launch"
    // each monster has a maximum number of 3 areas where it can appear
    function createArea() public onlyAdmin {
        _createArea();
    }

    function createTrainer(string _username, uint16 _starterId) public {
        require(hasLaunched);

        // only one trainer/account per ethereum address
        require(addressToTrainer[msg.sender].owner == 0);

        // valid input check
        require(_starterId == 1 || _starterId == 2 || _starterId == 3);

        uint256 mon = _createTrainer(_username, _starterId, msg.sender);

        // due to stack limitations we have to assign the IVs here:
        monsterIdToIVs[mon] = monsterCreator.getMonsterIVs();
    }

    function changeUsername(string _name) public {
        require(addressToTrainer[msg.sender].owner == msg.sender);
        addressToTrainer[msg.sender].username = _name;
    }

    function changeMonsterNickname(uint256 _tokenId, string _name) public {
        // users won't be able to rename a monster that is part of an auction
        require(_owns(msg.sender, _tokenId));

        // some string checks...?
        monsterIdToNickname[_tokenId] = _name;
    }

    function moveToArea(uint16 _newArea) public {
        require(addressToTrainer[msg.sender].currArea > 0);

        // never allow anyone to move to area 0 or below since this is used
        // to determine if a trainer profile exists in another method!
        require(_newArea > 0);

        // make sure that this area exists yet!
        require(areas.length >= _newArea);

        // when player is not stuck doing something else he can move freely!
        _moveToArea(_newArea, msg.sender);
    }

    // to be changed to retrieve current stats!
    function getMonster(uint256 _id) external view returns (
        uint256 birthTime, uint256 generation, uint8[8] stats,
        uint256 mID, bool tradeable, uint256 uID)
    {
        Monster storage mon = monsters[_id];
        birthTime = uint256(mon.birthTime);
        generation = mon.generation; // hardcoding due to stack too deep error
        mID = uint256(mon.mID);
        tradeable = bool(mon.tradeable);

        // these values are retrieved from monsterCreator
        stats = uint8[8](monsterCreator.getMonsterStats(uint256(mon.mID)));

        // hack to overcome solidity's stack limitation in monster struct....
        uID = _id;
    }

    function isTrainer(address _check) external view returns (bool isTrainer) {
        Trainer storage trainer = addressToTrainer[_check];

        return (trainer.currArea > 0);
    }

    function withdrawBalance() external onlyOwner {
        uint256 balance = this.balance;

        owner.transfer(balance);
    }

    // after we have setup everything we can unlock the game
    // for public
    function launchGame() external onlyOwner {
        hasLaunched = true;
    }
}

Contract Security Audit

Contract ABI

[{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"tokensInAuctionsOfOwner","outputs":[{"name":"auctionTokens","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"auctionIdToSeller","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_price","type":"uint256"},{"name":"_seller","type":"address"}],"name":"createAuction","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"withdrawBalance","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_cut","type":"uint256"}],"name":"setOwnerCut","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getAuction","outputs":[{"name":"seller","type":"address"},{"name":"price","type":"uint256"},{"name":"startedAt","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"auctionIndex","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ownerCut","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":false,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"cancelAuction","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isMonsterAuction","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"buy","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"nonFungibleContract","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getPrice","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"ownershipAuctionCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"core","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_nftAddress","type":"address"},{"name":"_cut","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"price","type":"uint256"},{"indexed":false,"name":"uID","type":"uint256"},{"indexed":false,"name":"seller","type":"address"}],"name":"AuctionCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"price","type":"uint256"},{"indexed":false,"name":"newOwner","type":"address"},{"indexed":false,"name":"uID","type":"uint256"}],"name":"AuctionSuccessful","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"tokenId","type":"uint256"},{"indexed":false,"name":"uID","type":"uint256"}],"name":"AuctionCancelled","type":"event"}]

60606040526006805460a060020a60ff021916740100000000000000000000000000000000000000001790556000600755341561003b57600080fd5b604051604080610da1833981016040528080519190602001805160068054600160a060020a03191633600160a060020a03161790559150600090508061271083111561008657600080fd5b505060025560008054600160a060020a03909216600160a060020a0319928316811790915560018054909216179055610cdd806100c46000396000f3006060604052600436106100d75763ffffffff60e060020a6000350416631a02af4081146100dc5780632fe29c781461014e57806354279bdd146101805780635fd8c710146101a7578063757de573146101ba57806378bd7935146101d05780637aacf03c1461021c57806383b5ff8b146102415780638da5cb5b1461025457806396b5a75514610267578063bfab4f8b1461027d578063d96a094a146102a4578063dd1b7a0f146102af578063e7572230146102c2578063e7751e48146102d8578063f2f4eb26146102f7578063f2fde38b1461030a575b600080fd5b34156100e757600080fd5b6100fb600160a060020a0360043516610329565b60405160208082528190810183818151815260200191508051906020019060200280838360005b8381101561013a578082015183820152602001610122565b505050509050019250505060405180910390f35b341561015957600080fd5b61016460043561044a565b604051600160a060020a03909116815260200160405180910390f35b341561018b57600080fd5b6101a5600435602435600160a060020a0360443516610465565b005b34156101b257600080fd5b6101a56105a9565b34156101c557600080fd5b6101a5600435610603565b34156101db57600080fd5b6101e6600435610632565b6040518084600160a060020a0316600160a060020a03168152602001838152602001828152602001935050505060405180910390f35b341561022757600080fd5b61022f610685565b60405190815260200160405180910390f35b341561024c57600080fd5b61022f61068b565b341561025f57600080fd5b610164610691565b341561027257600080fd5b6101a56004356106a0565b341561028857600080fd5b6102906106ee565b604051901515815260200160405180910390f35b6101a560043561070f565b34156102ba57600080fd5b610164610724565b34156102cd57600080fd5b61022f600435610733565b34156102e357600080fd5b61022f600160a060020a036004351661075f565b341561030257600080fd5b610164610771565b341561031557600080fd5b6101a5600160a060020a0360043516610780565b610331610c78565b600061033b610c78565b600160a060020a03841660009081526005602052604080822054935081908190819086905180591061036a5750595b9080825280602002602001820160405250600154909550600160a060020a03166318160ddd6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156103c657600080fd5b6102c65a03f115156103d757600080fd5b5050506040518051945060009350839250505b83821161043e575060008181526003602052604090208054600160a060020a0389811691161415610433578185848151811061042257fe5b602090810290910101526001909201915b6001909101906103ea565b50929695505050505050565b600460205260009081526040902054600160a060020a031681565b61046d610c8a565b600160a060020a038216151561048257600080fd5b600154600160a060020a0316634c8bae938560006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b15156104d357600080fd5b6102c65a03f115156104e457600080fd5b5050506040518051905015156104f957600080fd5b61050333856107d7565b151561050e57600080fd5b6105183385610859565b60806040519081016040908152600160a060020a038416808352602080840187905267ffffffffffffffff4216838501526007805460608601819052600090815260048352848120805473ffffffffffffffffffffffffffffffffffffffff191685179055928352600590915291902080546001908101909155815401905590506105a384826108d4565b50505050565b60065460009033600160a060020a039081169116146105c757600080fd5b50600654600160a060020a0330811631911681156108fc0282604051600060405180830381858888f19350505050151561060057600080fd5b50565b60065433600160a060020a0390811691161461061e57600080fd5b60025481111561062d57600080fd5b600255565b60008181526003602052604081208190819061064d816109b2565b151561065857600080fd5b80546001820154600290920154600160a060020a039091169691955067ffffffffffffffff169350915050565b60075481565b60025481565b600654600160a060020a031681565b6000818152600360205260408120906106b8826109b2565b15156106c357600080fd5b508054600160a060020a0390811690331681146106df57600080fd5b6106e983826109c8565b505050565b60065474010000000000000000000000000000000000000000900460ff1681565b6107198134610a50565b506106003382610bcd565b600054600160a060020a031681565b600081815260036020526040812061074a816109b2565b151561075557600080fd5b6001015492915050565b60056020526000908152604090205481565b600154600160a060020a031681565b60065433600160a060020a0390811691161461079b57600080fd5b600160a060020a038116156106005760068054600160a060020a03831673ffffffffffffffffffffffffffffffffffffffff1990911617905550565b60008054600160a060020a038085169116636352211e84846040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561082c57600080fd5b6102c65a03f1151561083d57600080fd5b50505060405180519050600160a060020a031614905092915050565b600054600160a060020a03166323b872dd83308460405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401600060405180830381600087803b15156108bc57600080fd5b6102c65a03f115156108cd57600080fd5b5050505050565b600082815260036020526040902081908151815473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039190911617815560208201518160010155604082015160028201805467ffffffffffffffff191667ffffffffffffffff929092169190911790556060820151600390910155507f31601d099683117d912ba8d2e0a9265379e3e1325353b6effa37c6ef86a9cb03826020830151836060015184516040519384526020840192909252604080840191909152600160a060020a0390911660608301526080909101905180910390a15050565b60020154600067ffffffffffffffff9091161190565b6000828152600360208190526040909120908101546109e684610c23565b600160a060020a03831660009081526005602052604090208054600019019055610a108385610bcd565b7fdb9cc99dc874f9afbae71151f737e51547d3d412b52922793437d86607050c3c848260405191825260208201526040908101905180910390a150505050565b6000828152600360205260408120818080808080610a6d876109b2565b1515610a7857600080fd5b6001870154955085891015610a8c57600080fd5b86546003880154600160a060020a0390911695509350610aab8a610c23565b600160a060020a03851660009081526005602052604081208054600019019055861115610b2957610adb86610c6c565b6001549093508387039250600160a060020a03868116911614610b2957600160a060020a03851682156108fc0283604051600060405180830381858888f193505050501515610b2957600080fd5b50848803600160a060020a03331681156108fc0282604051600060405180830381858888f193505050501515610b5e57600080fd5b7f34fee3e4a1e9469d637a0d1a15f76a747dd26789fb1e59cb62a2dbfc54fcf9798a8733876040518085815260200184815260200183600160a060020a0316600160a060020a0316815260200182815260200194505050505060405180910390a1509398975050505050505050565b600054600160a060020a031663a9059cbb838360405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401600060405180830381600087803b15156108bc57600080fd5b60009081526003602081905260408220805473ffffffffffffffffffffffffffffffffffffffff191681556001810183905560028101805467ffffffffffffffff191690550155565b60025461271091020490565b60206040519081016040526000815290565b608060405190810160409081526000808352602083018190529082018190526060820152905600a165627a7a72305820ddb947aa1a3115ebbfa3c33d0149c0896bfea1927d1675321861f87cae1a3ef00029000000000000000000000000f7f6c2836293a661be2690fbacae97f3f027e9c400000000000000000000000000000000000000000000000000000000000003e8

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

000000000000000000000000f7f6c2836293a661be2690fbacae97f3f027e9c400000000000000000000000000000000000000000000000000000000000003e8

-----Decoded View---------------
Arg [0] : _nftAddress (address): 0xf7f6c2836293a661be2690fbacae97f3f027e9c4
Arg [1] : _cut (uint256): 1000

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000f7f6c2836293a661be2690fbacae97f3f027e9c4
Arg [1] : 00000000000000000000000000000000000000000000000000000000000003e8


Swarm Source

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