Contract 0xbF8B9092e809DE87932B28ffaa00D520b04359aA 1

 
 
Txn Hash
Method
Block
From
To
Value
0xd4eb883591e78a0d26f73824ca2686af90f63c08bfc78e2a5a2d6e46d2943351Withdraw House S...62133452018-08-25 21:57:431615 days 11 hrs ago0x324ec9421c051d1ec1855ef6fe49263c02b35c77 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0 Ether0.00007173
0x3ab2f769701b08fcfb6a206c78a5c723b0e4694186869c071a0416aaf245f192Withdraw House S...62133362018-08-25 21:55:251615 days 11 hrs ago0x324ec9421c051d1ec1855ef6fe49263c02b35c77 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0 Ether0.00011673
0x2810cd49431177ef19363649f9d9b2249b649ae5c2be440eaa585bd2b2c384a7Pause62133002018-08-25 21:46:461615 days 11 hrs ago0x324ec9421c051d1ec1855ef6fe49263c02b35c77 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0 Ether0.0012712420
0x776813df8f46b8d1e744dc1b8968f341db3592aefd9bcc23ff7ab465547d3f63Transfer Profit ...62115962018-08-25 15:04:091615 days 18 hrs ago0xeb52267585e80ae2ca905be8e9abffba9eb3fa1c IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0 Ether0.000094933
0xc6574f67fc448637a24b88a6c8920d55f08acb7012b0863df1fdaba8d8b6c7b3Server End Game61824552018-08-20 16:55:231620 days 16 hrs ago0xcef260a5fed7a896bbe07b933b3a5c17aec094d8 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0 Ether0.000170142.205
0x2f17c8d84bf3906e4757e06436e65e7ae6bd3eb2770600167ca80b8031f85b0aCreate Game61824382018-08-20 16:52:051620 days 16 hrs ago0x89a548195582228eb1267908d7758b507b1ab847 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0.02 Ether0.000151071.5
0xe192cdd8b24840690c588dcae04b8538706bf6a23025e5d184981bee1d29cbe2Create Game61635872018-08-17 12:04:431623 days 21 hrs ago0x00e695c5d7b2f6a2e83e1b34db1390f89e2741ef IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0.11 Ether0.0021988260
0xbd2b2e2e1b268ce3b0e3d1b81c3a0d42a8c120c8e2c9a443c92c62649dcb625eServer End Game61403872018-08-13 14:12:151627 days 19 hrs ago0xcef260a5fed7a896bbe07b933b3a5c17aec094d8 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0 Ether0.00034674.41
0x54978acbfa6d7f48a62791796a24c1f2c315dcf43350c88b8fb9438dd4becfecCreate Game61403632018-08-13 14:06:321627 days 19 hrs ago0xdade02f2d7a20ee3cad4c181f32408332a90d6e3 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0.07 Ether0.000301953
0x75fcbc65cd613b625929f7323de0e55d5677f2b94e95b1c10e02745c28868fc5Server End Game61346422018-08-12 14:52:281628 days 18 hrs ago0xcef260a5fed7a896bbe07b933b3a5c17aec094d8 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0 Ether0.000323824.2
0x4a9161fcfa37e73b99c8fb9108414340a8bcdc173e73a619991319908d77b7cfCreate Game61346362018-08-12 14:50:241628 days 18 hrs ago0xeb52267585e80ae2ca905be8e9abffba9eb3fa1c IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0.01 Ether0.000402354
0x69c2910b44c9a869b94c70e8f011f51e35af6b45e9c563f3a22d2aac5018d8e0Server End Game61292642018-08-11 16:33:361629 days 16 hrs ago0xcef260a5fed7a896bbe07b933b3a5c17aec094d8 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0 Ether0.000323824.2
0x3b4fcf8bce804ed88ea8f20d730394b2e6f255ff4395f67a5a5a51b0a73b53d5Create Game61291752018-08-11 16:12:391629 days 17 hrs ago0x89a548195582228eb1267908d7758b507b1ab847 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0.02 Ether0.00040264
0xd69cc93d221301eb3635302f8cb233d2c8bc15632a01b4a04de3aaa4a626982eServer End Game61288092018-08-11 14:44:001629 days 18 hrs ago0xcef260a5fed7a896bbe07b933b3a5c17aec094d8 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0 Ether0.000659858.4
0x27f5dc9dd3dacf765302906ca40940a1c714a2952a524f0c4c10112c9044e449Create Game61285652018-08-11 13:50:041629 days 19 hrs ago0x3b360314717a312d9bd68a984eeac9109b997942 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0.1 Ether0.0035832231
0xdfac4a4f44caff92fce8c950338dfabd88e9522d7910bfff1247116811ed3f42Create Game61284352018-08-11 13:21:511629 days 19 hrs ago0x3b360314717a312d9bd68a984eeac9109b997942 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0.1 Ether0.0003651910
0x450e395a5165efe40d82a2fe14d71379db7927125c731fd66abbd692241896f6Server End Game61223752018-08-10 12:50:261630 days 20 hrs ago0xcef260a5fed7a896bbe07b933b3a5c17aec094d8 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0 Ether0.0013762517.85
0x9d8253afde29b62874490ad471b18da799902d35799cc321f093ebed07f8a8d1Create Game61223592018-08-10 12:47:181630 days 20 hrs ago0xdade02f2d7a20ee3cad4c181f32408332a90d6e3 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0.07 Ether0.0020143220
0x512424bba2cc4864f58efb1c7b4ef3381d615cbf7546832413d58c5443645da4Server End Game61216442018-08-10 9:57:031630 days 23 hrs ago0xcef260a5fed7a896bbe07b933b3a5c17aec094d8 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0 Ether0.0033649743.68
0x6ec9dcfd282861dc6ec6d0c13fc7a262b2666924840b237051133487c688c6a8Create Game61216172018-08-10 9:50:161630 days 23 hrs ago0xa51addee323697f1021024f056c6465aee755a92 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0.01 Ether0.0035228235
0x4edfdca9b93c8a4bb73ca160b4b478d1b1e0f2b55c556590087c31f77e5114c1Server Force Gam...61088292018-08-08 5:59:501633 days 3 hrs ago0xcef260a5fed7a896bbe07b933b3a5c17aec094d8 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0 Ether0.0029097863
0xf8f5d42e66eefc015bb5afd75373a57f8ff628f4d8599bd508e1b14cba723224Server End Game ...61070872018-08-07 23:00:021633 days 10 hrs ago0xcef260a5fed7a896bbe07b933b3a5c17aec094d8 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0 Ether0.0094629652.5
0x1d9bc89a1a4f446656284936cfedc7dc5afda538838dd2c7f521f2b689b58810Create Game61054932018-08-07 16:27:071633 days 16 hrs ago0xb40bd35695eaeb41bf7b17d069d2b0d8bb1e16d7 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0.03 Ether0.0069352860
0x54fecb54b8ba6b487178f56eec9b706ced8ea7d46ef3acc22d4fa4a939b5ec77Server End Game61034902018-08-07 8:11:121634 days 1 hr ago0xcef260a5fed7a896bbe07b933b3a5c17aec094d8 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0 Ether0.000247043.15
0x48f9ca45a7cc189ede56a01de4e460f453920354a00898d1ec3f55ec4093dda5Create Game61034682018-08-07 8:05:131634 days 1 hr ago0xdade02f2d7a20ee3cad4c181f32408332a90d6e3 IN  0xbf8b9092e809de87932b28ffaa00d520b04359aa0.08 Ether0.000302143
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0xd4eb883591e78a0d26f73824ca2686af90f63c08bfc78e2a5a2d6e46d294335162133452018-08-25 21:57:431615 days 11 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0x324ec9421c051d1ec1855ef6fe49263c02b35c7710 Ether
0x3ab2f769701b08fcfb6a206c78a5c723b0e4694186869c071a0416aaf245f19262133362018-08-25 21:55:251615 days 11 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0x324ec9421c051d1ec1855ef6fe49263c02b35c770.001 Ether
0x776813df8f46b8d1e744dc1b8968f341db3592aefd9bcc23ff7ab465547d3f6362115962018-08-25 15:04:091615 days 18 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0x71be1ace87248f3950bdfc4c89b4b3eed059f6f33.26229102 Ether
0xc6574f67fc448637a24b88a6c8920d55f08acb7012b0863df1fdaba8d8b6c7b361824552018-08-20 16:55:231620 days 16 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0x89a548195582228eb1267908d7758b507b1ab8470.0236672 Ether
0xbd2b2e2e1b268ce3b0e3d1b81c3a0d42a8c120c8e2c9a443c92c62649dcb625e61403872018-08-13 14:12:151627 days 19 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0xdade02f2d7a20ee3cad4c181f32408332a90d6e30.043231 Ether
0x75fcbc65cd613b625929f7323de0e55d5677f2b94e95b1c10e02745c28868fc561346422018-08-12 14:52:281628 days 18 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0xeb52267585e80ae2ca905be8e9abffba9eb3fa1c0.0100088 Ether
0x69c2910b44c9a869b94c70e8f011f51e35af6b45e9c563f3a22d2aac5018d8e061292642018-08-11 16:33:361629 days 16 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0x89a548195582228eb1267908d7758b507b1ab8470.0202048 Ether
0xd69cc93d221301eb3635302f8cb233d2c8bc15632a01b4a04de3aaa4a626982e61288092018-08-11 14:44:001629 days 18 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0x3b360314717a312d9bd68a984eeac9109b9979420.00000121 Ether
0x450e395a5165efe40d82a2fe14d71379db7927125c731fd66abbd692241896f661223752018-08-10 12:50:261630 days 20 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0xdade02f2d7a20ee3cad4c181f32408332a90d6e30.070128 Ether
0x512424bba2cc4864f58efb1c7b4ef3381d615cbf7546832413d58c5443645da461216442018-08-10 9:57:031630 days 23 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0xa51addee323697f1021024f056c6465aee755a920.0102528 Ether
0x54fecb54b8ba6b487178f56eec9b706ced8ea7d46ef3acc22d4fa4a939b5ec7761034902018-08-07 8:11:121634 days 1 hr ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0xdade02f2d7a20ee3cad4c181f32408332a90d6e30.0685312 Ether
0x1aef14cac9d8b99aed7bda405885f69880173ea16f5c7e4ff3ac8cbfe08e744760993192018-08-06 15:20:381634 days 17 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0xdade02f2d7a20ee3cad4c181f32408332a90d6e30.07865 Ether
0x801cb1d8d43a4de79fa75622f95475206f679bf4dd45fc6f91186376cd38b67860765742018-08-02 19:23:241638 days 13 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0x89a548195582228eb1267908d7758b507b1ab8470.021675 Ether
0x7be40339460494aa933669d511e06254e10d6f99d5f8b20d8167c96ee73d837c60728032018-08-02 3:45:571639 days 5 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0x2d477140e626f31ef9f219455906cff0ba683c930.02 Ether
0x655f8bfc1f162c5e7f00612601e8238af3dd1956313dbee8f2a182883fe2dbf960706242018-08-01 19:19:411639 days 13 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0xdade02f2d7a20ee3cad4c181f32408332a90d6e30.05835 Ether
0xff7670a59eac6fc42ccc9fae4f1b8d0834590411de0bf6c1cc1754d4cb150d8060701252018-08-01 17:03:591639 days 16 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0x2d477140e626f31ef9f219455906cff0ba683c930.01 Ether
0x4794f599980b3629a52866c42d56b0776faebe02a3c9140adf304e46051b72df60669652018-08-01 4:02:421640 days 5 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0x172f820de0db7e26a5e7a70d322409199e2bfded0.22965584 Ether
0xb6aa0b0862cc2722c906b5cb8f152838192c04d9479f32634d4e6df96aa55dc160652852018-07-31 21:16:541640 days 11 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0x4eda77df79ddf1711a5b5eecb3cb642cee682cf00.24146249 Ether
0xdaec60ee0015db7bbcf7f09f04a4d3dc9b347cd60881b15ab9eec65ef7dbea5560645282018-07-31 18:12:441640 days 15 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0xd1ceeee271fd5a8b0e2bfc12ea5b5b2e5cedec950.02364027 Ether
0x608228d5c7baef7db836782b9c4b1bd58ffa264ddfbf38c24cd4ce72e6a5d6b060642652018-07-31 17:12:501640 days 16 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0x4eda77df79ddf1711a5b5eecb3cb642cee682cf00.24605245 Ether
0xed7569e2505441f887897eb5168551db3ad401f3ff3f5b45477b9f7296e84a3f60641972018-07-31 16:57:381640 days 16 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0xdade02f2d7a20ee3cad4c181f32408332a90d6e30.0564282 Ether
0x0aaa36a3c77db3d771054f5fa6b88638bf8b0e794cddefe4142aa05c25b14df560640072018-07-31 16:14:301640 days 16 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0xdade02f2d7a20ee3cad4c181f32408332a90d6e30.031375 Ether
0xfd7d6cfc7d9c2cbcc6009f491eec3160fc47d8e61a9f391504958232cd3e836160588872018-07-30 19:11:581641 days 14 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0x89a548195582228eb1267908d7758b507b1ab8470.0203487 Ether
0x74ae1c57f808424de8378d4a3f499aca7dd98d08e715348bb2e5fb19082baa6460544892018-07-30 1:29:481642 days 7 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0x3778d19202ee3c91da85c16b882567cb7fd88e7d0.00035714 Ether
0xf2f6efe30156cba0b2f58a3fb9191f8901220f79593d13659810cf93727e374760514922018-07-29 13:33:191642 days 19 hrs ago 0xbf8b9092e809de87932b28ffaa00d520b04359aa0xdade02f2d7a20ee3cad4c181f32408332a90d6e30.021825 Ether
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
GameChannel

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-05-29
*/

pragma solidity ^0.4.24;

interface ConflictResolutionInterface {
    function minHouseStake(uint activeGames) external pure returns(uint);

    function maxBalance() external pure returns(int);

    function isValidBet(uint8 _gameType, uint _betNum, uint _betValue) external pure returns(bool);

    function endGameConflict(
        uint8 _gameType,
        uint _betNum,
        uint _betValue,
        int _balance,
        uint _stake,
        bytes32 _serverSeed,
        bytes32 _playerSeed
    )
        external
        view
        returns(int);

    function serverForceGameEnd(
        uint8 gameType,
        uint _betNum,
        uint _betValue,
        int _balance,
        uint _stake,
        uint _endInitiatedTime
    )
        external
        view
        returns(int);

    function playerForceGameEnd(
        uint8 _gameType,
        uint _betNum,
        uint _betValue,
        int _balance,
        uint _stake,
        uint _endInitiatedTime
    )
        external
        view
        returns(int);
}

library MathUtil {
    /**
     * @dev Returns the absolute value of _val.
     * @param _val value
     * @return The absolute value of _val.
     */
    function abs(int _val) internal pure returns(uint) {
        if (_val < 0) {
            return uint(-_val);
        } else {
            return uint(_val);
        }
    }

    /**
     * @dev Calculate maximum.
     */
    function max(uint _val1, uint _val2) internal pure returns(uint) {
        return _val1 >= _val2 ? _val1 : _val2;
    }

    /**
     * @dev Calculate minimum.
     */
    function min(uint _val1, uint _val2) internal pure returns(uint) {
        return _val1 <= _val2 ? _val1 : _val2;
    }
}

contract Ownable {
    address public owner;
    address public pendingOwner;

    event LogOwnerShipTransferred(address indexed previousOwner, address indexed newOwner);
    event LogOwnerShipTransferInitiated(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Modifier, which throws if called by other account than owner.
     */
    modifier onlyOwner {
        require(msg.sender == owner);
        _;
    }

    /**
     * @dev Modifier throws if called by any account other than the pendingOwner.
     */
    modifier onlyPendingOwner() {
        require(msg.sender == pendingOwner);
        _;
    }

    /**
     * @dev Set contract creator as initial owner
     */
    constructor() public {
        owner = msg.sender;
        pendingOwner = address(0);
    }

    /**
     * @dev Allows the current owner to set the pendingOwner address.
     * @param _newOwner The address to transfer ownership to.
     */
    function transferOwnership(address _newOwner) public onlyOwner {
        pendingOwner = _newOwner;
        emit LogOwnerShipTransferInitiated(owner, _newOwner);
    }

    /**
     * @dev New owner can accpet ownership.
     */
    function claimOwnership() public onlyPendingOwner {
        emit LogOwnerShipTransferred(owner, pendingOwner);
        owner = pendingOwner;
        pendingOwner = address(0);
    }
}

contract ConflictResolutionManager is Ownable {
    /// @dev Conflict resolution contract.
    ConflictResolutionInterface public conflictRes;

    /// @dev New Conflict resolution contract.
    address public newConflictRes = 0;

    /// @dev Time update of new conflict resolution contract was initiated.
    uint public updateTime = 0;

    /// @dev Min time before new conflict res contract can be activated after initiating update.
    uint public constant MIN_TIMEOUT = 3 days;

    /// @dev Min time before new conflict res contract can be activated after initiating update.
    uint public constant MAX_TIMEOUT = 6 days;

    /// @dev Update of conflict resolution contract was initiated.
    event LogUpdatingConflictResolution(address newConflictResolutionAddress);

    /// @dev New conflict resolution contract is active.
    event LogUpdatedConflictResolution(address newConflictResolutionAddress);

    /**
     * @dev Constructor
     * @param _conflictResAddress conflict resolution contract address.
     */
    constructor(address _conflictResAddress) public {
        conflictRes = ConflictResolutionInterface(_conflictResAddress);
    }

    /**
     * @dev Initiate conflict resolution contract update.
     * @param _newConflictResAddress New conflict resolution contract address.
     */
    function updateConflictResolution(address _newConflictResAddress) public onlyOwner {
        newConflictRes = _newConflictResAddress;
        updateTime = block.timestamp;

        emit LogUpdatingConflictResolution(_newConflictResAddress);
    }

    /**
     * @dev Active new conflict resolution contract.
     */
    function activateConflictResolution() public onlyOwner {
        require(newConflictRes != 0);
        require(updateTime != 0);
        require(updateTime + MIN_TIMEOUT <= block.timestamp && block.timestamp <= updateTime + MAX_TIMEOUT);

        conflictRes = ConflictResolutionInterface(newConflictRes);
        newConflictRes = 0;
        updateTime = 0;

        emit LogUpdatedConflictResolution(newConflictRes);
    }
}

contract Pausable is Ownable {
    /// @dev Is contract paused.
    bool public paused = false;

    /// @dev Time pause was called
    uint public timePaused = 0;

    /// @dev Modifier, which only allows function execution if not paused.
    modifier onlyNotPaused() {
        require(!paused);
        _;
    }

    /// @dev Modifier, which only allows function execution if paused.
    modifier onlyPaused() {
        require(paused);
        _;
    }

    /// @dev Modifier, which only allows function execution if paused longer than timeSpan.
    modifier onlyPausedSince(uint timeSpan) {
        require(paused && timePaused + timeSpan <= block.timestamp);
        _;
    }

    /// @dev Event is fired if paused.
    event LogPause();

    /// @dev Event is fired if pause is ended.
    event LogUnpause();

    /**
     * @dev Pause contract. No new game sessions can be created.
     */
    function pause() public onlyOwner onlyNotPaused {
        paused = true;
        timePaused = block.timestamp;
        emit LogPause();
    }

    /**
     * @dev Unpause contract.
     */
    function unpause() public onlyOwner onlyPaused {
        paused = false;
        timePaused = 0;
        emit LogUnpause();
    }
}

contract Destroyable is Pausable {
    /// @dev After pausing the contract for 20 days owner can selfdestruct it.
    uint public constant TIMEOUT_DESTROY = 20 days;

    /**
     * @dev Destroy contract and transfer ether to address _targetAddress.
     */
    function destroy() public onlyOwner onlyPausedSince(TIMEOUT_DESTROY) {
        selfdestruct(owner);
    }
}

contract GameChannelBase is Destroyable, ConflictResolutionManager {
    /// @dev Different game session states.
    enum GameStatus {
        ENDED, ///< @dev Game session is ended.
        ACTIVE, ///< @dev Game session is active.
        PLAYER_INITIATED_END, ///< @dev Player initiated non regular end.
        SERVER_INITIATED_END ///< @dev Server initiated non regular end.
    }

    /// @dev Reason game session ended.
    enum ReasonEnded {
        REGULAR_ENDED, ///< @dev Game session is regularly ended.
        END_FORCED_BY_SERVER, ///< @dev Player did not respond. Server forced end.
        END_FORCED_BY_PLAYER ///< @dev Server did not respond. Player forced end.
    }

    struct Game {
        /// @dev Game session status.
        GameStatus status;

        /// @dev Player's stake.
        uint128 stake;

        /// @dev Last game round info if not regularly ended.
        /// If game session is ended normally this data is not used.
        uint8 gameType;
        uint32 roundId;
        uint16 betNum;
        uint betValue;
        int balance;
        bytes32 playerSeed;
        bytes32 serverSeed;
        uint endInitiatedTime;
    }

    /// @dev Minimal time span between profit transfer.
    uint public constant MIN_TRANSFER_TIMESPAN = 1 days;

    /// @dev Maximal time span between profit transfer.
    uint public constant MAX_TRANSFER_TIMSPAN = 6 * 30 days;

    bytes32 public constant TYPE_HASH = keccak256(abi.encodePacked(
        "uint32 Round Id",
        "uint8 Game Type",
        "uint16 Number",
        "uint Value (Wei)",
        "int Current Balance (Wei)",
        "bytes32 Server Hash",
        "bytes32 Player Hash",
        "uint Game Id",
        "address Contract Address"
     ));

    /// @dev Current active game sessions.
    uint public activeGames = 0;

    /// @dev Game session id counter. Points to next free game session slot. So gameIdCntr -1 is the
    // number of game sessions created.
    uint public gameIdCntr;

    /// @dev Only this address can accept and end games.
    address public serverAddress;

    /// @dev Address to transfer profit to.
    address public houseAddress;

    /// @dev Current house stake.
    uint public houseStake = 0;

    /// @dev House profit since last profit transfer.
    int public houseProfit = 0;

    /// @dev Min value player needs to deposit for creating game session.
    uint128 public minStake;

    /// @dev Max value player can deposit for creating game session.
    uint128 public maxStake;

    /// @dev Timeout until next profit transfer is allowed.
    uint public profitTransferTimeSpan = 14 days;

    /// @dev Last time profit transferred to house.
    uint public lastProfitTransferTimestamp;

    /// @dev Maps gameId to game struct.
    mapping (uint => Game) public gameIdGame;

    /// @dev Maps player address to current player game id.
    mapping (address => uint) public playerGameId;

    /// @dev Maps player address to pending returns.
    mapping (address => uint) public pendingReturns;

    /// @dev Modifier, which only allows to execute if house stake is high enough.
    modifier onlyValidHouseStake(uint _activeGames) {
        uint minHouseStake = conflictRes.minHouseStake(_activeGames);
        require(houseStake >= minHouseStake);
        _;
    }

    /// @dev Modifier to check if value send fulfills player stake requirements.
    modifier onlyValidValue() {
        require(minStake <= msg.value && msg.value <= maxStake);
        _;
    }

    /// @dev Modifier, which only allows server to call function.
    modifier onlyServer() {
        require(msg.sender == serverAddress);
        _;
    }

    /// @dev Modifier, which only allows to set valid transfer timeouts.
    modifier onlyValidTransferTimeSpan(uint transferTimeout) {
        require(transferTimeout >= MIN_TRANSFER_TIMESPAN
                && transferTimeout <= MAX_TRANSFER_TIMSPAN);
        _;
    }

    /// @dev This event is fired when player creates game session.
    event LogGameCreated(address indexed player, uint indexed gameId, uint128 stake, bytes32 indexed serverEndHash, bytes32 playerEndHash);

    /// @dev This event is fired when player requests conflict end.
    event LogPlayerRequestedEnd(address indexed player, uint indexed gameId);

    /// @dev This event is fired when server requests conflict end.
    event LogServerRequestedEnd(address indexed player, uint indexed gameId);

    /// @dev This event is fired when game session is ended.
    event LogGameEnded(address indexed player, uint indexed gameId, uint32 roundId, int balance, ReasonEnded reason);

    /// @dev this event is fired when owner modifies player's stake limits.
    event LogStakeLimitsModified(uint minStake, uint maxStake);

    /**
     * @dev Contract constructor.
     * @param _serverAddress Server address.
     * @param _minStake Min value player needs to deposit to create game session.
     * @param _maxStake Max value player can deposit to create game session.
     * @param _conflictResAddress Conflict resolution contract address.
     * @param _houseAddress House address to move profit to.
     */
    constructor(
        address _serverAddress,
        uint128 _minStake,
        uint128 _maxStake,
        address _conflictResAddress,
        address _houseAddress,
        uint _gameIdCntr
    )
        public
        ConflictResolutionManager(_conflictResAddress)
    {
        require(_minStake > 0 && _minStake <= _maxStake);
        require(_gameIdCntr > 0);

        gameIdCntr = _gameIdCntr;
        serverAddress = _serverAddress;
        houseAddress = _houseAddress;
        lastProfitTransferTimestamp = block.timestamp;
        minStake = _minStake;
        maxStake = _maxStake;
    }

    /**
     * @notice Withdraw pending returns.
     */
    function withdraw() public {
        uint toTransfer = pendingReturns[msg.sender];
        require(toTransfer > 0);

        pendingReturns[msg.sender] = 0;
        msg.sender.transfer(toTransfer);
    }

    /**
     * @notice Transfer house profit to houseAddress.
     */
    function transferProfitToHouse() public {
        require(lastProfitTransferTimestamp + profitTransferTimeSpan <= block.timestamp);

        // update last transfer timestamp
        lastProfitTransferTimestamp = block.timestamp;

        if (houseProfit <= 0) {
            // no profit to transfer
            return;
        }

        // houseProfit is gt 0 => safe to cast
        uint toTransfer = uint(houseProfit);
        assert(houseStake >= toTransfer);

        houseProfit = 0;
        houseStake = houseStake - toTransfer;

        houseAddress.transfer(toTransfer);
    }

    /**
     * @dev Set profit transfer time span.
     */
    function setProfitTransferTimeSpan(uint _profitTransferTimeSpan)
        public
        onlyOwner
        onlyValidTransferTimeSpan(_profitTransferTimeSpan)
    {
        profitTransferTimeSpan = _profitTransferTimeSpan;
    }

    /**
     * @dev Increase house stake by msg.value
     */
    function addHouseStake() public payable onlyOwner {
        houseStake += msg.value;
    }

    /**
     * @dev Withdraw house stake.
     */
    function withdrawHouseStake(uint value) public onlyOwner {
        uint minHouseStake = conflictRes.minHouseStake(activeGames);

        require(value <= houseStake && houseStake - value >= minHouseStake);
        require(houseProfit <= 0 || uint(houseProfit) <= houseStake - value);

        houseStake = houseStake - value;
        owner.transfer(value);
    }

    /**
     * @dev Withdraw house stake and profit.
     */
    function withdrawAll() public onlyOwner onlyPausedSince(3 days) {
        houseProfit = 0;
        uint toTransfer = houseStake;
        houseStake = 0;
        owner.transfer(toTransfer);
    }

    /**
     * @dev Set new house address.
     * @param _houseAddress New house address.
     */
    function setHouseAddress(address _houseAddress) public onlyOwner {
        houseAddress = _houseAddress;
    }

    /**
     * @dev Set stake min and max value.
     * @param _minStake Min stake.
     * @param _maxStake Max stake.
     */
    function setStakeRequirements(uint128 _minStake, uint128 _maxStake) public onlyOwner {
        require(_minStake > 0 && _minStake <= _maxStake);
        minStake = _minStake;
        maxStake = _maxStake;
        emit LogStakeLimitsModified(minStake, maxStake);
    }

    /**
     * @dev Close game session.
     * @param _game Game session data.
     * @param _gameId Id of game session.
     * @param _playerAddress Player's address of game session.
     * @param _reason Reason for closing game session.
     * @param _balance Game session balance.
     */
    function closeGame(
        Game storage _game,
        uint _gameId,
        uint32 _roundId,
        address _playerAddress,
        ReasonEnded _reason,
        int _balance
    )
        internal
    {
        _game.status = GameStatus.ENDED;

        assert(activeGames > 0);
        activeGames = activeGames - 1;

        payOut(_playerAddress, _game.stake, _balance);

        emit LogGameEnded(_playerAddress, _gameId, _roundId, _balance, _reason);
    }

    /**
     * @dev End game by paying out player and server.
     * @param _playerAddress Player's address.
     * @param _stake Player's stake.
     * @param _balance Player's balance.
     */
    function payOut(address _playerAddress, uint128 _stake, int _balance) internal {
        assert(_balance <= conflictRes.maxBalance());
        assert((int(_stake) + _balance) >= 0); // safe as _balance (see line above), _stake ranges are fixed.

        uint valuePlayer = uint(int(_stake) + _balance); // safe as _balance, _stake ranges are fixed.

        if (_balance > 0 && int(houseStake) < _balance) { // safe to cast houseStake is limited.
            // Should never happen!
            // House is bankrupt.
            // Payout left money.
            valuePlayer = houseStake;
        }

        houseProfit = houseProfit - _balance;

        int newHouseStake = int(houseStake) - _balance; // safe to cast and sub as houseStake, balance ranges are fixed
        assert(newHouseStake >= 0);
        houseStake = uint(newHouseStake);

        pendingReturns[_playerAddress] += valuePlayer;
        if (pendingReturns[_playerAddress] > 0) {
            safeSend(_playerAddress);
        }
    }

    /**
     * @dev Send value of pendingReturns[_address] to _address.
     * @param _address Address to send value to.
     */
    function safeSend(address _address) internal {
        uint valueToSend = pendingReturns[_address];
        assert(valueToSend > 0);

        pendingReturns[_address] = 0;
        if (_address.send(valueToSend) == false) {
            pendingReturns[_address] = valueToSend;
        }
    }

    /**
     * @dev Verify signature of given data. Throws on verification failure.
     * @param _sig Signature of given data in the form of rsv.
     * @param _address Address of signature signer.
     */
    function verifySig(
        uint32 _roundId,
        uint8 _gameType,
        uint16 _num,
        uint _value,
        int _balance,
        bytes32 _serverHash,
        bytes32 _playerHash,
        uint _gameId,
        address _contractAddress,
        bytes _sig,
        address _address
    )
        internal
        view
    {
        // check if this is the correct contract
        address contractAddress = this;
        require(_contractAddress == contractAddress);

        bytes32 roundHash = calcHash(
                _roundId,
                _gameType,
                _num,
                _value,
                _balance,
                _serverHash,
                _playerHash,
                _gameId,
                _contractAddress
        );

        verify(
                roundHash,
                _sig,
                _address
        );
    }

     /**
     * @dev Check if _sig is valid signature of _hash. Throws if invalid signature.
     * @param _hash Hash to check signature of.
     * @param _sig Signature of _hash.
     * @param _address Address of signer.
     */
    function verify(
        bytes32 _hash,
        bytes _sig,
        address _address
    )
        internal
        pure
    {
        bytes32 r;
        bytes32 s;
        uint8 v;

        (r, s, v) = signatureSplit(_sig);
        address addressRecover = ecrecover(_hash, v, r, s);
        require(addressRecover == _address);
    }

    /**
     * @dev Calculate typed hash of given data (compare eth_signTypedData).
     * @return Hash of given data.
     */
    function calcHash(
        uint32 _roundId,
        uint8 _gameType,
        uint16 _num,
        uint _value,
        int _balance,
        bytes32 _serverHash,
        bytes32 _playerHash,
        uint _gameId,
        address _contractAddress
    )
        private
        pure
        returns(bytes32)
    {
        bytes32 dataHash = keccak256(abi.encodePacked(
            _roundId,
            _gameType,
            _num,
            _value,
            _balance,
            _serverHash,
            _playerHash,
            _gameId,
            _contractAddress
        ));

        return keccak256(abi.encodePacked(
            TYPE_HASH,
            dataHash
        ));
    }

    /**
     * @dev Split the given signature of the form rsv in r s v. v is incremented with 27 if
     * it is below 2.
     * @param _signature Signature to split.
     * @return r s v
     */
    function signatureSplit(bytes _signature)
        private
        pure
        returns (bytes32 r, bytes32 s, uint8 v)
    {
        require(_signature.length == 65);

        assembly {
            r := mload(add(_signature, 32))
            s := mload(add(_signature, 64))
            v := and(mload(add(_signature, 65)), 0xff)
        }
        if (v < 2) {
            v = v + 27;
        }
    }
}

contract GameChannelConflict is GameChannelBase {
    /**
     * @dev Contract constructor.
     * @param _serverAddress Server address.
     * @param _minStake Min value player needs to deposit to create game session.
     * @param _maxStake Max value player can deposit to create game session.
     * @param _conflictResAddress Conflict resolution contract address
     * @param _houseAddress House address to move profit to
     */
    constructor(
        address _serverAddress,
        uint128 _minStake,
        uint128 _maxStake,
        address _conflictResAddress,
        address _houseAddress,
        uint _gameIdCtr
    )
        public
        GameChannelBase(_serverAddress, _minStake, _maxStake, _conflictResAddress, _houseAddress, _gameIdCtr)
    {
        // nothing to do
    }

    /**
     * @dev Used by server if player does not end game session.
     * @param _roundId Round id of bet.
     * @param _gameType Game type of bet.
     * @param _num Number of bet.
     * @param _value Value of bet.
     * @param _balance Balance before this bet.
     * @param _serverHash Hash of server seed for this bet.
     * @param _playerHash Hash of player seed for this bet.
     * @param _gameId Game session id.
     * @param _contractAddress Address of this contract.
     * @param _playerSig Player signature of this bet.
     * @param _playerAddress Address of player.
     * @param _serverSeed Server seed for this bet.
     * @param _playerSeed Player seed for this bet.
     */
    function serverEndGameConflict(
        uint32 _roundId,
        uint8 _gameType,
        uint16 _num,
        uint _value,
        int _balance,
        bytes32 _serverHash,
        bytes32 _playerHash,
        uint _gameId,
        address _contractAddress,
        bytes _playerSig,
        address _playerAddress,
        bytes32 _serverSeed,
        bytes32 _playerSeed
    )
        public
        onlyServer
    {
        verifySig(
                _roundId,
                _gameType,
                _num,
                _value,
                _balance,
                _serverHash,
                _playerHash,
                _gameId,
                _contractAddress,
                _playerSig,
                _playerAddress
        );

        serverEndGameConflictImpl(
                _roundId,
                _gameType,
                _num,
                _value,
                _balance,
                _serverHash,
                _playerHash,
                _serverSeed,
                _playerSeed,
                _gameId,
                _playerAddress
        );
    }

    /**
     * @notice Can be used by player if server does not answer to the end game session request.
     * @param _roundId Round id of bet.
     * @param _gameType Game type of bet.
     * @param _num Number of bet.
     * @param _value Value of bet.
     * @param _balance Balance before this bet.
     * @param _serverHash Hash of server seed for this bet.
     * @param _playerHash Hash of player seed for this bet.
     * @param _gameId Game session id.
     * @param _contractAddress Address of this contract.
     * @param _serverSig Server signature of this bet.
     * @param _playerSeed Player seed for this bet.
     */
    function playerEndGameConflict(
        uint32 _roundId,
        uint8 _gameType,
        uint16 _num,
        uint _value,
        int _balance,
        bytes32 _serverHash,
        bytes32 _playerHash,
        uint _gameId,
        address _contractAddress,
        bytes _serverSig,
        bytes32 _playerSeed
    )
        public
    {
        verifySig(
            _roundId,
            _gameType,
            _num,
            _value,
            _balance,
            _serverHash,
            _playerHash,
            _gameId,
            _contractAddress,
            _serverSig,
            serverAddress
        );

        playerEndGameConflictImpl(
            _roundId,
            _gameType,
            _num,
            _value,
            _balance,
            _playerHash,
            _playerSeed,
            _gameId,
            msg.sender
        );
    }

    /**
     * @notice Cancel active game without playing. Useful if server stops responding before
     * one game is played.
     * @param _gameId Game session id.
     */
    function playerCancelActiveGame(uint _gameId) public {
        address playerAddress = msg.sender;
        uint gameId = playerGameId[playerAddress];
        Game storage game = gameIdGame[gameId];

        require(gameId == _gameId);

        if (game.status == GameStatus.ACTIVE) {
            game.endInitiatedTime = block.timestamp;
            game.status = GameStatus.PLAYER_INITIATED_END;

            emit LogPlayerRequestedEnd(msg.sender, gameId);
        } else if (game.status == GameStatus.SERVER_INITIATED_END && game.roundId == 0) {
            closeGame(game, gameId, 0, playerAddress, ReasonEnded.REGULAR_ENDED, 0);
        } else {
            revert();
        }
    }

    /**
     * @dev Cancel active game without playing. Useful if player starts game session and
     * does not play.
     * @param _playerAddress Players' address.
     * @param _gameId Game session id.
     */
    function serverCancelActiveGame(address _playerAddress, uint _gameId) public onlyServer {
        uint gameId = playerGameId[_playerAddress];
        Game storage game = gameIdGame[gameId];

        require(gameId == _gameId);

        if (game.status == GameStatus.ACTIVE) {
            game.endInitiatedTime = block.timestamp;
            game.status = GameStatus.SERVER_INITIATED_END;

            emit LogServerRequestedEnd(msg.sender, gameId);
        } else if (game.status == GameStatus.PLAYER_INITIATED_END && game.roundId == 0) {
            closeGame(game, gameId, 0, _playerAddress, ReasonEnded.REGULAR_ENDED, 0);
        } else {
            revert();
        }
    }

    /**
    * @dev Force end of game if player does not respond. Only possible after a certain period of time
    * to give the player a chance to respond.
    * @param _playerAddress Player's address.
    */
    function serverForceGameEnd(address _playerAddress, uint _gameId) public onlyServer {
        uint gameId = playerGameId[_playerAddress];
        Game storage game = gameIdGame[gameId];

        require(gameId == _gameId);
        require(game.status == GameStatus.SERVER_INITIATED_END);

        // theoretically we have enough data to calculate winner
        // but as player did not respond assume he has lost.
        int newBalance = conflictRes.serverForceGameEnd(
            game.gameType,
            game.betNum,
            game.betValue,
            game.balance,
            game.stake,
            game.endInitiatedTime
        );

        closeGame(game, gameId, game.roundId, _playerAddress, ReasonEnded.END_FORCED_BY_SERVER, newBalance);
    }

    /**
    * @notice Force end of game if server does not respond. Only possible after a certain period of time
    * to give the server a chance to respond.
    */
    function playerForceGameEnd(uint _gameId) public {
        address playerAddress = msg.sender;
        uint gameId = playerGameId[playerAddress];
        Game storage game = gameIdGame[gameId];

        require(gameId == _gameId);
        require(game.status == GameStatus.PLAYER_INITIATED_END);

        int newBalance = conflictRes.playerForceGameEnd(
            game.gameType,
            game.betNum,
            game.betValue,
            game.balance,
            game.stake,
            game.endInitiatedTime
        );

        closeGame(game, gameId, game.roundId, playerAddress, ReasonEnded.END_FORCED_BY_PLAYER, newBalance);
    }

    /**
     * @dev Conflict handling implementation. Stores game data and timestamp if game
     * is active. If server has already marked conflict for game session the conflict
     * resolution contract is used (compare conflictRes).
     * @param _roundId Round id of bet.
     * @param _gameType Game type of bet.
     * @param _num Number of bet.
     * @param _value Value of bet.
     * @param _balance Balance before this bet.
     * @param _playerHash Hash of player's seed for this bet.
     * @param _playerSeed Player's seed for this bet.
     * @param _gameId game Game session id.
     * @param _playerAddress Player's address.
     */
    function playerEndGameConflictImpl(
        uint32 _roundId,
        uint8 _gameType,
        uint16 _num,
        uint _value,
        int _balance,
        bytes32 _playerHash,
        bytes32 _playerSeed,
        uint _gameId,
        address _playerAddress
    )
        private
    {
        uint gameId = playerGameId[_playerAddress];
        Game storage game = gameIdGame[gameId];
        int maxBalance = conflictRes.maxBalance();

        require(gameId == _gameId);
        require(_roundId > 0);
        require(keccak256(abi.encodePacked(_playerSeed)) == _playerHash);
        require(-int(game.stake) <= _balance && _balance <= maxBalance); // save to cast as ranges are fixed
        require(conflictRes.isValidBet(_gameType, _num, _value));
        require(int(game.stake) + _balance - int(_value) >= 0); // save to cast as ranges are fixed

        if (game.status == GameStatus.SERVER_INITIATED_END && game.roundId == _roundId) {
            game.playerSeed = _playerSeed;
            endGameConflict(game, gameId, _playerAddress);
        } else if (game.status == GameStatus.ACTIVE
                || (game.status == GameStatus.SERVER_INITIATED_END && game.roundId < _roundId)) {
            game.status = GameStatus.PLAYER_INITIATED_END;
            game.endInitiatedTime = block.timestamp;
            game.roundId = _roundId;
            game.gameType = _gameType;
            game.betNum = _num;
            game.betValue = _value;
            game.balance = _balance;
            game.playerSeed = _playerSeed;
            game.serverSeed = bytes32(0);

            emit LogPlayerRequestedEnd(msg.sender, gameId);
        } else {
            revert();
        }
    }

    /**
     * @dev Conflict handling implementation. Stores game data and timestamp if game
     * is active. If player has already marked conflict for game session the conflict
     * resolution contract is used (compare conflictRes).
     * @param _roundId Round id of bet.
     * @param _gameType Game type of bet.
     * @param _num Number of bet.
     * @param _value Value of bet.
     * @param _balance Balance before this bet.
     * @param _serverHash Hash of server's seed for this bet.
     * @param _playerHash Hash of player's seed for this bet.
     * @param _serverSeed Server's seed for this bet.
     * @param _playerSeed Player's seed for this bet.
     * @param _playerAddress Player's address.
     */
    function serverEndGameConflictImpl(
        uint32 _roundId,
        uint8 _gameType,
        uint16 _num,
        uint _value,
        int _balance,
        bytes32 _serverHash,
        bytes32 _playerHash,
        bytes32 _serverSeed,
        bytes32 _playerSeed,
        uint _gameId,
        address _playerAddress
    )
        private
    {
        uint gameId = playerGameId[_playerAddress];
        Game storage game = gameIdGame[gameId];
        int maxBalance = conflictRes.maxBalance();

        require(gameId == _gameId);
        require(_roundId > 0);
        require(keccak256(abi.encodePacked(_serverSeed)) == _serverHash);
        require(keccak256(abi.encodePacked(_playerSeed)) == _playerHash);
        require(-int(game.stake) <= _balance && _balance <= maxBalance); // save to cast as ranges are fixed
        require(conflictRes.isValidBet(_gameType, _num, _value));
        require(int(game.stake) + _balance - int(_value) >= 0); // save to cast as ranges are fixed

        if (game.status == GameStatus.PLAYER_INITIATED_END && game.roundId == _roundId) {
            game.serverSeed = _serverSeed;
            endGameConflict(game, gameId, _playerAddress);
        } else if (game.status == GameStatus.ACTIVE
                || (game.status == GameStatus.PLAYER_INITIATED_END && game.roundId < _roundId)) {
            game.status = GameStatus.SERVER_INITIATED_END;
            game.endInitiatedTime = block.timestamp;
            game.roundId = _roundId;
            game.gameType = _gameType;
            game.betNum = _num;
            game.betValue = _value;
            game.balance = _balance;
            game.serverSeed = _serverSeed;
            game.playerSeed = _playerSeed;

            emit LogServerRequestedEnd(_playerAddress, gameId);
        } else {
            revert();
        }
    }

    /**
     * @dev End conflicting game.
     * @param _game Game session data.
     * @param _gameId Game session id.
     * @param _playerAddress Player's address.
     */
    function endGameConflict(Game storage _game, uint _gameId, address _playerAddress) private {
        int newBalance = conflictRes.endGameConflict(
            _game.gameType,
            _game.betNum,
            _game.betValue,
            _game.balance,
            _game.stake,
            _game.serverSeed,
            _game.playerSeed
        );

        closeGame(_game, _gameId, _game.roundId, _playerAddress, ReasonEnded.REGULAR_ENDED, newBalance);
    }
}

contract GameChannel is GameChannelConflict {
    /**
     * @dev contract constructor
     * @param _serverAddress Server address.
     * @param _minStake Min value player needs to deposit to create game session.
     * @param _maxStake Max value player can deposit to create game session.
     * @param _conflictResAddress Conflict resolution contract address.
     * @param _houseAddress House address to move profit to.
     */
    constructor(
        address _serverAddress,
        uint128 _minStake,
        uint128 _maxStake,
        address _conflictResAddress,
        address _houseAddress,
        uint _gameIdCntr
    )
        public
        GameChannelConflict(_serverAddress, _minStake, _maxStake, _conflictResAddress, _houseAddress, _gameIdCntr)
    {
        // nothing to do
    }

    /**
     * @notice Create games session request. msg.value needs to be valid stake value.
     * @param _playerEndHash last entry of players' hash chain.
     * @param _previousGameId player's previous game id, initial 0.
     * @param _createBefore game can be only created before this timestamp.
     * @param _serverEndHash last entry of server's hash chain.
     * @param _serverSig server signature. See verifyCreateSig
     */
    function createGame(
        bytes32 _playerEndHash,
        uint _previousGameId,
        uint _createBefore,
        bytes32 _serverEndHash,
        bytes _serverSig
    )
        public
        payable
        onlyValidValue
        onlyValidHouseStake(activeGames + 1)
        onlyNotPaused
    {
        uint previousGameId = playerGameId[msg.sender];
        Game storage game = gameIdGame[previousGameId];

        require(game.status == GameStatus.ENDED);
        require(previousGameId == _previousGameId);
        require(block.timestamp < _createBefore);

        verifyCreateSig(msg.sender, _previousGameId, _createBefore, _serverEndHash, _serverSig);

        uint gameId = gameIdCntr++;
        playerGameId[msg.sender] = gameId;
        Game storage newGame = gameIdGame[gameId];

        newGame.stake = uint128(msg.value); // It's safe to cast msg.value as it is limited, see onlyValidValue
        newGame.status = GameStatus.ACTIVE;

        activeGames = activeGames + 1;

        // It's safe to cast msg.value as it is limited, see onlyValidValue
        emit LogGameCreated(msg.sender, gameId, uint128(msg.value), _serverEndHash,  _playerEndHash);
    }


    /**
     * @dev Regular end game session. Used if player and house have both
     * accepted current game session state.
     * The game session with gameId _gameId is closed
     * and the player paid out. This functions is called by the server after
     * the player requested the termination of the current game session.
     * @param _roundId Round id of bet.
     * @param _gameType Game type of bet.
     * @param _num Number of bet.
     * @param _value Value of bet.
     * @param _balance Current balance.
     * @param _serverHash Hash of server's seed for this bet.
     * @param _playerHash Hash of player's seed for this bet.
     * @param _gameId Game session id.
     * @param _contractAddress Address of this contract.
     * @param _playerAddress Address of player.
     * @param _playerSig Player's signature of this bet.
     */
    function serverEndGame(
        uint32 _roundId,
        uint8 _gameType,
        uint16 _num,
        uint _value,
        int _balance,
        bytes32 _serverHash,
        bytes32 _playerHash,
        uint _gameId,
        address _contractAddress,
        address _playerAddress,
        bytes _playerSig
    )
        public
        onlyServer
    {
        verifySig(
                _roundId,
                _gameType,
                _num,
                _value,
                _balance,
                _serverHash,
                _playerHash,
                _gameId,
                _contractAddress,
                _playerSig,
                _playerAddress
        );

        regularEndGame(_playerAddress, _roundId, _gameType, _num, _value, _balance, _gameId, _contractAddress);
    }

    /**
     * @notice Regular end game session. Normally not needed as server ends game (@see serverEndGame).
     * Can be used by player if server does not end game session.
     * @param _roundId Round id of bet.
     * @param _gameType Game type of bet.
     * @param _num Number of bet.
     * @param _value Value of bet.
     * @param _balance Current balance.
     * @param _serverHash Hash of server's seed for this bet.
     * @param _playerHash Hash of player's seed for this bet.
     * @param _gameId Game session id.
     * @param _contractAddress Address of this contract.
     * @param _serverSig Server's signature of this bet.
     */
    function playerEndGame(
        uint32 _roundId,
        uint8 _gameType,
        uint16 _num,
        uint _value,
        int _balance,
        bytes32 _serverHash,
        bytes32 _playerHash,
        uint _gameId,
        address _contractAddress,
        bytes _serverSig
    )
        public
    {
        verifySig(
                _roundId,
                _gameType,
                _num,
                _value,
                _balance,
                _serverHash,
                _playerHash,
                _gameId,
                _contractAddress,
                _serverSig,
                serverAddress
        );

        regularEndGame(msg.sender, _roundId, _gameType, _num, _value, _balance, _gameId, _contractAddress);
    }

    /**
     * @dev Verify server signature.
     * @param _playerAddress player's address.
     * @param _previousGameId player's previous game id, initial 0.
     * @param _createBefore game can be only created before this timestamp.
     * @param _serverEndHash last entry of server's hash chain.
     * @param _serverSig server signature.
     */
    function verifyCreateSig(
        address _playerAddress,
        uint _previousGameId,
        uint _createBefore,
        bytes32 _serverEndHash,
        bytes _serverSig
    )
        private view
    {
        address contractAddress = this;
        bytes32 hash = keccak256(abi.encodePacked(
            contractAddress, _playerAddress, _previousGameId, _createBefore, _serverEndHash
        ));

        verify(hash, _serverSig, serverAddress);
    }

    /**
     * @dev Regular end game session implementation. Used if player and house have both
     * accepted current game session state. The game session with gameId _gameId is closed
     * and the player paid out.
     * @param _playerAddress Address of player.
     * @param _gameType Game type of bet.
     * @param _num Number of bet.
     * @param _value Value of bet.
     * @param _balance Current balance.
     * @param _gameId Game session id.
     * @param _contractAddress Address of this contract.
     */
    function regularEndGame(
        address _playerAddress,
        uint32 _roundId,
        uint8 _gameType,
        uint16 _num,
        uint _value,
        int _balance,
        uint _gameId,
        address _contractAddress
    )
        private
    {
        uint gameId = playerGameId[_playerAddress];
        Game storage game = gameIdGame[gameId];
        address contractAddress = this;
        int maxBalance = conflictRes.maxBalance();

        require(_gameId == gameId);
        require(_roundId > 0);
        // save to cast as game.stake hash fixed range
        require(-int(game.stake) <= _balance && _balance <= maxBalance);
        require((_gameType == 0) && (_num == 0) && (_value == 0));
        require(game.status == GameStatus.ACTIVE);

        assert(_contractAddress == contractAddress);

        closeGame(game, gameId, _roundId, _playerAddress, ReasonEnded.REGULAR_ENDED, _balance);
    }
}

Contract Security Audit

Contract ABI

[{"constant":false,"inputs":[{"name":"_roundId","type":"uint32"},{"name":"_gameType","type":"uint8"},{"name":"_num","type":"uint16"},{"name":"_value","type":"uint256"},{"name":"_balance","type":"int256"},{"name":"_serverHash","type":"bytes32"},{"name":"_playerHash","type":"bytes32"},{"name":"_gameId","type":"uint256"},{"name":"_contractAddress","type":"address"},{"name":"_serverSig","type":"bytes"},{"name":"_playerSeed","type":"bytes32"}],"name":"playerEndGameConflict","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"MIN_TRANSFER_TIMESPAN","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"playerGameId","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"pendingReturns","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"profitTransferTimeSpan","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"minStake","outputs":[{"name":"","type":"uint128"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"lastProfitTransferTimestamp","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"claimOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"addHouseStake","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"MIN_TIMEOUT","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"timePaused","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"conflictRes","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"TYPE_HASH","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_gameId","type":"uint256"}],"name":"playerForceGameEnd","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"value","type":"uint256"}],"name":"withdrawHouseStake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"destroy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"gameIdGame","outputs":[{"name":"status","type":"uint8"},{"name":"stake","type":"uint128"},{"name":"gameType","type":"uint8"},{"name":"roundId","type":"uint32"},{"name":"betNum","type":"uint16"},{"name":"betValue","type":"uint256"},{"name":"balance","type":"int256"},{"name":"playerSeed","type":"bytes32"},{"name":"serverSeed","type":"bytes32"},{"name":"endInitiatedTime","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"withdrawAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"houseProfit","outputs":[{"name":"","type":"int256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MAX_TRANSFER_TIMSPAN","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_profitTransferTimeSpan","type":"uint256"}],"name":"setProfitTransferTimeSpan","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"activateConflictResolution","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"newConflictRes","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_playerAddress","type":"address"},{"name":"_gameId","type":"uint256"}],"name":"serverCancelActiveGame","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_roundId","type":"uint32"},{"name":"_gameType","type":"uint8"},{"name":"_num","type":"uint16"},{"name":"_value","type":"uint256"},{"name":"_balance","type":"int256"},{"name":"_serverHash","type":"bytes32"},{"name":"_playerHash","type":"bytes32"},{"name":"_gameId","type":"uint256"},{"name":"_contractAddress","type":"address"},{"name":"_serverSig","type":"bytes"}],"name":"playerEndGame","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_playerEndHash","type":"bytes32"},{"name":"_previousGameId","type":"uint256"},{"name":"_createBefore","type":"uint256"},{"name":"_serverEndHash","type":"bytes32"},{"name":"_serverSig","type":"bytes"}],"name":"createGame","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_gameId","type":"uint256"}],"name":"playerCancelActiveGame","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_roundId","type":"uint32"},{"name":"_gameType","type":"uint8"},{"name":"_num","type":"uint16"},{"name":"_value","type":"uint256"},{"name":"_balance","type":"int256"},{"name":"_serverHash","type":"bytes32"},{"name":"_playerHash","type":"bytes32"},{"name":"_gameId","type":"uint256"},{"name":"_contractAddress","type":"address"},{"name":"_playerSig","type":"bytes"},{"name":"_playerAddress","type":"address"},{"name":"_serverSeed","type":"bytes32"},{"name":"_playerSeed","type":"bytes32"}],"name":"serverEndGameConflict","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"TIMEOUT_DESTROY","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"houseStake","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newConflictResAddress","type":"address"}],"name":"updateConflictResolution","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_playerAddress","type":"address"},{"name":"_gameId","type":"uint256"}],"name":"serverForceGameEnd","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_minStake","type":"uint128"},{"name":"_maxStake","type":"uint128"}],"name":"setStakeRequirements","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_roundId","type":"uint32"},{"name":"_gameType","type":"uint8"},{"name":"_num","type":"uint16"},{"name":"_value","type":"uint256"},{"name":"_balance","type":"int256"},{"name":"_serverHash","type":"bytes32"},{"name":"_playerHash","type":"bytes32"},{"name":"_gameId","type":"uint256"},{"name":"_contractAddress","type":"address"},{"name":"_playerAddress","type":"address"},{"name":"_playerSig","type":"bytes"}],"name":"serverEndGame","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"houseAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"serverAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"updateTime","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MAX_TIMEOUT","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"pendingOwner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"activeGames","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"maxStake","outputs":[{"name":"","type":"uint128"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_houseAddress","type":"address"}],"name":"setHouseAddress","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"gameIdCntr","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"transferProfitToHouse","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_serverAddress","type":"address"},{"name":"_minStake","type":"uint128"},{"name":"_maxStake","type":"uint128"},{"name":"_conflictResAddress","type":"address"},{"name":"_houseAddress","type":"address"},{"name":"_gameIdCntr","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"player","type":"address"},{"indexed":true,"name":"gameId","type":"uint256"},{"indexed":false,"name":"stake","type":"uint128"},{"indexed":true,"name":"serverEndHash","type":"bytes32"},{"indexed":false,"name":"playerEndHash","type":"bytes32"}],"name":"LogGameCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"player","type":"address"},{"indexed":true,"name":"gameId","type":"uint256"}],"name":"LogPlayerRequestedEnd","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"player","type":"address"},{"indexed":true,"name":"gameId","type":"uint256"}],"name":"LogServerRequestedEnd","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"player","type":"address"},{"indexed":true,"name":"gameId","type":"uint256"},{"indexed":false,"name":"roundId","type":"uint32"},{"indexed":false,"name":"balance","type":"int256"},{"indexed":false,"name":"reason","type":"uint8"}],"name":"LogGameEnded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"minStake","type":"uint256"},{"indexed":false,"name":"maxStake","type":"uint256"}],"name":"LogStakeLimitsModified","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"newConflictResolutionAddress","type":"address"}],"name":"LogUpdatingConflictResolution","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"newConflictResolutionAddress","type":"address"}],"name":"LogUpdatedConflictResolution","type":"event"},{"anonymous":false,"inputs":[],"name":"LogPause","type":"event"},{"anonymous":false,"inputs":[],"name":"LogUnpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"LogOwnerShipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"LogOwnerShipTransferInitiated","type":"event"}]

60806040526001805460a060020a60ff02191690556000600281905560048054600160a060020a031916905560058190556006819055600a819055600b5562127500600d5534801561005057600080fd5b5060405160c0806200315c83398101604090815281516020830151918301516060840151608085015160a0909501516000805433600160a060020a0319918216178255600180548216905560038054909116600160a060020a038516179055939592939192918690869086908690869086908690869086908690869086906001608060020a0386161180156100f75750836001608060020a0316856001608060020a031611155b151561010257600080fd5b6000811161010f57600080fd5b60075560088054600160a060020a03968716600160a060020a031991821617909155600980549290961691161790935542600e55600c80546001608060020a03928316700100000000000000000000000000000000029383166001608060020a03199091161790911691909117905550505050505050505050505050612fc1806200019b6000396000f3006080604052600436106102425763ffffffff60e060020a6000350416630b305c62811461024757806319fc36ed146102e257806325b05c881461030957806326b387bb1461032a5780632c94a2351461034b578063375b3c0a146103605780633ccfd60b146103915780633f4ba83a146103a657806341b80184146103bb5780634e71e0c8146103d05780634f739ff0146103e5578063543ad1df146103ed578063563c23a0146104025780635ba2dd22146104175780635c975abb1461044857806364d4c81914610471578063665eba291461048657806381efc01d1461049e57806383197ef0146104b657806383e256dc146104cb5780638456cb591461055f578063853828b61461057457806388fedd04146105895780638da5cb5b1461059e578063947bc72d146105b35780639c0051db146105c85780639f34ce14146105e0578063a09f8659146105f5578063a8182cd31461060a578063ae6409231461062e578063afc81953146106c5578063aff06fbd14610723578063b5d9f80b1461073b578063bd5c4e24146107e7578063c861f3a0146107fc578063cbffb1ae14610811578063d1e9dcbf14610832578063d6e5fe9814610856578063d6f0b4841461087d578063d7cee31e1461091f578063db420fe314610934578063dc55509014610949578063de38eb3a1461095e578063e30c397814610973578063e475222e14610988578063ea1b28e01461099d578063ef3aaf54146109b2578063f2fde38b146109d3578063f87ffb74146109f4578063fd306ca714610a09575b600080fd5b34801561025357600080fd5b50604080516020601f610124356004818101359283018490048402850184019095528184526102e09463ffffffff8135169460ff60248035919091169561ffff6044351695606435956084359560a4359560c4359560e43595600160a060020a0361010435169536956101449493019181908401838280828437509497505093359450610a1e9350505050565b005b3480156102ee57600080fd5b506102f7610a64565b60408051918252519081900360200190f35b34801561031557600080fd5b506102f7600160a060020a0360043516610a6b565b34801561033657600080fd5b506102f7600160a060020a0360043516610a7d565b34801561035757600080fd5b506102f7610a8f565b34801561036c57600080fd5b50610375610a95565b604080516001608060020a039092168252519081900360200190f35b34801561039d57600080fd5b506102e0610aa4565b3480156103b257600080fd5b506102e0610aff565b3480156103c757600080fd5b506102f7610b7c565b3480156103dc57600080fd5b506102e0610b82565b6102e0610c0a565b3480156103f957600080fd5b506102f7610c2b565b34801561040e57600080fd5b506102f7610c32565b34801561042357600080fd5b5061042c610c38565b60408051600160a060020a039092168252519081900360200190f35b34801561045457600080fd5b5061045d610c47565b604080519115158252519081900360200190f35b34801561047d57600080fd5b506102f7610c57565b34801561049257600080fd5b506102e0600435610e25565b3480156104aa57600080fd5b506102e0600435610f8c565b3480156104c257600080fd5b506102e06110c8565b3480156104d757600080fd5b506104e360043561111a565b604051808b60038111156104f357fe5b60ff90811682526001608060020a03909b166020820152989099166040808a019190915263ffffffff909716606089015261ffff909516608088015260a087019390935260c086019190915260e085015261010084015261012083015251908190036101400192509050f35b34801561056b57600080fd5b506102e0611195565b34801561058057600080fd5b506102e0611216565b34801561059557600080fd5b506102f76112a2565b3480156105aa57600080fd5b5061042c6112a8565b3480156105bf57600080fd5b506102f76112b7565b3480156105d457600080fd5b506102e06004356112be565b3480156105ec57600080fd5b506102e06112fd565b34801561060157600080fd5b5061042c6113cf565b34801561061657600080fd5b506102e0600160a060020a03600435166024356113de565b34801561063a57600080fd5b50604080516020601f610124356004818101359283018490048402850184019095528184526102e09463ffffffff8135169460ff60248035919091169561ffff6044351695606435956084359560a4359560c4359560e43595600160a060020a0361010435169536956101449493019181908401838280828437509497506114d09650505050505050565b604080516020601f6084356004818101359283018490048402850184019095528184526102e0948035946024803595604435956064359536959460a49490939101919081908401838280828437509497506115149650505050505050565b34801561072f57600080fd5b506102e0600435611750565b34801561074757600080fd5b50604080516020601f610124356004818101359283018490048402850184019095528184526102e09463ffffffff8135169460ff60248035919091169561ffff6044351695606435956084359560a4359560c4359560e43595600160a060020a03610104351695369561014494930191819084018382808284375094975050508335600160a060020a031694505050602082013591604001359050611815565b3480156107f357600080fd5b506102f7611861565b34801561080857600080fd5b506102f7611868565b34801561081d57600080fd5b506102e0600160a060020a036004351661186e565b34801561083e57600080fd5b506102e0600160a060020a03600435166024356118ea565b34801561086257600080fd5b506102e06001608060020a0360043581169060243516611a75565b34801561088957600080fd5b5060408051602060046101443581810135601f81018490048402850184019095528484526102e094823563ffffffff16946024803560ff169560443561ffff1695606435956084359560a4359560c4359560e4359561010435600160a060020a0390811696610124359091169536959194610164949093910191908190840183828082843750949750611b4f9650505050505050565b34801561092b57600080fd5b5061042c611b89565b34801561094057600080fd5b5061042c611b98565b34801561095557600080fd5b506102f7611ba7565b34801561096a57600080fd5b506102f7611bad565b34801561097f57600080fd5b5061042c611bb4565b34801561099457600080fd5b506102f7611bc3565b3480156109a957600080fd5b50610375611bc9565b3480156109be57600080fd5b506102e0600160a060020a0360043516611bec565b3480156109df57600080fd5b506102e0600160a060020a0360043516611c32565b348015610a0057600080fd5b506102f7611ca7565b348015610a1557600080fd5b506102e0611cad565b610a468b8b8b8b8b8b8b8b8b8b600860009054906101000a9004600160a060020a0316611d32565b610a578b8b8b8b8b8a878b33611d68565b5050505050505050505050565b6201518081565b60106020526000908152604090205481565b60116020526000908152604090205481565b600d5481565b600c546001608060020a031681565b33600090815260116020526040812054908111610ac057600080fd5b336000818152601160205260408082208290555183156108fc0291849190818181858888f19350505050158015610afb573d6000803e3d6000fd5b5050565b600054600160a060020a03163314610b1657600080fd5b60015460a060020a900460ff161515610b2e57600080fd5b6001805474ff000000000000000000000000000000000000000019169055600060028190556040517f730c1faaa977b67dacf1e2451ef54556e04a07d577785ff79f6d31f73502efc99190a1565b600e5481565b600154600160a060020a03163314610b9957600080fd5b60015460008054604051600160a060020a0393841693909116917f897d3c8bbea11029ba3b26eb993fe8edb14c2c4c0d2ecceccce41d1d83d3e35991a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b600054600160a060020a03163314610c2157600080fd5b600a805434019055565b6203f48081565b60025481565b600354600160a060020a031681565b60015460a060020a900460ff1681565b604080517f75696e74333220526f756e6420496400000000000000000000000000000000006020808301919091527f75696e74382047616d6520547970650000000000000000000000000000000000602f8301527f75696e743136204e756d62657200000000000000000000000000000000000000603e8301527f75696e742056616c756520285765692900000000000000000000000000000000604b8301527f696e742043757272656e742042616c616e636520285765692900000000000000605b8301527f627974657333322053657276657220486173680000000000000000000000000060748301527f6279746573333220506c6179657220486173680000000000000000000000000060878301527f75696e742047616d652049640000000000000000000000000000000000000000609a8301527f6164647265737320436f6e74726163742041646472657373000000000000000060a68301528251609e81840301815260be90920192839052815191929182918401908083835b60208310610df55780518252601f199092019160209182019101610dd6565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902081565b33600081815260106020908152604080832054808452600f90925282209091848314610e5057600080fd5b6002825460ff166003811115610e6257fe5b14610e6c57600080fd5b6003548254600184015460028501546005860154604080517fca7140ad00000000000000000000000000000000000000000000000000000000815271010000000000000000000000000000000000860460ff16600482015260b060020a860461ffff166024820152604481019490945260648401929092526101009093046001608060020a0316608483015260a48201929092529051600160a060020a039092169163ca7140ad9160c4808201926020929091908290030181600087803b158015610f3657600080fd5b505af1158015610f4a573d6000803e3d6000fd5b505050506040513d6020811015610f6057600080fd5b50518254909150610f859083908590609060020a900463ffffffff1687600286612141565b5050505050565b60008054600160a060020a03163314610fa457600080fd5b600354600654604080517f73c4726b000000000000000000000000000000000000000000000000000000008152600481019290925251600160a060020a03909216916373c4726b916024808201926020929091908290030181600087803b15801561100e57600080fd5b505af1158015611022573d6000803e3d6000fd5b505050506040513d602081101561103857600080fd5b5051600a54909150821180159061105357508082600a540310155b151561105e57600080fd5b6000600b54131580611076575081600a5403600b5411155b151561108157600080fd5b600a8054839003905560008054604051600160a060020a039091169184156108fc02918591818181858888f193505050501580156110c3573d6000803e3d6000fd5b505050565b600054600160a060020a031633146110df57600080fd5b600154621a5e009060a060020a900460ff168015611101575042816002540111155b151561110c57600080fd5b600054600160a060020a0316ff5b600f6020526000908152604090208054600182015460028301546003840154600485015460059095015460ff8086169661010087046001608060020a03169671010000000000000000000000000000000000810490921695609060020a830463ffffffff169560b060020a90930461ffff169490939091908a565b600054600160a060020a031633146111ac57600080fd5b60015460a060020a900460ff16156111c357600080fd5b6001805474ff0000000000000000000000000000000000000000191660a060020a179055426002556040517f4b314b34e912fda7f95e7d23e9c8c95f82f0aff1984e4ce592a0b005f905562490600090a1565b60008054600160a060020a0316331461122e57600080fd5b6001546203f4809060a060020a900460ff168015611250575042816002540111155b151561125b57600080fd5b6000600b819055600a8054908290558154604051919450600160a060020a03169184156108fc02918591818181858888f193505050501580156110c3573d6000803e3d6000fd5b600b5481565b600054600160a060020a031681565b62ed4e0081565b600054600160a060020a031633146112d557600080fd5b806201518081101580156112ec575062ed4e008111155b15156112f757600080fd5b50600d55565b600054600160a060020a0316331461131457600080fd5b600454600160a060020a0316151561132b57600080fd5b600554151561133957600080fd5b426203f480600554011115801561135757506207e900600554014211155b151561136257600080fd5b600480546003805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a038416179091551690556000600581905560408051918252517f28de3c2df3d09a8b061f86cd0c78b7d02f1f5caffcd086ff45ee12a4a51056c89181900360200190a1565b600454600160a060020a031681565b6008546000908190600160a060020a031633146113fa57600080fd5b5050600160a060020a038216600090815260106020908152604080832054808452600f90925290912082821461142f57600080fd5b6001815460ff16600381111561144157fe5b141561148a57426005820155805460ff19166003178155604051829033907fdbbc392d5391708a9def7f560f8cbdef92e1bb37e5104831e78feda1488b7ab090600090a36114ca565b6002815460ff16600381111561149c57fe5b1480156114b557508054609060020a900463ffffffff16155b15610242576114ca8183600087600080612141565b50505050565b6114f88a8a8a8a8a8a8a8a8a8a600860009054906101000a9004600160a060020a0316611d32565b611508338b8b8b8b8b89896121ef565b50505050505050505050565b600c54600090819081908190346001608060020a03909116118015906115595750600c5470010000000000000000000000000000000090046001608060020a03163411155b151561156457600080fd5b600654600354604080517f73c4726b00000000000000000000000000000000000000000000000000000000815260019093016004840181905290519092600092600160a060020a0316916373c4726b9160248082019260209290919082900301818787803b1580156115d557600080fd5b505af11580156115e9573d6000803e3d6000fd5b505050506040513d60208110156115ff57600080fd5b5051600a5490915081111561161357600080fd5b60015460a060020a900460ff161561162a57600080fd5b33600090815260106020908152604080832054808452600f90925282209097509550855460ff16600381111561165c57fe5b1461166657600080fd5b858a1461167257600080fd5b42891161167e57600080fd5b61168b338b8b8b8b612353565b600780546001808201909255336000908152601060209081526040808320849055838352600f9091529020805470ffffffffffffffffffffffffffffffff001916610100346001608060020a031602178082559196509450849060ff191682800217905550600680546001019055604080516001608060020a0334168152602081018d905281518a92879233927fd25faca801440882fa5d7c7f70b072a2ad89621e277ee0b6f9923ccac48411b1929181900390910190a45050505050505050505050565b33600081815260106020908152604080832054808452600f90925290912083821461177a57600080fd5b6001815460ff16600381111561178c57fe5b14156117d557426005820155805460ff19166002178155604051829033907f15df88512f2c79e9bb3062ae86120f5df5a70ffd25fde294717671ad2932d27890600090a36114ca565b6003815460ff1660038111156117e757fe5b14801561180057508054609060020a900463ffffffff16155b15610242576114ca8183600086600080612141565b600854600160a060020a0316331461182c57600080fd5b61183f8d8d8d8d8d8d8d8d8d8d8d611d32565b6118528d8d8d8d8d8d8d89898f8d612430565b50505050505050505050505050565b621a5e0081565b600a5481565b600054600160a060020a0316331461188557600080fd5b60048054600160a060020a03831673ffffffffffffffffffffffffffffffffffffffff1990911681179091554260055560408051918252517f97044e884f04922f1959ef2de012f4734423df2d4da57fd4c5eaf40cd63b525f9181900360200190a150565b60085460009081908190600160a060020a0316331461190857600080fd5b600160a060020a038516600090815260106020908152604080832054808452600f909252909120909350915083831461194057600080fd5b6003825460ff16600381111561195257fe5b1461195c57600080fd5b6003548254600184015460028501546005860154604080517f834d42c600000000000000000000000000000000000000000000000000000000815271010000000000000000000000000000000000860460ff16600482015260b060020a860461ffff166024820152604481019490945260648401929092526101009093046001608060020a0316608483015260a48201929092529051600160a060020a039092169163834d42c69160c4808201926020929091908290030181600087803b158015611a2657600080fd5b505af1158015611a3a573d6000803e3d6000fd5b505050506040513d6020811015611a5057600080fd5b50518254909150610f859083908590609060020a900463ffffffff1688600186612141565b600054600160a060020a03163314611a8c57600080fd5b6000826001608060020a0316118015611ab75750806001608060020a0316826001608060020a031611155b1515611ac257600080fd5b600c80546fffffffffffffffffffffffffffffffff19166001608060020a038481169190911781167001000000000000000000000000000000008483168102919091179283905560408051848416815291909304909116602082015281517f1ec948cac143dba0e555a87dd86ae387e2ecd4a8fee80f7dd324d5987cb3e7f8929181900390910190a15050565b600854600160a060020a03163314611b6657600080fd5b611b798b8b8b8b8b8b8b8b8b8a8c611d32565b610a57828c8c8c8c8c8a8a6121ef565b600954600160a060020a031681565b600854600160a060020a031681565b60055481565b6207e90081565b600154600160a060020a031681565b60065481565b600c5470010000000000000000000000000000000090046001608060020a031681565b600054600160a060020a03163314611c0357600080fd5b6009805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600054600160a060020a03163314611c4957600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383811691821790925560008054604051929316917f83ada3430836f9d4bd6f7bc690ffbba5199cb19b37393dd64c229930213535969190a350565b60075481565b600042600d54600e540111151515611cc457600080fd5b42600e55600b54600012611cd757611d2f565b50600b54600a54811115611ce757fe5b6000600b819055600a80548390039055600954604051600160a060020a039091169183156108fc02918491818181858888f19350505050158015610afb573d6000803e3d6000fd5b50565b306000600160a060020a0385168214611d4a57600080fd5b611d5b8d8d8d8d8d8d8d8d8d61289b565b9050611852818585612c03565b600160a060020a03808216600090815260106020908152604080832054808452600f835281842060035483517f73ad468a000000000000000000000000000000000000000000000000000000008152935192969195949116926373ad468a926004808301939282900301818787803b158015611de357600080fd5b505af1158015611df7573d6000803e3d6000fd5b505050506040513d6020811015611e0d57600080fd5b50519050828514611e1d57600080fd5b600063ffffffff8d1611611e3057600080fd5b6040805160208082018990528251808303820181529183019283905281518a93918291908401908083835b60208310611e7a5780518252601f199092019160209182019101611e5b565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902060001916141515611eb757600080fd5b815461010090046001608060020a03166000038812801590611ed95750808813155b1515611ee457600080fd5b600354604080517f09eecdd700000000000000000000000000000000000000000000000000000000815260ff8e16600482015261ffff8d166024820152604481018c90529051600160a060020a03909216916309eecdd7916064808201926020929091908290030181600087803b158015611f5e57600080fd5b505af1158015611f72573d6000803e3d6000fd5b505050506040513d6020811015611f8857600080fd5b50511515611f9557600080fd5b815460006101009091046001608060020a031689018a90031215611fb857600080fd5b6003825460ff166003811115611fca57fe5b148015611fe75750815463ffffffff8d8116609060020a90920416145b156120035760038201869055611ffe828486612c9a565b612133565b6001825460ff16600381111561201557fe5b148061204b57506003825460ff16600381111561202e57fe5b14801561204b5750815463ffffffff808e16609060020a90920416105b15610242578154600290839060ff191660018302179055504282600501819055508b8260000160126101000a81548163ffffffff021916908363ffffffff1602179055508a8260000160116101000a81548160ff021916908360ff160217905550898260000160166101000a81548161ffff021916908361ffff1602179055508882600101819055508782600201819055508582600301816000191690555060006001028260040181600019169055508233600160a060020a03167f15df88512f2c79e9bb3062ae86120f5df5a70ffd25fde294717671ad2932d27860405160405180910390a35b505050505050505050505050565b855460ff1916865560065460001061215557fe5b60068054600019019055855461217b90849061010090046001608060020a031683612dc4565b8483600160a060020a03167f59ba0efd7d5a5d7e109fb346b50365a8d68661fc7c2c311cd29750707e1b8de5868486604051808463ffffffff1663ffffffff1681526020018381526020018260028111156121d257fe5b60ff168152602001935050505060405180910390a3505050505050565b600160a060020a03808916600090815260106020908152604080832054808452600f835281842060035483517f73ad468a0000000000000000000000000000000000000000000000000000000081529351929691953095909491909216926373ad468a9260048084019391929182900301818787803b15801561227157600080fd5b505af1158015612285573d6000803e3d6000fd5b505050506040513d602081101561229b57600080fd5b505190508584146122ab57600080fd5b600063ffffffff8c16116122be57600080fd5b825461010090046001608060020a031660000387128015906122e05750808713155b15156122eb57600080fd5b60ff8a161580156122fe575061ffff8916155b8015612308575087155b151561231357600080fd5b6001835460ff16600381111561232557fe5b1461232f57600080fd5b600160a060020a038581169083161461234457fe5b61213383858d8f60008c612141565b604080516c0100000000000000000000000030818102602080850191909152600160a060020a038a169092026034840152604883018890526068830187905260888084018790528451808503909101815260a8909301938490528251909360009392909182918401908083835b602083106123df5780518252601f1990920191602091820191016123c0565b5181516020939093036101000a600019018019909116921691909117905260405192018290039091206008549094506124279350849250869150600160a060020a0316612c03565b50505050505050565b600160a060020a03808216600090815260106020908152604080832054808452600f835281842060035483517f73ad468a000000000000000000000000000000000000000000000000000000008152935192969195949116926373ad468a926004808301939282900301818787803b1580156124ab57600080fd5b505af11580156124bf573d6000803e3d6000fd5b505050506040513d60208110156124d557600080fd5b505190508285146124e557600080fd5b600063ffffffff8f16116124f857600080fd5b6040805160208082018a90528251808303820181529183019283905281518c93918291908401908083835b602083106125425780518252601f199092019160209182019101612523565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206000191614151561257f57600080fd5b6040805160208082018990528251808303820181529183019283905281518b93918291908401908083835b602083106125c95780518252601f1990920191602091820191016125aa565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206000191614151561260657600080fd5b815461010090046001608060020a03166000038a128015906126285750808a13155b151561263357600080fd5b600360009054906101000a9004600160a060020a0316600160a060020a03166309eecdd78e8e8e6040518463ffffffff1660e060020a028152600401808460ff1660ff1681526020018361ffff1681526020018281526020019350505050602060405180830381600087803b1580156126ab57600080fd5b505af11580156126bf573d6000803e3d6000fd5b505050506040513d60208110156126d557600080fd5b505115156126e257600080fd5b815460006101009091046001608060020a03168b018c9003121561270557600080fd5b6002825460ff16600381111561271757fe5b1480156127345750815463ffffffff8f8116609060020a90920416145b15612750576004820187905561274b828486612c9a565b61288b565b6001825460ff16600381111561276257fe5b14806127a757506002825460ff16600381111561277b57fe5b1480156127a757508d63ffffffff168260000160129054906101000a900463ffffffff1663ffffffff16105b15610242578154600390839060ff191660018302179055504282600501819055508d8260000160126101000a81548163ffffffff021916908363ffffffff1602179055508c8260000160116101000a81548160ff021916908360ff1602179055508b8260000160166101000a81548161ffff021916908361ffff1602179055508a826001018190555089826002018190555086826004018160001916905550858260030181600019169055508284600160a060020a03167fdbbc392d5391708a9def7f560f8cbdef92e1bb37e5104831e78feda1488b7ab060405160405180910390a35b5050505050505050505050505050565b6040805160e060020a63ffffffff8c16026020808301919091527f010000000000000000000000000000000000000000000000000000000000000060ff8c160260248301527e0100000000000000000000000000000000000000000000000000000000000061ffff8b160260258301526027820189905260478201889052606782018790526087820186905260a782018590526c01000000000000000000000000600160a060020a0385160260c7830152825160bb81840301815260db909201928390528151600093849392909182918401908083835b602083106129915780518252601f199092019160209182019101612972565b51815160209384036101000a6000190180199092169116179052604080519290940182900382207f75696e74333220526f756e642049640000000000000000000000000000000000838301527f75696e74382047616d6520547970650000000000000000000000000000000000602f8401527f75696e743136204e756d62657200000000000000000000000000000000000000603e8401527f75696e742056616c756520285765692900000000000000000000000000000000604b8401527f696e742043757272656e742042616c616e636520285765692900000000000000605b8401527f627974657333322053657276657220486173680000000000000000000000000060748401527f6279746573333220506c6179657220486173680000000000000000000000000060878401527f75696e742047616d652049640000000000000000000000000000000000000000609a8401527f6164647265737320436f6e74726163742041646472657373000000000000000060a68401528451808403609e01815260be9093019485905282519097509195509293508392850191508083835b60208310612b545780518252601f199092019160209182019101612b35565b51815160209384036101000a6000190180199092169116179052604080519290940182900382208282015281840187905283518083038501815260609092019384905281519195509293508392850191508083835b60208310612bc85780518252601f199092019160209182019101612ba9565b5181516020939093036101000a600019018019909116921691909117905260405192018290039091209e9d5050505050505050505050505050565b600080600080612c1286612ede565b60408051600080825260208083018085528e905260ff8516838501526060830187905260808301869052925195995093975091955060019360a0808401949293601f19830193908390039091019190865af1158015612c75573d6000803e3d6000fd5b5050604051601f190151915050600160a060020a038082169086161461242757600080fd5b6003805484546001860154600287015460048089015495890154604080517f2a0763ce00000000000000000000000000000000000000000000000000000000815271010000000000000000000000000000000000870460ff169381019390935260b060020a860461ffff166024840152604483019490945260648201929092526101009093046001608060020a0316608484015260a483019490945260c48201939093529151600092600160a060020a0390921691632a0763ce9160e480830192602092919082900301818787803b158015612d7557600080fd5b505af1158015612d89573d6000803e3d6000fd5b505050506040513d6020811015612d9f57600080fd5b505184549091506114ca9085908590609060020a900463ffffffff1685600086612141565b600080600360009054906101000a9004600160a060020a0316600160a060020a03166373ad468a6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015612e1a57600080fd5b505af1158015612e2e573d6000803e3d6000fd5b505050506040513d6020811015612e4457600080fd5b5051831315612e4f57fe5b60006001608060020a03851684011215612e6557fe5b82846001608060020a0316019150600083138015612e84575082600a54125b15612e8f57600a5491505b50600b80548390039055600a548290036000811215612eaa57fe5b600a819055600160a060020a038516600090815260116020526040812080548401908190551115610f8557610f8585612f1c565b600080600083516041141515612ef357600080fd5b50505060208101516040820151604183015160ff166002811015612f1557601b015b9193909250565b600160a060020a038116600090815260116020526040812054908111612f3e57fe5b600160a060020a0382166000818152601160205260408082208290555183156108fc0291849190818181858888f115159350610afb9250505057600160a060020a03919091166000908152601160205260409020555600a165627a7a72305820d56869ae758c338ca0ceef3b34a886b6a3785fc35b99840ddeaaf9000168d45f0029000000000000000000000000cef260a5fed7a896bbe07b933b3a5c17aec094d8000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000006f05b59d3b20000000000000000000000000000ddde2d9a455a038ea1f54ba9553dd093c75cf29900000000000000000000000071be1ace87248f3950bdfc4c89b4b3eed059f6f30000000000000000000000000000000000000000000000000000000000000100

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

000000000000000000000000cef260a5fed7a896bbe07b933b3a5c17aec094d8000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000006f05b59d3b20000000000000000000000000000ddde2d9a455a038ea1f54ba9553dd093c75cf29900000000000000000000000071be1ace87248f3950bdfc4c89b4b3eed059f6f30000000000000000000000000000000000000000000000000000000000000100

-----Decoded View---------------
Arg [0] : _serverAddress (address): 0xCef260a5Fed7A896BBE07b933B3A5c17aEC094D8
Arg [1] : _minStake (uint128): 10000000000000000
Arg [2] : _maxStake (uint128): 500000000000000000
Arg [3] : _conflictResAddress (address): 0xDDdE2D9A455a038Ea1f54Ba9553dD093c75cf299
Arg [4] : _houseAddress (address): 0x71BE1aCe87248F3950BdFc4c89b4B3EED059f6f3
Arg [5] : _gameIdCntr (uint256): 256

-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 000000000000000000000000cef260a5fed7a896bbe07b933b3a5c17aec094d8
Arg [1] : 000000000000000000000000000000000000000000000000002386f26fc10000
Arg [2] : 00000000000000000000000000000000000000000000000006f05b59d3b20000
Arg [3] : 000000000000000000000000ddde2d9a455a038ea1f54ba9553dd093c75cf299
Arg [4] : 00000000000000000000000071be1ace87248f3950bdfc4c89b4b3eed059f6f3
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000100


Swarm Source

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