ETH Price: $2,349.74 (+1.28%)

Contract

0xB64E6BEf349A0D3E8571aC80B5ec522B417FaeB6
 

Overview

ETH Balance

0.02725 ETH

Eth Value

$64.03 (@ $2,349.74/ETH)

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Withdraw Balance67642162018-11-24 13:39:502116 days ago1543066790IN
0xB64E6BEf...B417FaeB6
0 ETH0.000187276
Withdraw Auction...67642012018-11-24 13:37:062116 days ago1543066626IN
0xB64E6BEf...B417FaeB6
0 ETH0.000137053
Create Puppy Sal...65642382018-10-22 19:29:002149 days ago1540236540IN
0xB64E6BEf...B417FaeB6
0 ETH0.000375783
Create Puppy Sal...63125402018-09-11 14:41:122190 days ago1536676872IN
0xB64E6BEf...B417FaeB6
0 ETH0.000560534
Create Puppy Sal...62228492018-08-27 12:22:412205 days ago1535372561IN
0xB64E6BEf...B417FaeB6
0 ETH0.000280392
Create Puppy Sir...60798202018-08-03 8:41:522230 days ago1533285712IN
0xB64E6BEf...B417FaeB6
0 ETH0.000427913
Create Puppy Sir...60798072018-08-03 8:38:302230 days ago1533285510IN
0xB64E6BEf...B417FaeB6
0 ETH0.000598814.2
Breed With Auto60636372018-07-31 14:40:222232 days ago1533048022IN
0xB64E6BEf...B417FaeB6
0.008 ETH0.000214662
Create Puppy Sal...58750262018-06-29 13:27:082264 days ago1530278828IN
0xB64E6BEf...B417FaeB6
0 ETH0.000700675
Create Puppy Sal...58750212018-06-29 13:25:352264 days ago1530278735IN
0xB64E6BEf...B417FaeB6
0 ETH0.000560534
Create Puppy Sal...58676542018-06-28 6:44:152266 days ago1530168255IN
0xB64E6BEf...B417FaeB6
0 ETH0.00084086
Create Puppy Sal...58638952018-06-27 15:06:162266 days ago1530111976IN
0xB64E6BEf...B417FaeB6
0 ETH0.000840426
Create Puppy Sal...58353492018-06-22 17:11:182271 days ago1529687478IN
0xB64E6BEf...B417FaeB6
0 ETH0.000250142
Create Puppy Sal...58353472018-06-22 17:10:582271 days ago1529687458IN
0xB64E6BEf...B417FaeB6
0 ETH0.000280142
Create Puppy Sal...58353412018-06-22 17:07:392271 days ago1529687259IN
0xB64E6BEf...B417FaeB6
0 ETH0.000280142
Create Puppy Sal...58243322018-06-20 19:57:092273 days ago1529524629IN
0xB64E6BEf...B417FaeB6
0 ETH0.000125071
Create Puppy Sal...58242622018-06-20 19:40:082273 days ago1529523608IN
0xB64E6BEf...B417FaeB6
0 ETH0.000125131
Create Puppy Sal...57807892018-06-13 9:00:582281 days ago1528880458IN
0xB64E6BEf...B417FaeB6
0 ETH0.000560534
Create Puppy Sal...57741202018-06-12 4:55:582282 days ago1528779358IN
0xB64E6BEf...B417FaeB6
0 ETH0.000140131
Create Puppy Sal...57687112018-06-11 6:02:182283 days ago1528696938IN
0xB64E6BEf...B417FaeB6
0 ETH0.000841186
Create Puppy Sal...57687062018-06-11 6:01:312283 days ago1528696891IN
0xB64E6BEf...B417FaeB6
0 ETH0.000841186
Create Puppy Sal...57435472018-06-06 18:53:362287 days ago1528311216IN
0xB64E6BEf...B417FaeB6
0 ETH0.007013150
Create Puppy Sal...57435352018-06-06 18:49:502287 days ago1528310990IN
0xB64E6BEf...B417FaeB6
0 ETH0.007009950
Create Puppy Sal...57383832018-06-05 21:05:172288 days ago1528232717IN
0xB64E6BEf...B417FaeB6
0 ETH0.000700675
Create Puppy Sal...57276702018-06-03 23:18:222290 days ago1528067902IN
0xB64E6BEf...B417FaeB6
0 ETH0.000420213
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
130307792021-08-15 16:13:361121 days ago1629044016
0xB64E6BEf...B417FaeB6
0.009625 ETH
130303582021-08-15 14:42:221121 days ago1629038542
0xB64E6BEf...B417FaeB6
0.009625 ETH
67642162018-11-24 13:39:502116 days ago1543066790
0xB64E6BEf...B417FaeB6
1.05591888 ETH
67642012018-11-24 13:37:062116 days ago1543066626
0xB64E6BEf...B417FaeB6
0.03418855 ETH
67642012018-11-24 13:37:062116 days ago1543066626
0xB64E6BEf...B417FaeB6
0.60794688 ETH
60756782018-08-02 15:51:512230 days ago1533225111
0xB64E6BEf...B417FaeB6
0.008 ETH
57147172018-06-01 16:15:562292 days ago1527869756
0xB64E6BEf...B417FaeB6
0.008 ETH
57146092018-06-01 15:46:012292 days ago1527867961
0xB64E6BEf...B417FaeB6
0.008 ETH
56986522018-05-29 19:32:002295 days ago1527622320
0xB64E6BEf...B417FaeB6
0.008 ETH
56874332018-05-27 20:07:532297 days ago1527451673
0xB64E6BEf...B417FaeB6
0.008 ETH
56871632018-05-27 19:03:572297 days ago1527447837
0xB64E6BEf...B417FaeB6
0.008 ETH
56770022018-05-26 0:00:152299 days ago1527292815
0xB64E6BEf...B417FaeB6
0.008 ETH
56769682018-05-25 23:51:282299 days ago1527292288
0xB64E6BEf...B417FaeB6
0.008 ETH
56769012018-05-25 23:31:232299 days ago1527291083
0xB64E6BEf...B417FaeB6
0.008 ETH
56527512018-05-21 16:18:532303 days ago1526919533
0xB64E6BEf...B417FaeB6
0.008 ETH
56475522018-05-20 18:21:312304 days ago1526840491
0xB64E6BEf...B417FaeB6
0.009625 ETH
56475462018-05-20 18:19:322304 days ago1526840372
0xB64E6BEf...B417FaeB6
0.009625 ETH
56475172018-05-20 18:13:062304 days ago1526839986
0xB64E6BEf...B417FaeB6
0.009625 ETH
56430382018-05-19 23:15:042305 days ago1526771704
0xB64E6BEf...B417FaeB6
0.008 ETH
56332062018-05-18 5:16:222307 days ago1526620582
0xB64E6BEf...B417FaeB6
0.009625 ETH
56151022018-05-15 0:52:102310 days ago1526345530
0xB64E6BEf...B417FaeB6
0.009625 ETH
56095042018-05-14 0:59:122311 days ago1526259552
0xB64E6BEf...B417FaeB6
0.009625 ETH
56073092018-05-13 15:59:492311 days ago1526227189
0xB64E6BEf...B417FaeB6
0.0179802 ETH
56070312018-05-13 14:41:322311 days ago1526222492
0xB64E6BEf...B417FaeB6
0.02030674 ETH
55839032018-05-09 13:58:002315 days ago1525874280
0xB64E6BEf...B417FaeB6
0.008 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PuppiesCore

Compiler Version
v0.4.22-nightly.2018.3.16+commit.2b2527f3

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2018-03-22
*/

// CryptoPuppies Source code
// Copied from: https://etherscan.io/address/0x06012c8cf97bead5deae237070f9587f8e7a266d#code

pragma solidity ^0.4.11;

/**
 * @title Ownable
 * @dev The Ownable contract has an owner address, and provides basic authorization control
 * functions, this simplifies the implementation of "user permissions".
 */
contract Ownable {
  address public owner;


  /**
   * @dev The Ownable constructor sets the original `owner` of the contract to the sender
   * account.
   */
  function Ownable() {
    owner = msg.sender;
  }


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


  /**
   * @dev Allows the current owner to transfer control of the contract to a newOwner.
   * @param newOwner The address to transfer ownership to.
   */
  function transferOwnership(address newOwner) onlyOwner {
    if (newOwner != address(0)) {
      owner = newOwner;
    }
  }

}



/// @title Interface for contracts conforming to ERC-721: Non-Fungible Tokens
/// @author Dieter Shirley <[email protected]> (https://github.com/dete)
contract ERC721 {
    // Required methods
    function totalSupply() public view returns (uint256 total);
    function balanceOf(address _owner) public view returns (uint256 balance);
    function ownerOf(uint256 _tokenId) external view returns (address owner);
    function approve(address _to, uint256 _tokenId) external;
    function transfer(address _to, uint256 _tokenId) external;
    function transferFrom(address _from, address _to, uint256 _tokenId) external;

    // Events
    event Transfer(address from, address to, uint256 tokenId);
    event Approval(address owner, address approved, uint256 tokenId);

    // Optional
    // function name() public view returns (string name);
    // function symbol() public view returns (string symbol);
    // function tokensOfOwner(address _owner) external view returns (uint256[] tokenIds);
    // function tokenMetadata(uint256 _tokenId, string _preferredTransport) public view returns (string infoUrl);

    // ERC-165 Compatibility (https://github.com/ethereum/EIPs/issues/165)
    function supportsInterface(bytes4 _interfaceID) external view returns (bool);
}


// // Auction wrapper functions


// Auction wrapper functions


/// @title SEKRETOOOO
contract GeneScience {
    /// @dev simply a boolean to indicate this is the contract we expect to be
    function isGeneScience() public pure returns (bool);

    /// @dev given genes of puppies 1 & 2, return a genetic combination - may have a random factor
    /// @param genes1 genes of mom
    /// @param genes2 genes of sire
    /// @return the genes that are supposed to be passed down the child
    function mixGenes(uint256 genes1, uint256 genes2, uint256 targetBlock) public returns (uint256);
}

/// @title Puppy sports contract
contract PuppySports {
    /// @dev simply a boolean to indipuppye this is the contract we expect to be
    function isPuppySports() public pure returns (bool);

    /// @dev contract that provides gaming functionality
    /// @param puppyId - id of the puppy
    /// @param gameId - id of the game
    /// @param targetBlock - proof of randomness
    /// @return true if puppy won the game, false otherwise
    function playGame(uint256 puppyId, uint256 gameId, uint256 targetBlock) public returns (bool);
}


/// @title A facet of PuppiesCore that manages special access privileges.
/// @author SmartFoxLabs
/// @dev See the PuppiesCore contract documentation to understand how the various contract facets are arranged.
contract PuppyAccessControl {
    // This facet controls access control for CryptoPuppies. There are four roles managed here:
    //
    //     - The CEO: The CEO can reassign other roles and change the addresses of our dependent smart
    //         contracts. It is also the only role that can unpause the smart contract. It is initially
    //         set to the address that created the smart contract in the PuppiesCore constructor.
    //
    //     - The CFO: The CFO can withdraw funds from PuppiesCore and its auction contracts.
    //
    //     - The COO: The COO can release gen0 puppies to auction, and mint promo puppys.
    //
    // It should be noted that these roles are distinct without overlap in their access abilities, the
    // abilities listed for each role above are exhaustive. In particular, while the CEO can assign any
    // address to any role, the CEO address itself doesn't have the ability to act in those roles. This
    // restriction is intentional so that we aren't tempted to use the CEO address frequently out of
    // convenience. The less we use an address, the less likely it is that we somehow compromise the
    // account.

    /// @dev Emited when contract is upgraded - See README.md for updgrade plan
    event ContractUpgrade(address newContract);

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

    // @dev Keeps track whether the contract is paused. When that is true, most actions are blocked
    bool public paused = false;

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

    /// @dev Access modifier for CFO-only functionality
    modifier onlyCFO() {
        require(msg.sender == cfoAddress);
        _;
    }

    /// @dev Access modifier for COO-only functionality
    modifier onlyCOO() {
        require(msg.sender == cooAddress);
        _;
    }

    modifier onlyCLevel() {
        require(msg.sender == cooAddress || msg.sender == ceoAddress || msg.sender == cfoAddress);
        _;
    }

    /// @dev Assigns a new address to act as the CEO. Only available to the current CEO.
    /// @param _newCEO The address of the new CEO
    function setCEO(address _newCEO) external onlyCEO {
        require(_newCEO != address(0));

        ceoAddress = _newCEO;
    }

    /// @dev Assigns a new address to act as the CFO. Only available to the current CEO.
    /// @param _newCFO The address of the new CFO
    function setCFO(address _newCFO) external onlyCEO {
        require(_newCFO != address(0));

        cfoAddress = _newCFO;
    }

    /// @dev Assigns a new address to act as the COO. Only available to the current CEO.
    /// @param _newCOO The address of the new COO
    function setCOO(address _newCOO) external onlyCEO {
        require(_newCOO != address(0));

        cooAddress = _newCOO;
    }

    /*** Pausable functionality adapted from OpenZeppelin ***/

    /// @dev Modifier to allow actions only when the contract IS NOT paused
    modifier whenNotPaused() {
        require(!paused);
        _;
    }

    /// @dev Modifier to allow actions only when the contract IS paused
    modifier whenPaused {
        require(paused);
        _;
    }

    /// @dev Called by any "C-level" role to pause the contract. Used only when
    ///  a bug or exploit is detected and we need to limit damage.
    function pause() external onlyCLevel whenNotPaused {
        paused = true;
    }

    /// @dev Unpauses the smart contract. Can only be called by the CEO, since
    ///  one reason we may pause the contract is when CFO or COO accounts are
    ///  compromised.
    /// @notice This is public rather than external so it can be called by
    ///  derived contracts.
    function unpause() public onlyCEO whenPaused {
        // can't unpause if contract was upgraded
        paused = false;
    }
}

/// @title Base contract for CryptoPuppies. Holds all common structs, events and base variables.
/// @author Axiom Zen (https://www.axiomzen.co)
/// @dev See the PuppiesCore contract documentation to understand how the various contract facets are arranged.
contract PuppyBase is PuppyAccessControl {
    /*** EVENTS ***/

    /// @dev The Birth event is fired whenever a new puppy comes into existence. This obviously
    ///  includes any time a puppy is created through the giveBirth method, but it is also called
    ///  when a new gen0 puppy is created.
    event Birth(address owner, uint256 puppyId, uint256 matronId, uint256 sireId, uint256 genes);

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

    /*** DATA TYPES ***/

    /// @dev The main Puppy struct. Every puppy in CryptoPuppies is represented by a copy
    ///  of this structure, so great care was taken to ensure that it fits neatly into
    ///  exactly two 256-bit words. Note that the order of the members in this structure
    ///  is important because of the byte-packing rules used by Ethereum.
    ///  Ref: http://solidity.readthedocs.io/en/develop/miscellaneous.html
    struct Puppy {
        // The Puppy's genetic code is packed into these 256-bits, the format is
        // sooper-sekret! A puppy's genes never change.
        uint256 genes;

        // The timestamp from the block when this puppy came into existence.
        uint64 birthTime;

        // The minimum timestamp after which this puppy can engage in breeding
        // activities again. This same timestamp is used for the pregnancy
        // timer (for matrons) as well as the siring cooldown.
        uint64 cooldownEndBlock;

        // The ID of the parents of this Puppy, set to 0 for gen0 puppys.
        // Note that using 32-bit unsigned integers limits us to a "mere"
        // 4 billion puppys. This number might seem small until you realize
        // that Ethereum currently has a limit of about 500 million
        // transactions per year! So, this definitely won't be a problem
        // for several years (even as Ethereum learns to scale).
        uint32 matronId;
        uint32 sireId;

        // Set to the ID of the sire puppy for matrons that are pregnant,
        // zero otherwise. A non-zero value here is how we know a puppy
        // is pregnant. Used to retrieve the genetic material for the new
        // puppy when the birth transpires.
        uint32 siringWithId;

        // Set to the index in the cooldown array (see below) that represents
        // the current cooldown duration for this Puppy. This starts at zero
        // for gen0 puppys, and is initialized to floor(generation/2) for others.
        // Incremented by one for each successful breeding action, regardless
        // of whether this puppy is acting as matron or sire.
        uint16 cooldownIndex;

        // The "generation number" of this puppy. puppys minted by the CK contract
        // for sale are called "gen0" and have a generation number of 0. The
        // generation number of all other puppys is the larger of the two generation
        // numbers of their parents, plus one.
        // (i.e. max(matron.generation, sire.generation) + 1)
        uint16 generation;

        uint16 childNumber;

        uint16 strength;

        uint16 agility;

        uint16 intelligence;

        uint16 speed;
    }

    /*** CONSTANTS ***/

    /// @dev A lookup table indipuppying the cooldown duration after any successful
    ///  breeding action, called "pregnancy time" for matrons and "siring cooldown"
    ///  for sires. Designed such that the cooldown roughly doubles each time a puppy
    ///  is bred, encouraging owners not to just keep breeding the same puppy over
    ///  and over again. Caps out at one week (a puppy can breed an unbounded number
    ///  of times, and the maximum cooldown is always seven days).
    uint32[14] public cooldowns = [
        uint32(1 minutes),
        uint32(2 minutes),
        uint32(5 minutes),
        uint32(10 minutes),
        uint32(30 minutes),
        uint32(1 hours),
        uint32(2 hours),
        uint32(4 hours),
        uint32(8 hours),
        uint32(16 hours),
        uint32(1 days),
        uint32(2 days),
        uint32(4 days),
        uint32(7 days)
    ];

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

    /*** STORAGE ***/

    /// @dev An array containing the Puppy struct for all puppies in existence. The ID
    ///  of each puppy is actually an index into this array. Note that ID 0 is a negapuppy,
    ///  the unPuppy, the mythical beast that is the parent of all gen0 puppys. A bizarre
    ///  creature that is both matron and sire... to itself! Has an invalid genetic code.
    ///  In other words, puppy ID 0 is invalid... ;-)
    Puppy[] puppies;

    /// @dev A mapping from puppy IDs to the address that owns them. All puppys have
    ///  some valid owner address, even gen0 puppys are created with a non-zero owner.
    mapping (uint256 => address) public PuppyIndexToOwner;

    // @dev A mapping from owner address to count of tokens that address owns.
    //  Used internally inside balanceOf() to resolve ownership count.
    mapping (address => uint256) ownershipTokenCount;

    /// @dev A mapping from puppyIds to an address that has been approved to call
    ///  transferFrom(). Each Puppy can only have one approved address for transfer
    ///  at any time. A zero value means no approval is outstanding.
    mapping (uint256 => address) public PuppyIndexToApproved;

    /// @dev A mapping from puppyIds to an address that has been approved to use
    ///  this Puppy for siring via breedWith(). Each Puppy can only have one approved
    ///  address for siring at any time. A zero value means no approval is outstanding.
    mapping (uint256 => address) public sireAllowedToAddress;

    /// @dev The address of the ClockAuction contract that handles sales of puppies. This
    ///  same contract handles both peer-to-peer sales as well as the gen0 sales which are
    ///  initiated every 15 minutes.
    SaleClockAuction public saleAuction;

    /// @dev The address of a custom ClockAuction subclassed contract that handles siring
    ///  auctions. Needs to be separate from saleAuction because the actions taken on success
    ///  after a sales and siring auction are quite different.
    SiringClockAuction public siringAuction;

    /// @dev Assigns ownership of a specific Puppy to an address.
    function _transfer(address _from, address _to, uint256 _tokenId) internal {
        // Since the number of puppys is capped to 2^32 we can't overflow this
        ownershipTokenCount[_to]++;
        // transfer ownership
        PuppyIndexToOwner[_tokenId] = _to;
        // When creating new puppys _from is 0x0, but we can't account that address.
        if (_from != address(0)) {
            ownershipTokenCount[_from]--;
            // once the puppy is transferred also clear sire allowances
            delete sireAllowedToAddress[_tokenId];
            // clear any previously approved ownership exchange
            delete PuppyIndexToApproved[_tokenId];
        }
        // Emit the transfer event.
        Transfer(_from, _to, _tokenId);
    }

    /// @dev An internal method that creates a new Puppy and stores it. This
    ///  method doesn't do any checking and should only be called when the
    ///  input data is known to be valid. Will generate both a Birth event
    ///  and a Transfer event.
    /// @param _matronId The Puppy ID of the matron of this puppy (zero for gen0)
    /// @param _sireId The Puppy ID of the sire of this puppy (zero for gen0)
    /// @param _generation The generation number of this puppy, must be computed by caller.
    /// @param _genes The Puppy's genetic code.
    /// @param _owner The inital owner of this puppy, must be non-zero (except for the unPuppy, ID 0)
    function _createPuppy(
        uint256 _matronId,
        uint256 _sireId,
        uint256 _generation,
        uint256 _genes,
        address _owner,
        uint16 _strength,
        uint16 _agility,
        uint16 _intelligence,
        uint16 _speed
    )
        internal
        returns (uint)
    {
        // These requires are not strictly necessary, our calling code should make
        // sure that these conditions are never broken. However! _createPuppy() is already
        // an expensive call (for storage), and it doesn't hurt to be especially careful
        // to ensure our data structures are always valid.
        require(_matronId == uint256(uint32(_matronId)));
        require(_sireId == uint256(uint32(_sireId)));
        require(_generation == uint256(uint16(_generation)));

        // New Puppy starts with the same cooldown as parent gen/2
        uint16 cooldownIndex = uint16(_generation / 2);
        if (cooldownIndex > 13) {
            cooldownIndex = 13;
        }

        Puppy memory _puppy = Puppy({
            genes: _genes,
            birthTime: uint64(now),
            cooldownEndBlock: 0,
            matronId: uint32(_matronId),
            sireId: uint32(_sireId),
            siringWithId: 0,
            cooldownIndex: cooldownIndex,
            generation: uint16(_generation),
            childNumber: 0,
            strength: _strength,
            agility: _agility,
            intelligence: _intelligence,
            speed: _speed
        });

        uint256 newpuppyId = puppies.push(_puppy) - 1;

        // It's probably never going to happen, 4 billion puppys is A LOT, but
        // let's just be 100% sure we never let this happen.
        require(newpuppyId == uint256(uint32(newpuppyId)));

        // emit the birth event
        Birth(
            _owner,
            newpuppyId,
            uint256(_puppy.matronId),
            uint256(_puppy.sireId),
            _puppy.genes
        );

        // This will assign ownership, and also emit the Transfer event as
        // per ERC721 draft
        _transfer(0, _owner, newpuppyId);

        return newpuppyId;
    }

    // Any C-level can fix how many seconds per blocks are currently observed.
    function setSecondsPerBlock(uint256 secs) external onlyCLevel {
        require(secs < cooldowns[0]);
        secondsPerBlock = secs;
    }
}





/// @title The external contract that is responsible for generating metadata for the puppies,
///  it has one function that will return the data as bytes.
contract ERC721Metadata {
    /// @dev Given a token Id, returns a byte array that is supposed to be converted into string.
    function getMetadata(uint256 _tokenId, string) public view returns (bytes32[4] buffer, uint256 count) {
        if (_tokenId == 1) {
            buffer[0] = "Hello World! :D";
            count = 15;
        } else if (_tokenId == 2) {
            buffer[0] = "I would definitely choose a medi";
            buffer[1] = "um length string.";
            count = 49;
        } else if (_tokenId == 3) {
            buffer[0] = "Lorem ipsum dolor sit amet, mi e";
            buffer[1] = "st accumsan dapibus augue lorem,";
            buffer[2] = " tristique vestibulum id, libero";
            buffer[3] = " suscipit varius sapien aliquam.";
            count = 128;
        }
    }
}


/// @title The facet of the CryptoPuppies core contract that manages ownership, ERC-721 (draft) compliant.
/// @author Axiom Zen (https://www.axiomzen.co)
/// @dev Ref: https://github.com/ethereum/EIPs/issues/721
///  See the PuppiesCore contract documentation to understand how the various contract facets are arranged.
contract PuppyOwnership is PuppyBase, ERC721 {

    /// @notice Name and symbol of the non fungible token, as defined in ERC721.
    string public constant name = "CryptoPuppies";
    string public constant symbol = "CP";

    // The contract that will return Puppy metadata
    ERC721Metadata public erc721Metadata;

    bytes4 constant InterfaceSignature_ERC165 =
        bytes4(keccak256("supportsInterface(bytes4)"));

    bytes4 constant InterfaceSignature_ERC721 =
        bytes4(keccak256("name()")) ^
        bytes4(keccak256("symbol()")) ^
        bytes4(keccak256("totalSupply()")) ^
        bytes4(keccak256("balanceOf(address)")) ^
        bytes4(keccak256("ownerOf(uint256)")) ^
        bytes4(keccak256("approve(address,uint256)")) ^
        bytes4(keccak256("transfer(address,uint256)")) ^
        bytes4(keccak256("transferFrom(address,address,uint256)")) ^
        bytes4(keccak256("tokensOfOwner(address)")) ^
        bytes4(keccak256("tokenMetadata(uint256,string)"));

    /// @notice Introspection interface as per ERC-165 (https://github.com/ethereum/EIPs/issues/165).
    ///  Returns true for any standardized interfaces implemented by this contract. We implement
    ///  ERC-165 (obviously!) and ERC-721.
    function supportsInterface(bytes4 _interfaceID) external view returns (bool) {
        // DEBUG ONLY
        //require((InterfaceSignature_ERC165 == 0x01ffc9a7) && (InterfaceSignature_ERC721 == 0x9a20483d));

        return ((_interfaceID == InterfaceSignature_ERC165) || (_interfaceID == InterfaceSignature_ERC721));
    }

    /// @dev Set the address of the sibling contract that tracks metadata.
    ///  CEO only.
    function setMetadataAddress(address _contractAddress) public onlyCEO {
        erc721Metadata = ERC721Metadata(_contractAddress);
    }

    // Internal utility functions: These functions all assume that their input arguments
    // are valid. We leave it to public methods to sanitize their inputs and follow
    // the required logic.

    /// @dev Checks if a given address is the current owner of a particular Puppy.
    /// @param _claimant the address we are validating against.
    /// @param _tokenId puppy id, only valid when > 0
    function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) {
        return PuppyIndexToOwner[_tokenId] == _claimant;
    }

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

    /// @dev Marks an address as being approved for transferFrom(), overwriting any previous
    ///  approval. Setting _approved to address(0) clears all transfer approval.
    ///  NOTE: _approve() does NOT send the Approval event. This is intentional because
    ///  _approve() and transferFrom() are used together for putting puppies on auction, and
    ///  there is no value in spamming the log with Approval events in that case.
    function _approve(uint256 _tokenId, address _approved) internal {
        PuppyIndexToApproved[_tokenId] = _approved;
    }

    /// @notice Returns the number of puppies owned by a specific address.
    /// @param _owner The owner address to check.
    /// @dev Required for ERC-721 compliance
    function balanceOf(address _owner) public view returns (uint256 count) {
        return ownershipTokenCount[_owner];
    }

    /// @notice Transfers a Puppy to another address. If transferring to a smart
    ///  contract be VERY CAREFUL to ensure that it is aware of ERC-721 (or
    ///  CryptoPuppies specifically) or your Puppy may be lost forever. Seriously.
    /// @param _to The address of the recipient, can be a user or contract.
    /// @param _tokenId The ID of the Puppy to transfer.
    /// @dev Required for ERC-721 compliance.
    function transfer(
        address _to,
        uint256 _tokenId
    )
        external
        whenNotPaused
    {
        // Safety check to prevent against an unexpected 0x0 default.
        require(_to != address(0));
        // Disallow transfers to this contract to prevent accidental misuse.
        // The contract should never own any puppies (except very briefly
        // after a gen0 puppy is created and before it goes on auction).
        require(_to != address(this));
        // Disallow transfers to the auction contracts to prevent accidental
        // misuse. Auction contracts should only take ownership of puppies
        // through the allow + transferFrom flow.
        require(_to != address(saleAuction));
        require(_to != address(siringAuction));

        // You can only send your own puppy.
        require(_owns(msg.sender, _tokenId));

        // Reassign ownership, clear pending approvals, emit Transfer event.
        _transfer(msg.sender, _to, _tokenId);
    }

    /// @notice Grant another address the right to transfer a specific Puppy via
    ///  transferFrom(). This is the preferred flow for transfering NFTs to contracts.
    /// @param _to The address to be granted transfer approval. Pass address(0) to
    ///  clear all approvals.
    /// @param _tokenId The ID of the Puppy that can be transferred if this call succeeds.
    /// @dev Required for ERC-721 compliance.
    function approve(
        address _to,
        uint256 _tokenId
    )
        external
        whenNotPaused
    {
        // Only an owner can grant transfer approval.
        require(_owns(msg.sender, _tokenId));

        // Register the approval (replacing any previous approval).
        _approve(_tokenId, _to);

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

    /// @notice Transfer a Puppy owned by another address, for which the calling address
    ///  has previously been granted transfer approval by the owner.
    /// @param _from The address that owns the Puppy to be transfered.
    /// @param _to The address that should take ownership of the Puppy. Can be any address,
    ///  including the caller.
    /// @param _tokenId The ID of the Puppy to be transferred.
    /// @dev Required for ERC-721 compliance.
    function transferFrom(
        address _from,
        address _to,
        uint256 _tokenId
    )
        external
        whenNotPaused
    {
        // Safety check to prevent against an unexpected 0x0 default.
        require(_to != address(0));
        // Disallow transfers to this contract to prevent accidental misuse.
        // The contract should never own any puppies (except very briefly
        // after a gen0 puppy is created and before it goes on auction).
        require(_to != address(this));
        // Check for approval and valid ownership
        require(_approvedFor(msg.sender, _tokenId));
        require(_owns(_from, _tokenId));

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

    /// @notice Returns the total number of puppies currently in existence.
    /// @dev Required for ERC-721 compliance.
    function totalSupply() public view returns (uint) {
        return puppies.length - 1;
    }

    /// @notice Returns the address currently assigned ownership of a given Puppy.
    /// @dev Required for ERC-721 compliance.
    function ownerOf(uint256 _tokenId)
        external
        view
        returns (address owner)
    {
        owner = PuppyIndexToOwner[_tokenId];

        require(owner != address(0));
    }

    /// @notice Returns a list of all Puppy IDs assigned to an address.
    /// @param _owner The owner whose puppies we are interested in.
    /// @dev This method MUST NEVER be called by smart contract code. First, it's fairly
    ///  expensive (it walks the entire Puppy array looking for puppys belonging to owner),
    ///  but it also returns a dynamic array, which is only supported for web3 calls, and
    ///  not contract-to-contract calls.
    function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) {
        uint256 tokenCount = balanceOf(_owner);

        if (tokenCount == 0) {
            // Return an empty array
            return new uint256[](0);
        } else {
            uint256[] memory result = new uint256[](tokenCount);
            uint256 totalpuppys = totalSupply();
            uint256 resultIndex = 0;

            // We count on the fact that all puppys have IDs starting at 1 and increasing
            // sequentially up to the totalpuppy count.
            uint256 puppyId;

            for (puppyId = 1; puppyId <= totalpuppys; puppyId++) {
                if (PuppyIndexToOwner[puppyId] == _owner) {
                    result[resultIndex] = puppyId;
                    resultIndex++;
                }
            }

            return result;
        }
    }

    /// @dev Adapted from memcpy() by @arachnid (Nick Johnson <[email protected]>)
    ///  This method is licenced under the Apache License.
    ///  Ref: https://github.com/Arachnid/solidity-stringutils/blob/2f6ca9accb48ae14c66f1437ec50ed19a0616f78/strings.sol
    function _memcpy(uint _dest, uint _src, uint _len) private view {
        // Copy word-length chunks while possible
        for(; _len >= 32; _len -= 32) {
            assembly {
                mstore(_dest, mload(_src))
            }
            _dest += 32;
            _src += 32;
        }

        // Copy remaining bytes
        uint256 mask = 256 ** (32 - _len) - 1;
        assembly {
            let srcpart := and(mload(_src), not(mask))
            let destpart := and(mload(_dest), mask)
            mstore(_dest, or(destpart, srcpart))
        }
    }

    /// @dev Adapted from toString(slice) by @arachnid (Nick Johnson <[email protected]>)
    ///  This method is licenced under the Apache License.
    ///  Ref: https://github.com/Arachnid/solidity-stringutils/blob/2f6ca9accb48ae14c66f1437ec50ed19a0616f78/strings.sol
    function _toString(bytes32[4] _rawBytes, uint256 _stringLength) private view returns (string) {
        var outputString = new string(_stringLength);
        uint256 outputPtr;
        uint256 bytesPtr;

        assembly {
            outputPtr := add(outputString, 32)
            bytesPtr := _rawBytes
        }

        _memcpy(outputPtr, bytesPtr, _stringLength);

        return outputString;
    }

    /// @notice Returns a URI pointing to a metadata package for this token conforming to
    ///  ERC-721 (https://github.com/ethereum/EIPs/issues/721)
    /// @param _tokenId The ID number of the Puppy whose metadata should be returned.
    function tokenMetadata(uint256 _tokenId, string _preferredTransport) external view returns (string infoUrl) {
        require(erc721Metadata != address(0));
        bytes32[4] memory buffer;
        uint256 count;
        (buffer, count) = erc721Metadata.getMetadata(_tokenId, _preferredTransport);

        return _toString(buffer, count);
    }
}

/// @title A facet of PuppiesCore that manages Puppy siring, gestation, and birth.
/// @author Axiom Zen (https://www.axiomzen.co)
/// @dev See the PuppiesCore contract documentation to understand how the various contract facets are arranged.
contract PuppyBreeding is PuppyOwnership {

    /// @dev The Pregnant event is fired when two puppys successfully breed and the pregnancy
    ///  timer begins for the matron.
    event Pregnant(address owner, uint256 matronId, uint256 sireId, uint256 cooldownEndBlock);

    /// @notice The minimum payment required to use breedWithAuto(). This fee goes towards
    ///  the gas cost paid by whatever calls giveBirth(), and can be dynamically updated by
    ///  the COO role as the gas price changes.
    uint256 public autoBirthFee = 8 finney;

    // Keeps track of number of pregnant puppies.
    uint256 public pregnantpuppies;

    uint256 public minChildCount = 2;

    uint256 public maxChildCount = 14;

    uint randNonce = 0;

    /// @dev The address of the sibling contract that is used to implement the sooper-sekret
    ///  genetic combination algorithm.

    GeneScience public geneScience;

    PuppySports public puppySports;

    function setMinChildCount(uint256 _minChildCount) onlyCOO whenNotPaused {
        require(_minChildCount >= 2);
        minChildCount = _minChildCount;
    }

    function setMaxChildCount(uint256 _maxChildCount) onlyCOO whenNotPaused {
        require(_maxChildCount > minChildCount);
        maxChildCount = _maxChildCount;
    }

    function setGeneScienceAddress(address _address) external onlyCEO {
        GeneScience candidateContract = GeneScience(_address);

        // NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117
        require(candidateContract.isGeneScience());

        // Set the new contract address
        geneScience = candidateContract;
    }

    function setPuppySports(address _address) external onlyCEO {
        PuppySports candidateContract = PuppySports(_address);

        // NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117
        require(candidateContract.isPuppySports());

        // Set the new contract address
        puppySports = candidateContract;
    }

    /// @dev Checks that a given puppy is able to breed. Requires that the
    ///  current cooldown is finished (for sires) and also checks that there is
    ///  no pending pregnancy.
    function _isReadyToBreed(Puppy _pup) internal view returns (bool) {
        // In addition to checking the cooldownEndBlock, we also need to check to see if
        // the puppy has a pending birth; there can be some period of time between the end
        // of the pregnacy timer and the birth event.
        uint256 numberOfAllowedChild = maxChildCount - _pup.generation * 2;
        if (numberOfAllowedChild < minChildCount) {
            numberOfAllowedChild = minChildCount;
        }

        bool isChildLimitNotReached = _pup.childNumber < numberOfAllowedChild;

        return (_pup.siringWithId == 0) && (_pup.cooldownEndBlock <= uint64(block.number)) && isChildLimitNotReached;
    }

    /// @dev Check if a sire has authorized breeding with this matron. True if both sire
    ///  and matron have the same owner, or if the sire has given siring permission to
    ///  the matron's owner (via approveSiring()).
    function _isSiringPermitted(uint256 _sireId, uint256 _matronId) internal view returns (bool) {
        address matronOwner = PuppyIndexToOwner[_matronId];
        address sireOwner = PuppyIndexToOwner[_sireId];

        // Siring is okay if they have same owner, or if the matron's owner was given
        // permission to breed with this sire.
        return (matronOwner == sireOwner || sireAllowedToAddress[_sireId] == matronOwner);
    }

    /// @dev Set the cooldownEndTime for the given Puppy, based on its current cooldownIndex.
    ///  Also increments the cooldownIndex (unless it has hit the cap).
    /// @param _puppy A reference to the Puppy in storage which needs its timer started.
    function _triggerCooldown(Puppy storage _puppy) internal {
        // Compute an estimation of the cooldown time in blocks (based on current cooldownIndex).
        _puppy.cooldownEndBlock = uint64((cooldowns[_puppy.cooldownIndex]/secondsPerBlock) + block.number);

        // Increment the breeding count, clamping it at 13, which is the length of the
        // cooldowns array. We could check the array size dynamically, but hard-coding
        // this as a constant saves gas. Yay, Solidity!
        if (_puppy.cooldownIndex < 13) {
            _puppy.cooldownIndex += 1;
        }
    }

    /// @dev Set the cooldownEndTime for the given Puppy, based on its current cooldownIndex.
    ///  Also increments the cooldownIndex (unless it has hit the cap).
    /// @param _puppy A reference to the Puppy in storage which needs its timer started.
    function _triggerChildCount(Puppy storage _puppy) internal {
        // Increment the child count
        _puppy.childNumber += 1;
    }

    /// @notice Grants approval to another user to sire with one of your puppies.
    /// @param _addr The address that will be able to sire with your Puppy. Set to
    ///  address(0) to clear all siring approvals for this Puppy.
    /// @param _sireId A Puppy that you own that _addr will now be able to sire with.
    function approveSiring(address _addr, uint256 _sireId)
        external
        whenNotPaused
    {
        require(_owns(msg.sender, _sireId));
        sireAllowedToAddress[_sireId] = _addr;
    }

    /// @dev Updates the minimum payment required for calling giveBirthAuto(). Can only
    ///  be called by the COO address. (This fee is used to offset the gas cost incurred
    ///  by the autobirth daemon).
    function setAutoBirthFee(uint256 val) external onlyCOO {
        autoBirthFee = val;
    }

    /// @dev Checks to see if a given Puppy is pregnant and (if so) if the gestation
    ///  period has passed.
    function _isReadyToGiveBirth(Puppy _matron) private view returns (bool) {
        return (_matron.siringWithId != 0) && (_matron.cooldownEndBlock <= uint64(block.number));
    }

    /// @notice Checks that a given puppy is able to breed (i.e. it is not pregnant or
    ///  in the middle of a siring cooldown).
    /// @param _puppyId reference the id of the puppy, any user can inquire about it
    function isReadyToBreed(uint256 _puppyId)
        public
        view
        returns (bool)
    {
        require(_puppyId > 0);
        Puppy storage pup = puppies[_puppyId];
        return _isReadyToBreed(pup);
    }

    /// @dev Checks whether a Puppy is currently pregnant.
    /// @param _puppyId reference the id of the puppy, any user can inquire about it
    function isPregnant(uint256 _puppyId)
        public
        view
        returns (bool)
    {
        require(_puppyId > 0);
        // A Puppy is pregnant if and only if this field is set
        return puppies[_puppyId].siringWithId != 0;
    }

    /// @dev Internal check to see if a given sire and matron are a valid mating pair. DOES NOT
    ///  check ownership permissions (that is up to the caller).
    /// @param _matron A reference to the Puppy struct of the potential matron.
    /// @param _matronId The matron's ID.
    /// @param _sire A reference to the Puppy struct of the potential sire.
    /// @param _sireId The sire's ID
    function _isValidMatingPair(
        Puppy storage _matron,
        uint256 _matronId,
        Puppy storage _sire,
        uint256 _sireId
    )
        private
        view
        returns(bool)
    {
        // A Puppy can't breed with itself!
        if (_matronId == _sireId) {
            return false;
        }

        // puppies can't breed with their parents.
        if (_matron.matronId == _sireId || _matron.sireId == _sireId) {
            return false;
        }
        if (_sire.matronId == _matronId || _sire.sireId == _matronId) {
            return false;
        }

        // We can short circuit the sibling check (below) if either puppy is
        // gen zero (has a matron ID of zero).
        if (_sire.matronId == 0 || _matron.matronId == 0) {
            return true;
        }

        // puppies can't breed with full or half siblings.
        if (_sire.matronId == _matron.matronId || _sire.matronId == _matron.sireId) {
            return false;
        }
        if (_sire.sireId == _matron.matronId || _sire.sireId == _matron.sireId) {
            return false;
        }

        // Everything seems cool! Let's get DTF.
        return true;
    }

    /// @dev Internal check to see if a given sire and matron are a valid mating pair for
    ///  breeding via auction (i.e. skips ownership and siring approval checks).
    function _canBreedWithViaAuction(uint256 _matronId, uint256 _sireId)
        internal
        view
        returns (bool)
    {
        Puppy storage matron = puppies[_matronId];
        Puppy storage sire = puppies[_sireId];
        return _isValidMatingPair(matron, _matronId, sire, _sireId);
    }

    /// @notice Checks to see if two puppys can breed together, including checks for
    ///  ownership and siring approvals. Does NOT check that both puppys are ready for
    ///  breeding (i.e. breedWith could still fail until the cooldowns are finished).
    ///  TODO: Shouldn't this check pregnancy and cooldowns?!?
    /// @param _matronId The ID of the proposed matron.
    /// @param _sireId The ID of the proposed sire.
    function canBreedWith(uint256 _matronId, uint256 _sireId)
        external
        view
        returns(bool)
    {
        require(_matronId > 0);
        require(_sireId > 0);
        Puppy storage matron = puppies[_matronId];
        Puppy storage sire = puppies[_sireId];
        return _isValidMatingPair(matron, _matronId, sire, _sireId) &&
            _isSiringPermitted(_sireId, _matronId);
    }

    /// @dev Internal utility function to initiate breeding, assumes that all breeding
    ///  requirements have been checked.
    function _breedWith(uint256 _matronId, uint256 _sireId) internal {
        // Grab a reference to the puppies from storage.
        Puppy storage sire = puppies[_sireId];
        Puppy storage matron = puppies[_matronId];

        // Mark the matron as pregnant, keeping track of who the sire is.
        matron.siringWithId = uint32(_sireId);

        // Trigger the cooldown for both parents.
        _triggerCooldown(sire);
        _triggerCooldown(matron);
        _triggerChildCount(sire);
        _triggerChildCount(matron);

        // Clear siring permission for both parents. This may not be strictly necessary
        // but it's likely to avoid confusion!
        delete sireAllowedToAddress[_matronId];
        delete sireAllowedToAddress[_sireId];

        // Every time a Puppy gets pregnant, counter is incremented.
        pregnantpuppies++;

        // Emit the pregnancy event.
        Pregnant(PuppyIndexToOwner[_matronId], _matronId, _sireId, matron.cooldownEndBlock);
    }

    /// @notice Breed a Puppy you own (as matron) with a sire that you own, or for which you
    ///  have previously been given Siring approval. Will either make your puppy pregnant, or will
    ///  fail entirely. Requires a pre-payment of the fee given out to the first caller of giveBirth()
    /// @param _matronId The ID of the Puppy acting as matron (will end up pregnant if successful)
    /// @param _sireId The ID of the Puppy acting as sire (will begin its siring cooldown if successful)
    function breedWithAuto(uint256 _matronId, uint256 _sireId)
        external
        payable
        whenNotPaused
    {
        // Checks for payment.
        require(msg.value >= autoBirthFee);

        // Caller must own the matron.
        require(_owns(msg.sender, _matronId));

        // Neither sire nor matron are allowed to be on auction during a normal
        // breeding operation, but we don't need to check that explicitly.
        // For matron: The caller of this function can't be the owner of the matron
        //   because the owner of a Puppy on auction is the auction house, and the
        //   auction house will never call breedWith().
        // For sire: Similarly, a sire on auction will be owned by the auction house
        //   and the act of transferring ownership will have cleared any oustanding
        //   siring approval.
        // Thus we don't need to spend gas explicitly checking to see if either puppy
        // is on auction.

        // Check that matron and sire are both owned by caller, or that the sire
        // has given siring permission to caller (i.e. matron's owner).
        // Will fail for _sireId = 0
        require(_isSiringPermitted(_sireId, _matronId));

        // Grab a reference to the potential matron
        Puppy storage matron = puppies[_matronId];

        // Make sure matron isn't pregnant, or in the middle of a siring cooldown
        require(_isReadyToBreed(matron));

        // Grab a reference to the potential sire
        Puppy storage sire = puppies[_sireId];

        // Make sure sire isn't pregnant, or in the middle of a siring cooldown
        require(_isReadyToBreed(sire));

        // Test that these puppys are a valid mating pair.
        require(_isValidMatingPair(
            matron,
            _matronId,
            sire,
            _sireId
        ));

        // All checks passed, Puppy gets pregnant!
        _breedWith(_matronId, _sireId);
    }

    function playGame(uint256 _puppyId, uint256 _gameId)
        external
        whenNotPaused
        returns(bool)
    {
        require(puppySports != address(0));
        require(_owns(msg.sender, _puppyId));

        return puppySports.playGame(_puppyId, _gameId, block.number);
    }

    /// @notice Have a pregnant Puppy give birth!
    /// @param _matronId A Puppy ready to give birth.
    /// @return The Puppy ID of the new puppy.
    /// @dev Looks at a given Puppy and, if pregnant and if the gestation period has passed,
    ///  combines the genes of the two parents to create a new puppy. The new Puppy is assigned
    ///  to the current owner of the matron. Upon successful completion, both the matron and the
    ///  new puppy will be ready to breed again. Note that anyone can call this function (if they
    ///  are willing to pay the gas!), but the new puppy always goes to the mother's owner.
    function giveBirth(uint256 _matronId) payable
        external
        whenNotPaused
        returns(uint256)
    {
        // Grab a reference to the matron in storage.
        Puppy storage matron = puppies[_matronId];

        // Check that the matron is a valid puppy.
        require(matron.birthTime != 0);

        // Check that the matron is pregnant, and that its time has come!
        require(_isReadyToGiveBirth(matron));

        // Grab a reference to the sire in storage.
        uint256 sireId = matron.siringWithId;
        Puppy storage sire = puppies[sireId];

        // Determine the higher generation number of the two parents
        uint16 parentGen = matron.generation;
        if (sire.generation > matron.generation) {
            parentGen = sire.generation;
        }

        // Call the sooper-sekret gene mixing operation.
        //uint256 childGenes = _babyGenes;
        uint256 childGenes = geneScience.mixGenes(matron.genes, sire.genes, matron.cooldownEndBlock - 1);

        // Make the new puppy!
        address owner = PuppyIndexToOwner[_matronId];
        // Add randomizer for attributes
        uint16 strength = uint16(random(_matronId));
        uint16 agility = uint16(random(strength));
        uint16 intelligence = uint16(random(agility));
        uint16 speed = uint16(random(intelligence));

        uint256 puppyId = _createPuppy(_matronId, matron.siringWithId, parentGen + 1, childGenes, owner, strength, agility, intelligence, speed);

        // Clear the reference to sire from the matron (REQUIRED! Having siringWithId
        // set is what marks a matron as being pregnant.)
        delete matron.siringWithId;

        // Every time a Puppy gives birth counter is decremented.
        pregnantpuppies--;

        // Send the balance fee to the person who made birth happen.
        msg.sender.send(autoBirthFee);

        // return the new puppy's ID
        return puppyId;
    }

    //random
    function random(uint256 seed) public view returns (uint8 randomNumber) {
        uint8 rnd = uint8(keccak256(
            seed,
            block.blockhash(block.number - 1),
            block.coinbase,
            block.difficulty
        )) % 100 + uint8(1);
        return rnd % 100 + 1;
    }
}

/// @title Auction Core
/// @dev Contains models, variables, and internal methods for the auction.
/// @notice We omit a fallback function to prevent accidental sends to this contract.
contract ClockAuctionBase {

    // Represents an auction on an NFT
    struct Auction {
        // Current owner of NFT
        address seller;
        // Price (in wei) at beginning of auction
        uint128 startingPrice;
        // Price (in wei) at end of auction
        uint128 endingPrice;
        // Duration (in seconds) of auction
        uint64 duration;
        // Time when auction started
        // NOTE: 0 if this auction has been concluded
        uint64 startedAt;
    }

    // Reference to contract tracking NFT ownership
    ERC721 public nonFungibleContract;

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

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

    event AuctionCreated(uint256 tokenId, uint256 startingPrice, uint256 endingPrice, uint256 duration);
    event AuctionSuccessful(uint256 tokenId, uint256 totalPrice, address winner);
    event AuctionCancelled(uint256 tokenId);

    /// @dev Returns true if the claimant owns the token.
    /// @param _claimant - Address claiming to own the token.
    /// @param _tokenId - ID of token whose ownership to verify.
    function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) {
        return (nonFungibleContract.ownerOf(_tokenId) == _claimant);
    }

    /// @dev Escrows the NFT, assigning ownership to this contract.
    /// Throws if the escrow fails.
    /// @param _owner - Current owner address of token to escrow.
    /// @param _tokenId - ID of token whose approval to verify.
    function _escrow(address _owner, uint256 _tokenId) internal {
        // it will throw if transfer fails
        nonFungibleContract.transferFrom(_owner, this, _tokenId);
    }

    /// @dev Transfers an NFT owned by this contract to another address.
    /// Returns true if the transfer succeeds.
    /// @param _receiver - Address to transfer NFT to.
    /// @param _tokenId - ID of token to transfer.
    function _transfer(address _receiver, uint256 _tokenId) internal {
        // it will throw if transfer fails
        nonFungibleContract.transfer(_receiver, _tokenId);
    }

    /// @dev Adds an auction to the list of open auctions. Also fires the
    ///  AuctionCreated event.
    /// @param _tokenId The ID of the token to be put on auction.
    /// @param _auction Auction to add.
    function _addAuction(uint256 _tokenId, Auction _auction) internal {
        // Require that all auctions have a duration of
        // at least one minute. (Keeps our math from getting hairy!)
        require(_auction.duration >= 1 minutes);

        tokenIdToAuction[_tokenId] = _auction;

        AuctionCreated(
            uint256(_tokenId),
            uint256(_auction.startingPrice),
            uint256(_auction.endingPrice),
            uint256(_auction.duration)
        );
    }

    /// @dev Cancels an auction unconditionally.
    function _cancelAuction(uint256 _tokenId, address _seller) internal {
        _removeAuction(_tokenId);
        _transfer(_seller, _tokenId);
        AuctionCancelled(_tokenId);
    }

    /// @dev Computes the price and transfers winnings.
    /// Does NOT transfer ownership of token.
    function _bid(uint256 _tokenId, uint256 _bidAmount)
        internal
        returns (uint256)
    {
        // Get a reference to the auction struct
        Auction storage auction = tokenIdToAuction[_tokenId];

        // Explicitly check that this auction is currently live.
        // (Because of how Ethereum mappings work, we can't just count
        // on the lookup above failing. An invalid _tokenId will just
        // return an auction object that is all zeros.)
        require(_isOnAuction(auction));

        // Check that the bid is greater than or equal to the current price
        uint256 price = _currentPrice(auction);
        require(_bidAmount >= price);

        // Grab a reference to the seller before the auction struct
        // gets deleted.
        address seller = auction.seller;

        // The bid is good! Remove the auction before sending the fees
        // to the sender so we can't have a reentrancy attack.
        _removeAuction(_tokenId);

        // Transfer proceeds to seller (if there are any!)
        if (price > 0) {
            // Calculate the auctioneer's cut.
            // (NOTE: _computeCut() is guaranteed to return a
            // value <= price, so this subtraction can't go negative.)
            uint256 auctioneerCut = _computeCut(price);
            uint256 sellerProceeds = price - auctioneerCut;

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

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

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

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

        return price;
    }

    /// @dev Removes an auction from the list of open auctions.
    /// @param _tokenId - ID of NFT on auction.
    function _removeAuction(uint256 _tokenId) internal {
        delete tokenIdToAuction[_tokenId];
    }

    /// @dev Returns true if the NFT is on auction.
    /// @param _auction - Auction to check.
    function _isOnAuction(Auction storage _auction) internal view returns (bool) {
        return (_auction.startedAt > 0);
    }

    /// @dev Returns current price of an NFT on auction. Broken into two
    ///  functions (this one, that computes the duration from the auction
    ///  structure, and the other that does the price computation) so we
    ///  can easily test that the price computation works correctly.
    function _currentPrice(Auction storage _auction)
        internal
        view
        returns (uint256)
    {
        uint256 secondsPassed = 0;

        // A bit of insurance against negative values (or wraparound).
        // Probably not necessary (since Ethereum guarnatees that the
        // now variable doesn't ever go backwards).
        if (now > _auction.startedAt) {
            secondsPassed = now - _auction.startedAt;
        }

        return _computeCurrentPrice(
            _auction.startingPrice,
            _auction.endingPrice,
            _auction.duration,
            secondsPassed
        );
    }

    /// @dev Computes the current price of an auction. Factored out
    ///  from _currentPrice so we can run extensive unit tests.
    ///  When testing, make this function public and turn on
    ///  `Current price computation` test suite.
    function _computeCurrentPrice(
        uint256 _startingPrice,
        uint256 _endingPrice,
        uint256 _duration,
        uint256 _secondsPassed
    )
        internal
        pure
        returns (uint256)
    {
        // NOTE: We don't use SafeMath (or similar) in this function because
        //  all of our public functions carefully cap the maximum values for
        //  time (at 64-bits) and currency (at 128-bits). _duration is
        //  also known to be non-zero (see the require() statement in
        //  _addAuction())
        if (_secondsPassed >= _duration) {
            // We've reached the end of the dynamic pricing portion
            // of the auction, just return the end price.
            return _endingPrice;
        } else {
            // Starting price can be higher than ending price (and often is!), so
            // this delta can be negative.
            int256 totalPriceChange = int256(_endingPrice) - int256(_startingPrice);

            // This multiplipuppyion can't overflow, _secondsPassed will easily fit within
            // 64-bits, and totalPriceChange will easily fit within 128-bits, their product
            // will always fit within 256-bits.
            int256 currentPriceChange = totalPriceChange * int256(_secondsPassed) / int256(_duration);

            // currentPriceChange can be negative, but if so, will have a magnitude
            // less that _startingPrice. Thus, this result will always end up positive.
            int256 currentPrice = int256(_startingPrice) + currentPriceChange;

            return uint256(currentPrice);
        }
    }

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

}

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

  bool public paused = false;


  /**
   * @dev modifier to allow actions only when the contract IS paused
   */
  modifier whenNotPaused() {
    require(!paused);
    _;
  }

  /**
   * @dev modifier to allow actions only when the contract IS NOT paused
   */
  modifier whenPaused {
    require(paused);
    _;
  }

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

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


/// @title Clock auction for non-fungible tokens.
/// @notice We omit a fallback function to prevent accidental sends to this contract.
contract ClockAuction is Pausable, ClockAuctionBase {

    /// @dev The ERC-165 interface signature for ERC-721.
    ///  Ref: https://github.com/ethereum/EIPs/issues/165
    ///  Ref: https://github.com/ethereum/EIPs/issues/721
    bytes4 constant InterfaceSignature_ERC721 = bytes4(0x9a20483d);

    /// @dev Constructor creates a reference to the NFT ownership contract
    ///  and verifies the owner cut is in the valid range.
    /// @param _nftAddress - address of a deployed contract implementing
    ///  the Nonfungible Interface.
    /// @param _cut - percent cut the owner takes on each auction, must be
    ///  between 0-10,000.
    function ClockAuction(address _nftAddress, uint256 _cut) public {
        require(_cut <= 10000);
        ownerCut = _cut;

        ERC721 candidateContract = ERC721(_nftAddress);
        require(candidateContract.supportsInterface(InterfaceSignature_ERC721));
        nonFungibleContract = candidateContract;
    }

    /// @dev Remove all Ether from the contract, which is the owner's cuts
    ///  as well as any Ether sent directly to the contract address.
    ///  Always transfers to the NFT contract, but can be called either by
    ///  the owner or the NFT contract.
    function withdrawBalance() external {
        address nftAddress = address(nonFungibleContract);

        require(
            msg.sender == owner ||
            msg.sender == nftAddress
        );
        // We are using this boolean method to make sure that even if one fails it will still work
        bool res = nftAddress.send(this.balance);
    }

    /// @dev Creates and begins a new auction.
    /// @param _tokenId - ID of token to auction, sender must be owner.
    /// @param _startingPrice - Price of item (in wei) at beginning of auction.
    /// @param _endingPrice - Price of item (in wei) at end of auction.
    /// @param _duration - Length of time to move between starting
    ///  price and ending price (in seconds).
    /// @param _seller - Seller, if not the message sender
    function createAuction(
        uint256 _tokenId,
        uint256 _startingPrice,
        uint256 _endingPrice,
        uint256 _duration,
        address _seller
    )
        external
        whenNotPaused
    {
        // Sanity check that no inputs overflow how many bits we've allopuppyed
        // to store them in the auction struct.
        require(_startingPrice == uint256(uint128(_startingPrice)));
        require(_endingPrice == uint256(uint128(_endingPrice)));
        require(_duration == uint256(uint64(_duration)));

        require(_owns(msg.sender, _tokenId));
        _escrow(msg.sender, _tokenId);
        Auction memory auction = Auction(
            _seller,
            uint128(_startingPrice),
            uint128(_endingPrice),
            uint64(_duration),
            uint64(now)
        );
        _addAuction(_tokenId, auction);
    }

    /// @dev Bids on an open auction, completing the auction and transferring
    ///  ownership of the NFT if enough Ether is supplied.
    /// @param _tokenId - ID of token to bid on.
    function bid(uint256 _tokenId)
        external
        payable
        whenNotPaused
    {
        // _bid will throw if the bid or funds transfer fails
        _bid(_tokenId, msg.value);
        _transfer(msg.sender, _tokenId);
    }

    /// @dev Cancels an auction that hasn't been won yet.
    ///  Returns the NFT to original owner.
    /// @notice This is a state-modifying function that can
    ///  be called while the contract is paused.
    /// @param _tokenId - ID of token on auction
    function cancelAuction(uint256 _tokenId)
        external
    {
        Auction storage auction = tokenIdToAuction[_tokenId];
        require(_isOnAuction(auction));
        address seller = auction.seller;
        require(msg.sender == seller);
        _cancelAuction(_tokenId, seller);
    }

    /// @dev Cancels an auction when the contract is paused.
    ///  Only the owner may do this, and NFTs are returned to
    ///  the seller. This should only be used in emergencies.
    /// @param _tokenId - ID of the NFT on auction to cancel.
    function cancelAuctionWhenPaused(uint256 _tokenId)
        whenPaused
        onlyOwner
        external
    {
        Auction storage auction = tokenIdToAuction[_tokenId];
        require(_isOnAuction(auction));
        _cancelAuction(_tokenId, auction.seller);
    }

    /// @dev Returns auction info for an NFT on auction.
    /// @param _tokenId - ID of NFT on auction.
    function getAuction(uint256 _tokenId)
        external
        view
        returns
    (
        address seller,
        uint256 startingPrice,
        uint256 endingPrice,
        uint256 duration,
        uint256 startedAt
    ) {
        Auction storage auction = tokenIdToAuction[_tokenId];
        require(_isOnAuction(auction));
        return (
            auction.seller,
            auction.startingPrice,
            auction.endingPrice,
            auction.duration,
            auction.startedAt
        );
    }

    /// @dev Returns the current price of an auction.
    /// @param _tokenId - ID of the token price we are checking.
    function getCurrentPrice(uint256 _tokenId)
        external
        view
        returns (uint256)
    {
        Auction storage auction = tokenIdToAuction[_tokenId];
        require(_isOnAuction(auction));
        return _currentPrice(auction);
    }

}


/// @title Reverse auction modified for siring
/// @notice We omit a fallback function to prevent accidental sends to this contract.
contract SiringClockAuction is ClockAuction {

    // @dev Sanity check that allows us to ensure that we are pointing to the
    //  right auction in our setSiringAuctionAddress() call.
    bool public isSiringClockAuction = true;

    // Delegate constructor
    function SiringClockAuction(address _nftAddr, uint256 _cut) public
        ClockAuction(_nftAddr, _cut)
    {

    }

    /// @dev Creates and begins a new auction. Since this function is wrapped,
    /// require sender to be PuppiesCore contract.
    /// @param _tokenId - ID of token to auction, sender must be owner.
    /// @param _startingPrice - Price of item (in wei) at beginning of auction.
    /// @param _endingPrice - Price of item (in wei) at end of auction.
    /// @param _duration - Length of auction (in seconds).
    /// @param _seller - Seller, if not the message sender
    function createAuction(
        uint256 _tokenId,
        uint256 _startingPrice,
        uint256 _endingPrice,
        uint256 _duration,
        address _seller
    )
        external
    {
        // Sanity check that no inputs overflow how many bits we've allopuppyed
        // to store them in the auction struct.
        require(_startingPrice == uint256(uint128(_startingPrice)));
        require(_endingPrice == uint256(uint128(_endingPrice)));
        require(_duration == uint256(uint64(_duration)));

        require(msg.sender == address(nonFungibleContract));
        _escrow(_seller, _tokenId);
        Auction memory auction = Auction(
            _seller,
            uint128(_startingPrice),
            uint128(_endingPrice),
            uint64(_duration),
            uint64(now)
        );
        _addAuction(_tokenId, auction);
    }

    /// @dev Places a bid for siring. Requires the sender
    /// is the PuppiesCore contract because all bid methods
    /// should be wrapped. Also returns the Puppy to the
    /// seller rather than the winner.
    function bid(uint256 _tokenId)
        external
        payable
    {
        require(msg.sender == address(nonFungibleContract));
        address seller = tokenIdToAuction[_tokenId].seller;
        // _bid checks that token ID is valid and will throw if bid fails
        _bid(_tokenId, msg.value);
        // We transfer the Puppy back to the seller, the winner will get
        // the offspring
        _transfer(seller, _tokenId);
    }

}





/// @title Clock auction modified for sale of puppies
/// @notice We omit a fallback function to prevent accidental sends to this contract.
contract SaleClockAuction is ClockAuction {

    // @dev Sanity check that allows us to ensure that we are pointing to the
    //  right auction in our setSaleAuctionAddress() call.
    bool public isSaleClockAuction = true;

    // Tracks last 5 sale price of gen0 Puppy sales
    uint256 public gen0SaleCount;
    uint256[5] public lastGen0SalePrices;

    // Delegate constructor
    function SaleClockAuction(address _nftAddr, uint256 _cut) public ClockAuction(_nftAddr, _cut) {}

    /// @dev Creates and begins a new auction.
    /// @param _tokenId - ID of token to auction, sender must be owner.
    /// @param _startingPrice - Price of item (in wei) at beginning of auction.
    /// @param _endingPrice - Price of item (in wei) at end of auction.
    /// @param _duration - Length of auction (in seconds).
    /// @param _seller - Seller, if not the message sender
    function createAuction(
        uint256 _tokenId,
        uint256 _startingPrice,
        uint256 _endingPrice,
        uint256 _duration,
        address _seller
    )
        external
    {
        // Sanity check that no inputs overflow how many bits we've allopuppyed
        // to store them in the auction struct.
        require(_startingPrice == uint256(uint128(_startingPrice)));
        require(_endingPrice == uint256(uint128(_endingPrice)));
        require(_duration == uint256(uint64(_duration)));

        require(msg.sender == address(nonFungibleContract));
        _escrow(_seller, _tokenId);
        Auction memory auction = Auction(
            _seller,
            uint128(_startingPrice),
            uint128(_endingPrice),
            uint64(_duration),
            uint64(now)
        );
        _addAuction(_tokenId, auction);
    }

    /// @dev Updates lastSalePrice if seller is the nft contract
    /// Otherwise, works the same as default bid method.
    function bid(uint256 _tokenId)
        external
        payable
    {
        // _bid verifies token ID size
        address seller = tokenIdToAuction[_tokenId].seller;
        uint256 price = _bid(_tokenId, msg.value);
        _transfer(msg.sender, _tokenId);

        // If not a gen0 auction, exit
        if (seller == address(nonFungibleContract)) {
            // Track gen0 sale prices
            lastGen0SalePrices[gen0SaleCount % 5] = price;
            gen0SaleCount++;
        }
    }

    function averageGen0SalePrice() external view returns (uint256) {
        uint256 sum = 0;
        for (uint256 i = 0; i < 5; i++) {
            sum += lastGen0SalePrices[i];
        }
        return sum / 5;
    }

}


/// @title Handles creating auctions for sale and siring of puppies.
///  This wrapper of ReverseAuction exists only so that users can create
///  auctions with only one transaction.
contract PuppiesAuction is PuppyBreeding {

    // @notice The auction contract variables are defined in PuppyBase to allow
    //  us to refer to them in PuppyOwnership to prevent accidental transfers.
    // `saleAuction` refers to the auction for gen0 and p2p sale of puppies.
    // `siringAuction` refers to the auction for siring rights of puppies.

    /// @dev Sets the reference to the sale auction.
    /// @param _address - Address of sale contract.
    function setSaleAuctionAddress(address _address) external onlyCEO {
        SaleClockAuction candidateContract = SaleClockAuction(_address);

        // NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117
        require(candidateContract.isSaleClockAuction());

        // Set the new contract address
        saleAuction = candidateContract;
    }

    /// @dev Sets the reference to the siring auction.
    /// @param _address - Address of siring contract.
    function setSiringAuctionAddress(address _address) external onlyCEO {
        SiringClockAuction candidateContract = SiringClockAuction(_address);

        // NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117
        require(candidateContract.isSiringClockAuction());

        // Set the new contract address
        siringAuction = candidateContract;
    }

    /// @dev Put a Puppy up for auction.
    ///  Does some ownership trickery to create auctions in one tx.
    function createPuppySaleAuction(
        uint256 _puppyId,
        uint256 _startingPrice,
        uint256 _endingPrice,
        uint256 _duration
    )
        external
        whenNotPaused
    {
        // Auction contract checks input sizes
        // If Puppy is already on any auction, this will throw
        // because it will be owned by the auction contract.
        require(_owns(msg.sender, _puppyId));
        // Ensure the Puppy is not pregnant to prevent the auction
        // contract accidentally receiving ownership of the child.
        // NOTE: the Puppy IS allowed to be in a cooldown.
        require(!isPregnant(_puppyId));
        _approve(_puppyId, saleAuction);
        // Sale auction throws if inputs are invalid and clears
        // transfer and sire approval after escrowing the Puppy.
        saleAuction.createAuction(
            _puppyId,
            _startingPrice,
            _endingPrice,
            _duration,
            msg.sender
        );
    }

    /// @dev Put a Puppy up for auction to be sire.
    ///  Performs checks to ensure the Puppy can be sired, then
    ///  delegates to reverse auction.
    function createPuppySiringAuctiona(
        uint256 _puppyId,
        uint256 _startingPrice,
        uint256 _endingPrice,
        uint256 _duration
    )
        external
        whenNotPaused
    {
        // Auction contract checks input sizes
        // If Puppy is already on any auction, this will throw
        // because it will be owned by the auction contract.
        require(_owns(msg.sender, _puppyId));
        require(isReadyToBreed(_puppyId));
        _approve(_puppyId, siringAuction);
        // Siring auction throws if inputs are invalid and clears
        // transfer and sire approval after escrowing the Puppy.
        siringAuction.createAuction(
            _puppyId,
            _startingPrice,
            _endingPrice,
            _duration,
            msg.sender
        );
    }

    /// @dev Completes a siring auction by bidding.
    ///  Immediately breeds the winning matron with the sire on auction.
    /// @param _sireId - ID of the sire on auction.
    /// @param _matronId - ID of the matron owned by the bidder.
    function bidOnSiringAuction(
        uint256 _sireId,
        uint256 _matronId
    )
        external
        payable
        whenNotPaused
    {
        // Auction contract checks input sizes
        require(_owns(msg.sender, _matronId));
        require(isReadyToBreed(_matronId));
        require(_canBreedWithViaAuction(_matronId, _sireId));

        // Define the current price of the auction.
        uint256 currentPrice = siringAuction.getCurrentPrice(_sireId);
        require(msg.value >= currentPrice + autoBirthFee);

        // Siring auction will throw if the bid fails.
        siringAuction.bid.value(msg.value - autoBirthFee)(_sireId);
        _breedWith(uint32(_matronId), uint32(_sireId));
    }

    /// @dev Transfers the balance of the sale auction contract
    /// to the PuppiesCore contract. We use two-step withdrawal to
    /// prevent two transfer calls in the auction bid function.
    function withdrawAuctionBalances() external onlyCLevel {
        saleAuction.withdrawBalance();
        siringAuction.withdrawBalance();
    }
}


/// @title all functions related to creating puppys
contract PuppiesMinting is PuppiesAuction {

    // Limits the number of puppys the contract owner can ever create.
    uint256 public constant PROMO_CREATION_LIMIT = 5000;
    uint256 public constant GEN0_CREATION_LIMIT = 15000;

    // Constants for gen0 auctions.
    uint256 public constant GEN0_STARTING_PRICE = 100 finney;
    uint256 public constant GEN0_MINIMAL_PRICE = 10 finney;
    uint256 public constant GEN0_AUCTION_DURATION = 2 days;

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

    /// @dev we can create promo puppys, up to a limit. Only callable by COO
    /// @param _genes the encoded genes of the puppy to be created, any value is accepted
    /// @param _owner the future owner of the created puppys. Default to contract COO
    function createPromoPuppy(uint256 _genes, address _owner, uint16 _strength, uint16 _agility, uint16 _intelligence, uint16 _speed) external onlyCOO {
        address puppyOwner = _owner;
        if (puppyOwner == address(0)) {
             puppyOwner = cooAddress;
        }
        require(promoCreatedCount < PROMO_CREATION_LIMIT);

        promoCreatedCount++;
        _createPuppy(0, 0, 0, _genes, puppyOwner, _strength, _agility, _intelligence, _speed);
    }

    /// @dev Creates a new gen0 Puppy with the given genes and
    ///  creates an auction for it.
    function createGen0Auction(uint256 _genes, uint16 _strength, uint16 _agility, uint16 _intelligence, uint16 _speed, uint16 _talent) external onlyCOO {
        require(gen0CreatedCount < GEN0_CREATION_LIMIT);

        uint256 puppyId = _createPuppy(0, 0, 0, _genes, address(this), _strength, _agility, _intelligence, _speed);
        _approve(puppyId, saleAuction);

        saleAuction.createAuction(
            puppyId,
            _computeNextGen0Price(),
            GEN0_MINIMAL_PRICE,
            GEN0_AUCTION_DURATION,
            address(this)
        );

        gen0CreatedCount++;
    }

    /// @dev Computes the next gen0 auction starting price, given
    ///  the average of the past 5 prices + 50%.
    function _computeNextGen0Price() internal view returns (uint256) {
        uint256 avePrice = saleAuction.averageGen0SalePrice();

        // Sanity check to ensure we don't overflow arithmetic
        require(avePrice == uint256(uint128(avePrice)));

        uint256 nextPrice = avePrice + (avePrice / 2);

        // We never auction for less than starting price
        if (nextPrice < GEN0_STARTING_PRICE) {
            nextPrice = GEN0_STARTING_PRICE;
        }

        return nextPrice;
    }
}


/// @title CryptoPuppies: Collectible, breedable, and oh-so-adorable puppys on the Ethereum blockchain.
/// @author Axiom Zen (https://www.axiomzen.co)
/// @dev The main CryptoPuppies contract, keeps track of puppys so they don't wander around and get lost.
contract PuppiesCore is PuppiesMinting {

    // This is the main CryptoPuppies contract. In order to keep our code seperated into logical sections,
    // we've broken it up in two ways. First, we have several seperately-instantiated sibling contracts
    // that handle auctions and our super-top-secret genetic combination algorithm. The auctions are
    // seperate since their logic is somewhat complex and there's always a risk of subtle bugs. By keeping
    // them in their own contracts, we can upgrade them without disrupting the main contract that tracks
    // Puppy ownership. The genetic combination algorithm is kept seperate so we can open-source all of
    // the rest of our code without making it _too_ easy for folks to figure out how the genetics work.
    // Don't worry, I'm sure someone will reverse engineer it soon enough!
    //
    // Secondly, we break the core contract into multiple files using inheritence, one for each major
    // facet of functionality of CK. This allows us to keep related code bundled together while still
    // avoiding a single giant file with everything in it. The breakdown is as follows:
    //
    //      - PuppyBase: This is where we define the most fundamental code shared throughout the core
    //             functionality. This includes our main data storage, constants and data types, plus
    //             internal functions for managing these items.
    //
    //      - PuppyAccessControl: This contract manages the various addresses and constraints for operations
    //             that can be executed only by specific roles. Namely CEO, CFO and COO.
    //
    //      - PuppyOwnership: This provides the methods required for basic non-fungible token
    //             transactions, following the draft ERC-721 spec (https://github.com/ethereum/EIPs/issues/721).
    //
    //      - PuppyBreeding: This file contains the methods necessary to breed puppys together, including
    //             keeping track of siring offers, and relies on an external genetic combination contract.
    //
    //      - PuppyAuctions: Here we have the public methods for auctioning or bidding on puppys or siring
    //             services. The actual auction functionality is handled in two sibling contracts (one
    //             for sales and one for siring), while auction creation and bidding is mostly mediated
    //             through this facet of the core contract.
    //
    //      - PuppiesMinting: This final facet contains the functionality we use for creating new gen0 puppys.
    //             We can make up to 5000 "promo" puppys that can be given away (especially important when
    //             the community is new), and all others can only be created and then immediately put up
    //             for auction via an algorithmically determined starting price. Regardless of how they
    //             are created, there is a hard limit of 50k gen0 puppys. After that, it's all up to the
    //             community to breed, breed, breed!

    // Set in case the core contract is broken and an upgrade is required
    address public newContractAddress;

    /// @notice Creates the main CryptoPuppies smart contract instance.
    function PuppiesCore() public {
        // Starts paused.
        paused = true;

        // the creator of the contract is the initial CEO
        ceoAddress = msg.sender;

        // the creator of the contract is also the initial COO
        cooAddress = msg.sender;

        // start with the mythical puppy 0 - so we don't have generation-0 parent issues
        _createPuppy(0, 0, 0, uint256(-1), address(0), 0, 0, 0, 0);
    }

    /// @dev Used to mark the smart contract as upgraded, in case there is a serious
    ///  breaking bug. This method does nothing but keep track of the new contract and
    ///  emit a message indipuppying that the new address is set. It's up to clients of this
    ///  contract to update to the new contract address in that case. (This contract will
    ///  be paused indefinitely if such an upgrade takes place.)
    /// @param _v2Address new address
    function setNewAddress(address _v2Address) external onlyCEO whenPaused {
        // See README.md for updgrade plan
        newContractAddress = _v2Address;
        ContractUpgrade(_v2Address);
    }

    /// @notice No tipping!
    /// @dev Reject all Ether from being sent here, unless it's from one of the
    ///  two auction contracts. (Hopefully, we can prevent user accidents.)
    function() external payable {
        require(
            msg.sender == address(saleAuction) ||
            msg.sender == address(siringAuction)
        );
    }

    /// @notice Returns all the relevant information about a specific Puppy.
    /// @param _id The ID of the Puppy of interest.
    function getPuppy(uint256 _id)
        external
        view
        returns (
        bool isGestating,
        bool isReady,
        uint256 cooldownIndex,
        uint256 nextActionAt,
        uint256 siringWithId,
        uint256 birthTime,
        uint256 matronId,
        uint256 sireId,
        uint256 generation,
        uint256 genes
    ) {
        Puppy storage pup = puppies[_id];

        // if this variable is 0 then it's not gestating
        isGestating = (pup.siringWithId != 0);
        isReady = (pup.cooldownEndBlock <= block.number);
        cooldownIndex = uint256(pup.cooldownIndex);
        nextActionAt = uint256(pup.cooldownEndBlock);
        siringWithId = uint256(pup.siringWithId);
        birthTime = uint256(pup.birthTime);
        matronId = uint256(pup.matronId);
        sireId = uint256(pup.sireId);
        generation = uint256(pup.generation);
        genes = pup.genes;
    }

    function getPuppyAttributes(uint256 _id)
    external
        view
        returns (
        uint16 childNumber,
        uint16 strength,
        uint16 agility,
        uint16 intelligence,
        uint16 speed
    ) {
        Puppy storage pup = puppies[_id];

        // if this variable is 0 then it's not gestating
        childNumber = uint16(pup.childNumber);
        strength = uint16(pup.strength);
        agility = uint16(pup.agility);
        intelligence = uint16(pup.intelligence);
        speed = uint16(pup.speed);
    }

    /// @dev Override unpause so it requires all external contract addresses
    ///  to be set before contract can be unpaused. Also, we can't have
    ///  newContractAddress set either, because then the contract was upgraded.
    /// @notice This is public rather than external so we can call super.unpause
    ///  without using an expensive CALL.
    function unpause() public onlyCEO whenPaused {
        require(saleAuction != address(0));
        require(siringAuction != address(0));
        //require(geneScience != address(0));
        //require(newContractAddress == address(0));

        // Actually unpause the contract.
        super.unpause();
    }

    // @dev Allows the CFO to capture the balance available to the contract.
    function withdrawBalance() external onlyCFO {
        uint256 balance = this.balance;
        // Subtract all the currently pregnant puppys we have, plus 1 of margin.
        uint256 subtractFees = (pregnantpuppies + 1) * autoBirthFee;

        if (balance > subtractFees) {
            cfoAddress.send(balance - subtractFees);
        }
    }
}

Contract Security Audit

Contract ABI

[{"constant":true,"inputs":[{"name":"_interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"cfoAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"_preferredTransport","type":"string"}],"name":"tokenMetadata","outputs":[{"name":"infoUrl","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"promoCreatedCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"puppySports","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"ceoAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"GEN0_STARTING_PRICE","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"}],"name":"setSiringAuctionAddress","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_puppyId","type":"uint256"}],"name":"isPregnant","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"GEN0_AUCTION_DURATION","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"siringAuction","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_puppyId","type":"uint256"},{"name":"_startingPrice","type":"uint256"},{"name":"_endingPrice","type":"uint256"},{"name":"_duration","type":"uint256"}],"name":"createPuppySaleAuction","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"}],"name":"setGeneScienceAddress","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newCEO","type":"address"}],"name":"setCEO","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newCOO","type":"address"}],"name":"setCOO","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"maxChildCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_maxChildCount","type":"uint256"}],"name":"setMaxChildCount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_id","type":"uint256"}],"name":"getPuppyAttributes","outputs":[{"name":"childNumber","type":"uint16"},{"name":"strength","type":"uint16"},{"name":"agility","type":"uint16"},{"name":"intelligence","type":"uint16"},{"name":"speed","type":"uint16"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_puppyId","type":"uint256"},{"name":"_gameId","type":"uint256"}],"name":"playGame","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_minChildCount","type":"uint256"}],"name":"setMinChildCount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"minChildCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_genes","type":"uint256"},{"name":"_strength","type":"uint16"},{"name":"_agility","type":"uint16"},{"name":"_intelligence","type":"uint16"},{"name":"_speed","type":"uint16"},{"name":"_talent","type":"uint16"}],"name":"createGen0Auction","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"sireAllowedToAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_matronId","type":"uint256"},{"name":"_sireId","type":"uint256"}],"name":"canBreedWith","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"val","type":"uint256"}],"name":"setAutoBirthFee","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_addr","type":"address"},{"name":"_sireId","type":"uint256"}],"name":"approveSiring","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newCFO","type":"address"}],"name":"setCFO","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"secs","type":"uint256"}],"name":"setSecondsPerBlock","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"withdrawBalance","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"name":"owner","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"GEN0_CREATION_LIMIT","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"GEN0_MINIMAL_PRICE","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"newContractAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_genes","type":"uint256"},{"name":"_owner","type":"address"},{"name":"_strength","type":"uint16"},{"name":"_agility","type":"uint16"},{"name":"_intelligence","type":"uint16"},{"name":"_speed","type":"uint16"}],"name":"createPromoPuppy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"}],"name":"setSaleAuctionAddress","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"count","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_v2Address","type":"address"}],"name":"setNewAddress","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"PuppyIndexToOwner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"secondsPerBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"tokensOfOwner","outputs":[{"name":"ownerTokens","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_matronId","type":"uint256"}],"name":"giveBirth","outputs":[{"name":"","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_puppyId","type":"uint256"},{"name":"_startingPrice","type":"uint256"},{"name":"_endingPrice","type":"uint256"},{"name":"_duration","type":"uint256"}],"name":"createPuppySiringAuctiona","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"withdrawAuctionBalances","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"cooldowns","outputs":[{"name":"","type":"uint32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"pregnantpuppies","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"transfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"cooAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"autoBirthFee","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"seed","type":"uint256"}],"name":"random","outputs":[{"name":"randomNumber","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"erc721Metadata","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_puppyId","type":"uint256"}],"name":"isReadyToBreed","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"}],"name":"setPuppySports","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"PROMO_CREATION_LIMIT","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_contractAddress","type":"address"}],"name":"setMetadataAddress","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"saleAuction","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_sireId","type":"uint256"},{"name":"_matronId","type":"uint256"}],"name":"bidOnSiringAuction","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"gen0CreatedCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"geneScience","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_id","type":"uint256"}],"name":"getPuppy","outputs":[{"name":"isGestating","type":"bool"},{"name":"isReady","type":"bool"},{"name":"cooldownIndex","type":"uint256"},{"name":"nextActionAt","type":"uint256"},{"name":"siringWithId","type":"uint256"},{"name":"birthTime","type":"uint256"},{"name":"matronId","type":"uint256"},{"name":"sireId","type":"uint256"},{"name":"generation","type":"uint256"},{"name":"genes","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_matronId","type":"uint256"},{"name":"_sireId","type":"uint256"}],"name":"breedWithAuto","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"PuppyIndexToApproved","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"matronId","type":"uint256"},{"indexed":false,"name":"sireId","type":"uint256"},{"indexed":false,"name":"cooldownEndBlock","type":"uint256"}],"name":"Pregnant","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"from","type":"address"},{"indexed":false,"name":"to","type":"address"},{"indexed":false,"name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"approved","type":"address"},{"indexed":false,"name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"puppyId","type":"uint256"},{"indexed":false,"name":"matronId","type":"uint256"},{"indexed":false,"name":"sireId","type":"uint256"},{"indexed":false,"name":"genes","type":"uint256"}],"name":"Birth","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"newContract","type":"address"}],"name":"ContractUpgrade","type":"event"}]

606060409081526002805460a060020a60ff02191690556101c090519081016040908152603c82526078602083015261012c9082015261025860608201526107086080820152610e1060a0820152611c2060c082015261384060e082015261708061010082015261e100610120820152620151806101408201526202a3006101608201526205460061018082015262093a806101a0820152620000a790600390600e620005df565b50600f600555661c6bf526340000600e556002601055600e60115560006012553415620000d357600080fd5b6002805460008054600160a060020a033316600160a060020a03199182168117835560a060020a60ff021990931674010000000000000000000000000000000000000000171690911790915562000142908080600019818080808064010000000062002c806200014982021704565b506200077e565b6000806200015662000682565b600063ffffffff8d168d146200016b57600080fd5b63ffffffff8c168c146200017e57600080fd5b61ffff8b168b146200018f57600080fd5b60028b049250600d8361ffff161115620001a857600d92505b6101a0604051908101604052808b8152602001426001604060020a0316815260200160006001604060020a031681526020018e63ffffffff1681526020018d63ffffffff168152602001600063ffffffff1681526020018461ffff1681526020018c61ffff168152602001600061ffff1681526020018961ffff1681526020018861ffff1681526020018761ffff1681526020018661ffff1681525091506001600680548060010182816200025e9190620006ee565b6000928352602090922085916003020181518155602082015160018201805467ffffffffffffffff19166001604060020a039290921691909117905560408201518160010160086101000a8154816001604060020a0302191690836001604060020a0316021790555060608201518160010160106101000a81548163ffffffff021916908363ffffffff16021790555060808201518160010160146101000a81548163ffffffff021916908363ffffffff16021790555060a08201518160010160186101000a81548163ffffffff021916908363ffffffff16021790555060c082015181600101601c6101000a81548161ffff021916908361ffff16021790555060e082015181600101601e6101000a81548161ffff021916908361ffff16021790555061010082015160028201805461ffff191661ffff929092169190911790556101208201518160020160026101000a81548161ffff021916908361ffff1602179055506101408201518160020160046101000a81548161ffff021916908361ffff1602179055506101608201518160020160066101000a81548161ffff021916908361ffff1602179055506101808201516002909101805461ffff929092166801000000000000000002604060020a61ffff02199092169190911790555003905063ffffffff811681146200045557600080fd5b7f0a5311bd2a6608f08a180df2ee7c5946819a649b204b554bb8e39825b2c50ad58982846060015163ffffffff16856080015163ffffffff168651604051600160a060020a03909516855260208501939093526040808501929092526060840152608083019190915260a0909101905180910390a1620004e660008a8364010000000062002b98620004f682021704565b9c9b505050505050505050505050565b600160a060020a03808316600081815260086020908152604080832080546001019055858352600790915290208054600160a060020a03191690911790558316156200058a57600160a060020a03831660009081526008602090815260408083208054600019019055838352600a82528083208054600160a060020a03199081169091556009909252909120805490911690555b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef838383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a1505050565b600283019183908215620006705791602002820160005b838211156200063c57835183826101000a81548163ffffffff021916908363ffffffff1602179055509260200192600401602081600301049283019260010302620005f6565b80156200066e5782816101000a81549063ffffffff02191690556004016020816003010492830192600103026200063c565b505b506200067e92915062000722565b5090565b6101a06040519081016040908152600080835260208301819052908201819052606082018190526080820181905260a0820181905260c0820181905260e08201819052610100820181905261012082018190526101408201819052610160820181905261018082015290565b8154818355818111156200071d576003028160030283600052602060002091820191016200071d919062000749565b505050565b6200074691905b808211156200067e57805463ffffffff1916815560010162000729565b90565b6200074691905b808211156200067e57600080825560018201556002810180546001605060020a031916905560030162000750565b6137d6806200078e6000396000f3006060604052600436106103135763ffffffff60e060020a60003504166301ffc9a7811461034b5780630519ce79146103975780630560ff44146103c657806305e455461461045f57806306fdde031461048457806308595e5e14610497578063095ea7b3146104aa5780630a0f8168146104cc5780630e583df0146104df57806314001f4c146104f257806318160ddd146105115780631940a9361461052457806319c2f2011461053a57806321717ebf1461054d57806323b872dd1461056057806324280cc41461058857806324e7a38a146105a757806327d7874c146105c65780632ba73c15146105e55780632cf5fe89146106045780632eae0018146106175780633268215c1461062d57806334825a231461067c57806337621da0146106955780633790613f146106ab5780633ac9a77a146106be5780633f4ba83a146106f357806346116e6f1461070657806346d22c701461071c5780634b85fd55146107355780634dfff04f1461074b5780634e0a33791461076d5780635663896e1461078c5780635c975abb146107a25780635fd8c710146107b55780636352211e146107c8578063680eba27146107de57806368f2d6e2146107f15780636af04a57146108045780636b7d9a5c146108175780636fbde40d1461085257806370a0823114610871578063715879881461089057806379b4fd55146108af5780637a7d4937146108c55780638456cb59146108d85780638462151c146108eb57806388c2a0bf1461095d5780638b587b821461096857806391876e571461098757806395d89b411461099a5780639d6fac6f146109ad578063a4acbcd6146109dc578063a9059cbb146109ef578063b047fb5014610a11578063b0c35c0514610a24578063b863bd3714610a37578063bc4006f514610a63578063d3e6f49f14610a76578063da24e40214610a8c578063defb958414610aab578063e17b25af14610abe578063e6cbe35114610add578063ed60ade614610af0578063f1ca941014610afe578063f2b47d5214610b11578063f36c83f014610b24578063f7d8c88314610b92578063ff139dfb14610ba0575b600b5433600160a060020a039081169116148061033e5750600c5433600160a060020a039081169116145b151561034957600080fd5b005b341561035657600080fd5b6103837fffffffff0000000000000000000000000000000000000000000000000000000060043516610bb6565b604051901515815260200160405180910390f35b34156103a257600080fd5b6103aa610e3d565b604051600160a060020a03909116815260200160405180910390f35b34156103d157600080fd5b6103e8600480359060248035908101910135610e4c565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561042457808201518382015260200161040c565b50505050905090810190601f1680156104515780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561046a57600080fd5b610472610f1c565b60405190815260200160405180910390f35b341561048f57600080fd5b6103e8610f22565b34156104a257600080fd5b6103aa610f59565b34156104b557600080fd5b610349600160a060020a0360043516602435610f68565b34156104d757600080fd5b6103aa610ff2565b34156104ea57600080fd5b610472611001565b34156104fd57600080fd5b610349600160a060020a036004351661100d565b341561051c57600080fd5b6104726110ad565b341561052f57600080fd5b6103836004356110b8565b341561054557600080fd5b6104726110fd565b341561055857600080fd5b6103aa611104565b341561056b57600080fd5b610349600160a060020a0360043581169060243516604435611113565b341561059357600080fd5b61034960043560243560443560643561119a565b34156105b257600080fd5b610349600160a060020a0360043516611275565b34156105d157600080fd5b610349600160a060020a0360043516611315565b34156105f057600080fd5b610349600160a060020a0360043516611367565b341561060f57600080fd5b6104726113b9565b341561062257600080fd5b6103496004356113bf565b341561063857600080fd5b610643600435611404565b60405161ffff9586168152938516602085015291841660408085019190915290841660608401529216608082015260a001905180910390f35b341561068757600080fd5b610383600435602435611471565b34156106a057600080fd5b61034960043561152b565b34156106b657600080fd5b610472611570565b34156106c957600080fd5b61034960043561ffff60243581169060443581169060643581169060843581169060a43516611576565b34156106fe57600080fd5b610349611674565b341561071157600080fd5b6103aa6004356116df565b341561072757600080fd5b6103836004356024356116fa565b341561074057600080fd5b61034960043561177a565b341561075657600080fd5b610349600160a060020a036004351660243561179a565b341561077857600080fd5b610349600160a060020a03600435166117f4565b341561079757600080fd5b610349600435611846565b34156107ad57600080fd5b6103836118ae565b34156107c057600080fd5b6103496118be565b34156107d357600080fd5b6103aa60043561192f565b34156107e957600080fd5b610472611953565b34156107fc57600080fd5b610472611959565b341561080f57600080fd5b6103aa611964565b341561082257600080fd5b610349600435600160a060020a036024351661ffff60443581169060643581169060843581169060a43516611973565b341561085d57600080fd5b610349600160a060020a03600435166119e7565b341561087c57600080fd5b610472600160a060020a0360043516611a87565b341561089b57600080fd5b610349600160a060020a0360043516611aa2565b34156108ba57600080fd5b6103aa600435611b30565b34156108d057600080fd5b610472611b4b565b34156108e357600080fd5b610349611b51565b34156108f657600080fd5b61090a600160a060020a0360043516611bdd565b60405160208082528190810183818151815260200191508051906020019060200280838360005b83811015610949578082015183820152602001610931565b505050509050019250505060405180910390f35b610472600435611cbe565b341561097357600080fd5b61034960043560243560443560643561201a565b341561099257600080fd5b6103496120e0565b34156109a557600080fd5b6103e86121cb565b34156109b857600080fd5b6109c3600435612202565b60405163ffffffff909116815260200160405180910390f35b34156109e757600080fd5b61047261222f565b34156109fa57600080fd5b610349600160a060020a0360043516602435612235565b3415610a1c57600080fd5b6103aa6122d8565b3415610a2f57600080fd5b6104726122e7565b3415610a4257600080fd5b610a4d6004356122ed565b60405160ff909116815260200160405180910390f35b3415610a6e57600080fd5b6103aa612362565b3415610a8157600080fd5b610383600435612371565b3415610a9757600080fd5b610349600160a060020a0360043516612484565b3415610ab657600080fd5b610472612524565b3415610ac957600080fd5b610349600160a060020a036004351661252a565b3415610ae857600080fd5b6103aa612567565b610349600435602435612576565b3415610b0957600080fd5b6104726126b8565b3415610b1c57600080fd5b6103aa6126be565b3415610b2f57600080fd5b610b3a6004356126cd565b6040519915158a5297151560208a01526040808a01979097526060890195909552608088019390935260a087019190915260c086015260e0850152610100840152610120830191909152610140909101905180910390f35b61034960043560243561282e565b3415610bab57600080fd5b6103aa600435612aba565b60006040517f737570706f727473496e7465726661636528627974657334290000000000000081526019016040518091039020600160e060020a03191682600160e060020a0319161480610e3557506040517f746f6b656e4d657461646174612875696e743235362c737472696e67290000008152601d0160405180910390206040517f746f6b656e734f664f776e657228616464726573732900000000000000000000815260160160405180910390206040517f7472616e7366657246726f6d28616464726573732c616464726573732c75696e81527f7432353629000000000000000000000000000000000000000000000000000000602082015260250160405180910390206040517f7472616e7366657228616464726573732c75696e743235362900000000000000815260190160405180910390206040517f617070726f766528616464726573732c75696e74323536290000000000000000815260180160405180910390206040517f6f776e65724f662875696e743235362900000000000000000000000000000000815260100160405180910390206040517f62616c616e63654f662861646472657373290000000000000000000000000000815260120160405180910390206040517f746f74616c537570706c792829000000000000000000000000000000000000008152600d0160405180910390206040517f73796d626f6c2829000000000000000000000000000000000000000000000000815260080160405180910390206040517f6e616d652829000000000000000000000000000000000000000000000000000081526006016040518091039020181818181818181818600160e060020a03191682600160e060020a031916145b90505b919050565b600154600160a060020a031681565b610e546136a6565b610e5c6136b8565b600d54600090600160a060020a03161515610e7657600080fd5b600d54600160a060020a031663cb4799f287878760405160e060020a63ffffffff861602815260048101848152604060248301908152604483018490529091606401848480828437820191505094505050505060a060405180830381600087803b1515610ee257600080fd5b5af11515610eef57600080fd5b50505060405180608001805160209091016040529092509050610f128282612ad5565b9695505050505050565b60155481565b60408051908101604052600d81527f43727970746f5075707069657300000000000000000000000000000000000000602082015281565b601454600160a060020a031681565b60025460a060020a900460ff1615610f7f57600080fd5b610f893382612b2a565b1515610f9457600080fd5b610f9e8183612b4a565b7f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925338383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a15050565b600054600160a060020a031681565b67016345785d8a000081565b6000805433600160a060020a0390811691161461102957600080fd5b5080600160a060020a0381166376190f8f6040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561106857600080fd5b5af1151561107557600080fd5b50505060405180519050151561108a57600080fd5b600c8054600160a060020a031916600160a060020a039290921691909117905550565b600654600019015b90565b60008082116110c657600080fd5b60068054839081106110d457fe5b600091825260209091206003909102016001015460c060020a900463ffffffff16151592915050565b6202a30081565b600c54600160a060020a031681565b60025460a060020a900460ff161561112a57600080fd5b600160a060020a038216151561113f57600080fd5b30600160a060020a031682600160a060020a03161415151561116057600080fd5b61116a3382612b78565b151561117557600080fd5b61117f8382612b2a565b151561118a57600080fd5b611195838383612b98565b505050565b60025460a060020a900460ff16156111b157600080fd5b6111bb3385612b2a565b15156111c657600080fd5b6111cf846110b8565b156111d957600080fd5b600b546111f0908590600160a060020a0316612b4a565b600b54600160a060020a03166327ebe40a858585853360405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b151561125f57600080fd5b5af1151561126c57600080fd5b50505050505050565b6000805433600160a060020a0390811691161461129157600080fd5b5080600160a060020a0381166354c15b826040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156112d057600080fd5b5af115156112dd57600080fd5b5050506040518051905015156112f257600080fd5b60138054600160a060020a031916600160a060020a039290921691909117905550565b60005433600160a060020a0390811691161461133057600080fd5b600160a060020a038116151561134557600080fd5b60008054600160a060020a031916600160a060020a0392909216919091179055565b60005433600160a060020a0390811691161461138257600080fd5b600160a060020a038116151561139757600080fd5b60028054600160a060020a031916600160a060020a0392909216919091179055565b60115481565b60025433600160a060020a039081169116146113da57600080fd5b60025460a060020a900460ff16156113f157600080fd5b60105481116113ff57600080fd5b601155565b60008060008060008060068781548110151561141c57fe5b600091825260209091206002600390920201015461ffff808216996201000083048216995064010000000083048216985066010000000000008304821697506801000000000000000090920416945092505050565b60025460009060a060020a900460ff161561148b57600080fd5b601454600160a060020a031615156114a257600080fd5b6114ac3384612b2a565b15156114b757600080fd5b601454600160a060020a0316635d12ace484844360405160e060020a63ffffffff8616028152600481019390935260248301919091526044820152606401602060405180830381600087803b151561150e57600080fd5b5af1151561151b57600080fd5b5050506040518051949350505050565b60025433600160a060020a0390811691161461154657600080fd5b60025460a060020a900460ff161561155d57600080fd5b600281101561156b57600080fd5b601055565b60105481565b60025460009033600160a060020a0390811691161461159457600080fd5b601654613a9890106115a557600080fd5b6115b860008060008a308b8b8b8b612c80565b600b549091506115d2908290600160a060020a0316612b4a565b600b54600160a060020a03166327ebe40a826115ec61301b565b662386f26fc100006202a3003060405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b151561165257600080fd5b5af1151561165f57600080fd5b50506016805460010190555050505050505050565b60005433600160a060020a0390811691161461168f57600080fd5b60025460a060020a900460ff1615156116a757600080fd5b600b54600160a060020a031615156116be57600080fd5b600c54600160a060020a031615156116d557600080fd5b6116dd6130bf565b565b600a60205260009081526040902054600160a060020a031681565b6000808080851161170a57600080fd5b6000841161171757600080fd5b600680548690811061172557fe5b9060005260206000209060030201915060068481548110151561174457fe5b9060005260206000209060030201905061176082868387613112565b801561177157506117718486613292565b95945050505050565b60025433600160a060020a0390811691161461179557600080fd5b600e55565b60025460a060020a900460ff16156117b157600080fd5b6117bb3382612b2a565b15156117c657600080fd5b6000908152600a602052604090208054600160a060020a031916600160a060020a0392909216919091179055565b60005433600160a060020a0390811691161461180f57600080fd5b600160a060020a038116151561182457600080fd5b60018054600160a060020a031916600160a060020a0392909216919091179055565b60025433600160a060020a0390811691161480611871575060005433600160a060020a039081169116145b8061188a575060015433600160a060020a039081169116145b151561189557600080fd5b60035463ffffffff1681106118a957600080fd5b600555565b60025460a060020a900460ff1681565b600154600090819033600160a060020a039081169116146118de57600080fd5b30600160a060020a0316319150600e54600f546001010290508082111561192b57600154600160a060020a031681830380156108fc0290604051600060405180830381858888f150505050505b5050565b600081815260076020526040902054600160a060020a0316801515610e3857600080fd5b613a9881565b662386f26fc1000081565b601754600160a060020a031681565b60025460009033600160a060020a0390811691161461199157600080fd5b5084600160a060020a03811615156119b15750600254600160a060020a03165b60155461138890106119c257600080fd5b6015805460010190556119dd600080808a858a8a8a8a612c80565b5050505050505050565b6000805433600160a060020a03908116911614611a0357600080fd5b5080600160a060020a0381166385b861886040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515611a4257600080fd5b5af11515611a4f57600080fd5b505050604051805190501515611a6457600080fd5b600b8054600160a060020a031916600160a060020a039290921691909117905550565b600160a060020a031660009081526008602052604090205490565b60005433600160a060020a03908116911614611abd57600080fd5b60025460a060020a900460ff161515611ad557600080fd5b60178054600160a060020a031916600160a060020a0383161790557f450db8da6efbe9c22f2347f7c2021231df1fc58d3ae9a2fa75d39fa44619930581604051600160a060020a03909116815260200160405180910390a150565b600760205260009081526040902054600160a060020a031681565b60055481565b60025433600160a060020a0390811691161480611b7c575060005433600160a060020a039081169116145b80611b95575060015433600160a060020a039081169116145b1515611ba057600080fd5b60025460a060020a900460ff1615611bb757600080fd5b6002805474ff0000000000000000000000000000000000000000191660a060020a179055565b611be56136a6565b6000611bef6136a6565b6000806000611bfd87611a87565b9450841515611c2d576000604051805910611c155750595b90808252806020026020018201604052509550611cb4565b84604051805910611c3b5750595b90808252806020026020018201604052509350611c566110ad565b925060009150600190505b828111611cb057600081815260076020526040902054600160a060020a0388811691161415611ca85780848381518110611c9757fe5b602090810290910101526001909101905b600101611c61565b8395505b5050505050919050565b600080600080600080600080600080600080600260149054906101000a900460ff16151515611cec57600080fd5b600680548e908110611cfa57fe5b600091825260209091206003909102016001810154909b5067ffffffffffffffff161515611d2757600080fd5b611e068b6101a0604051908101604090815282548252600183015467ffffffffffffffff8082166020850152680100000000000000008083049091169284019290925263ffffffff608060020a82048116606085015260a060020a82048116608085015260c060020a82041660a084015261ffff60e060020a8204811660c085015260f060020a909104811660e0840152600290930154808416610100840152620100008104841661012084015264010000000081048416610140840152660100000000000081048416610160840152049091166101808201526132e7565b1515611e1157600080fd5b60018b01546006805460c060020a90920463ffffffff169b50908b908110611e3557fe5b600091825260209091206001808e0154600390930290910190810154909a5061ffff60f060020a9283900481169a509190041688901115611e8357600189015460f060020a900461ffff1697505b6013548b548a5460018e0154600160a060020a0390931692630d9f5aed92919068010000000000000000900467ffffffffffffffff166000190160405160e060020a63ffffffff86160281526004810193909352602483019190915267ffffffffffffffff166044820152606401602060405180830381600087803b1515611f0a57600080fd5b5af11515611f1757600080fd5b505050604051805160008f815260076020526040902054909850600160a060020a03169650611f4790508d6122ed565b60ff169450611f55856122ed565b60ff169350611f63846122ed565b60ff169250611f71836122ed565b60ff169150611fa88d8c60010160189054906101000a900463ffffffff1663ffffffff168a60010161ffff168a8a8a8a8a8a612c80565b60018c0180547bffffffff00000000000000000000000000000000000000000000000019169055600f8054600019019055600e54909150600160a060020a0333169080156108fc0290604051600060405180830381858888f1935050505050809b505050505050505050505050919050565b60025460a060020a900460ff161561203157600080fd5b61203b3385612b2a565b151561204657600080fd5b61204f84612371565b151561205a57600080fd5b600c54612071908590600160a060020a0316612b4a565b600c54600160a060020a03166327ebe40a858585853360405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b151561125f57600080fd5b60025433600160a060020a039081169116148061210b575060005433600160a060020a039081169116145b80612124575060015433600160a060020a039081169116145b151561212f57600080fd5b600b54600160a060020a0316635fd8c7106040518163ffffffff1660e060020a028152600401600060405180830381600087803b151561216e57600080fd5b5af1151561217b57600080fd5b5050600c54600160a060020a03169050635fd8c7106040518163ffffffff1660e060020a028152600401600060405180830381600087803b15156121be57600080fd5b5af1151561119557600080fd5b60408051908101604052600281527f4350000000000000000000000000000000000000000000000000000000000000602082015281565b600381600e811061220f57fe5b60089182820401919006600402915054906101000a900463ffffffff1681565b600f5481565b60025460a060020a900460ff161561224c57600080fd5b600160a060020a038216151561226157600080fd5b30600160a060020a031682600160a060020a03161415151561228257600080fd5b600b54600160a060020a038381169116141561229d57600080fd5b600c54600160a060020a03838116911614156122b857600080fd5b6122c23382612b2a565b15156122cd57600080fd5b61192b338383612b98565b600254600160a060020a031681565b600e5481565b6000806001606484600143034041446040519384526020840192909252600160a060020a03166c010000000000000000000000000260408084019190915260548301919091526074909101905190819003902060ff1681151561234c57fe5b06019050606460ff821606600101915050919050565b600d54600160a060020a031681565b60008080831161238057600080fd5b600680548490811061238e57fe5b9060005260206000209060030201905061247d816101a0604051908101604090815282548252600183015467ffffffffffffffff8082166020850152680100000000000000008083049091169284019290925263ffffffff608060020a82048116606085015260a060020a82048116608085015260c060020a82041660a084015261ffff60e060020a8204811660c085015260f060020a909104811660e08401526002909301548084166101008401526201000081048416610120840152640100000000810484166101408401526601000000000000810484166101608401520490911661018082015261331f565b9392505050565b6000805433600160a060020a039081169116146124a057600080fd5b5080600160a060020a03811663100380996040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156124df57600080fd5b5af115156124ec57600080fd5b50505060405180519050151561250157600080fd5b60148054600160a060020a031916600160a060020a039290921691909117905550565b61138881565b60005433600160a060020a0390811691161461254557600080fd5b600d8054600160a060020a031916600160a060020a0392909216919091179055565b600b54600160a060020a031681565b60025460009060a060020a900460ff161561259057600080fd5b61259a3383612b2a565b15156125a557600080fd5b6125ae82612371565b15156125b957600080fd5b6125c38284613392565b15156125ce57600080fd5b600c54600160a060020a031663c55d0f568460405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561261657600080fd5b5af1151561262357600080fd5b5050506040518051600e549092508201341015905061264157600080fd5b600c54600e54600160a060020a039091169063454a2ab39034038560405160e060020a63ffffffff851602815260048101919091526024016000604051808303818588803b151561269157600080fd5b5af1151561269e57600080fd5b505050506111958263ffffffff168463ffffffff166133e1565b60165481565b601354600160a060020a031681565b600080600080600080600080600080600060068c8154811015156126ed57fe5b906000526020600020906003020190508060010160189054906101000a900463ffffffff1663ffffffff16600014159a50438160010160089054906101000a900467ffffffffffffffff1667ffffffffffffffff161115995080600101601c9054906101000a900461ffff1661ffff1698508060010160089054906101000a900467ffffffffffffffff1667ffffffffffffffff1697508060010160189054906101000a900463ffffffff1663ffffffff1696508060010160009054906101000a900467ffffffffffffffff1667ffffffffffffffff1695508060010160109054906101000a900463ffffffff1663ffffffff1694508060010160149054906101000a900463ffffffff1663ffffffff16935080600101601e9054906101000a900461ffff1661ffff16925080600001549150509193959799509193959799565b600254600090819060a060020a900460ff161561284a57600080fd5b600e5434101561285957600080fd5b6128633385612b2a565b151561286e57600080fd5b6128788385613292565b151561288357600080fd5b600680548590811061289157fe5b90600052602060002090600302019150612980826101a0604051908101604090815282548252600183015467ffffffffffffffff8082166020850152680100000000000000008083049091169284019290925263ffffffff608060020a82048116606085015260a060020a82048116608085015260c060020a82041660a084015261ffff60e060020a8204811660c085015260f060020a909104811660e08401526002909301548084166101008401526201000081048416610120840152640100000000810484166101408401526601000000000000810484166101608401520490911661018082015261331f565b151561298b57600080fd5b600680548490811061299957fe5b90600052602060002090600302019050612a88816101a0604051908101604090815282548252600183015467ffffffffffffffff8082166020850152680100000000000000008083049091169284019290925263ffffffff608060020a82048116606085015260a060020a82048116608085015260c060020a82041660a084015261ffff60e060020a8204811660c085015260f060020a909104811660e08401526002909301548084166101008401526201000081048416610120840152640100000000810484166101408401526601000000000000810484166101608401520490911661018082015261331f565b1515612a9357600080fd5b612a9f82858386613112565b1515612aaa57600080fd5b612ab484846133e1565b50505050565b600960205260009081526040902054600160a060020a031681565b612add6136a6565b612ae56136a6565b60008084604051805910612af65750595b818152601f19601f8301168101602001604052905092505060208201905084612b2082828761355d565b5090949350505050565b600090815260076020526040902054600160a060020a0391821691161490565b6000918252600960205260409091208054600160a060020a031916600160a060020a03909216919091179055565b600090815260096020526040902054600160a060020a0391821691161490565b600160a060020a03808316600081815260086020908152604080832080546001019055858352600790915290208054600160a060020a0319169091179055831615612c2b57600160a060020a03831660009081526008602090815260408083208054600019019055838352600a82528083208054600160a060020a03199081169091556009909252909120805490911690555b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef838383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a1505050565b600080612c8b6136e1565b600063ffffffff8d168d14612c9f57600080fd5b63ffffffff8c168c14612cb157600080fd5b61ffff8b168b14612cc157600080fd5b60028b049250600d8361ffff161115612cd957600d92505b6101a0604051908101604052808b81526020014267ffffffffffffffff168152602001600067ffffffffffffffff1681526020018e63ffffffff1681526020018d63ffffffff168152602001600063ffffffff1681526020018461ffff1681526020018c61ffff168152602001600061ffff1681526020018961ffff1681526020018861ffff1681526020018761ffff1681526020018661ffff168152509150600160068054806001018281612d8f919061374d565b6000928352602090922085916003020181518155602082015160018201805467ffffffffffffffff191667ffffffffffffffff9290921691909117905560408201518160010160086101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060608201518160010160106101000a81548163ffffffff021916908363ffffffff16021790555060808201518160010160146101000a81548163ffffffff021916908363ffffffff16021790555060a08201518160010160186101000a81548163ffffffff021916908363ffffffff16021790555060c082015181600101601c6101000a81548161ffff021916908361ffff16021790555060e082015181600101601e6101000a81548161ffff021916908361ffff16021790555061010082015160028201805461ffff191661ffff929092169190911790556101208201518160020160026101000a81548161ffff021916908361ffff1602179055506101408201518160020160046101000a81548161ffff021916908361ffff1602179055506101608201518160020160066101000a81548161ffff021916908361ffff1602179055506101808201516002909101805461ffff92909216680100000000000000000269ffff0000000000000000199092169190911790555003905063ffffffff81168114612f8a57600080fd5b7f0a5311bd2a6608f08a180df2ee7c5946819a649b204b554bb8e39825b2c50ad58982846060015163ffffffff16856080015163ffffffff168651604051600160a060020a03909516855260208501939093526040808501929092526060840152608083019190915260a0909101905180910390a161300b60008a83612b98565b9c9b505050505050505050505050565b600b5460009081908190600160a060020a031663eac9d94c6040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561306157600080fd5b5af1151561306e57600080fd5b50505060405180519250506fffffffffffffffffffffffffffffffff8216821461309757600080fd5b5060028104810167016345785d8a00008110156130b9575067016345785d8a00005b92915050565b60005433600160a060020a039081169116146130da57600080fd5b60025460a060020a900460ff1615156130f257600080fd5b6002805474ff000000000000000000000000000000000000000019169055565b6000818414156131245750600061328a565b6001850154608060020a900463ffffffff168214806131535750600185015460a060020a900463ffffffff1682145b156131605750600061328a565b6001830154608060020a900463ffffffff1684148061318f5750600183015460a060020a900463ffffffff1684145b1561319c5750600061328a565b6001830154608060020a900463ffffffff1615806131c957506001850154608060020a900463ffffffff16155b156131d65750600161328a565b60018581015490840154608060020a9182900463ffffffff90811692909104161480613221575060018086015490840154608060020a900463ffffffff90811660a060020a90920416145b1561322e5750600061328a565b6001808601549084015460a060020a900463ffffffff908116608060020a90920416148061327957506001858101549084015460a060020a9182900463ffffffff9081169290910416145b156132865750600061328a565b5060015b949350505050565b6000818152600760205260408082205484835290822054600160a060020a0391821691168082148061177157506000858152600a6020526040902054600160a060020a03908116908316149250505092915050565b60008160a0015163ffffffff1615801590610e3557504367ffffffffffffffff16826040015167ffffffffffffffff16111592915050565b60008060008360e0015160020261ffff166011540391506010548210156133465760105491505b8184610100015161ffff161090508360a0015163ffffffff1615801561338457504367ffffffffffffffff16846040015167ffffffffffffffff1611155b801561328a57509392505050565b60008060006006858154811015156133a657fe5b906000526020600020906003020191506006848154811015156133c557fe5b9060005260206000209060030201905061177182868387613112565b6000806006838154811015156133f357fe5b9060005260206000209060030201915060068481548110151561341257fe5b600091825260209091206003909102016001810180547bffffffff000000000000000000000000000000000000000000000000191660c060020a63ffffffff8716021790559050613462826135a2565b61346b816135a2565b6134748261368b565b61347d8161368b565b6000848152600a602090815260408083208054600160a060020a031990811690915586845281842080549091169055600f8054600190810190915587845260079092529182902054908301547f241ea03ca20251805084d27d4440371c34a0b85ff108f6bb5611248f73818b8092600160a060020a0390921691879187916801000000000000000090910467ffffffffffffffff1690518085600160a060020a0316600160a060020a031681526020018481526020018381526020018267ffffffffffffffff16815260200194505050505060405180910390a150505050565b60005b602082106135835782518452602084019350602083019250602082039150613560565b6001826020036101000a03905080198351168185511617909352505050565b600554600182015443919060039060e060020a900461ffff16600e81106135c557fe5b600891828204019190066004029054906101000a900463ffffffff1663ffffffff168115156135f057fe5b6001840180546fffffffffffffffff0000000000000000191668010000000000000000939092049390930167ffffffffffffffff16919091021790819055600d60e060020a90910461ffff161015613688576001818101805461ffff60e060020a8083048216909401169092027fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092169190911790555b50565b600201805461ffff8082166001011661ffff19909116179055565b60206040519081016040526000815290565b60806040519081016040526004815b600081526000199190910190602001816136c75790505090565b6101a06040519081016040908152600080835260208301819052908201819052606082018190526080820181905260a0820181905260c0820181905260e08201819052610100820181905261012082018190526101408201819052610160820181905261018082015290565b81548183558181111561119557600083815260209020611195916110b59160039182028101918502015b808211156137a6576000808255600182015560028101805469ffffffffffffffffffff19169055600301613777565b50905600a165627a7a723058206f9f0662bdd35fc92831674806f157c1850e70836c1bf50ce42ef418efa516500029

Deployed Bytecode

0x6060604052600436106103135763ffffffff60e060020a60003504166301ffc9a7811461034b5780630519ce79146103975780630560ff44146103c657806305e455461461045f57806306fdde031461048457806308595e5e14610497578063095ea7b3146104aa5780630a0f8168146104cc5780630e583df0146104df57806314001f4c146104f257806318160ddd146105115780631940a9361461052457806319c2f2011461053a57806321717ebf1461054d57806323b872dd1461056057806324280cc41461058857806324e7a38a146105a757806327d7874c146105c65780632ba73c15146105e55780632cf5fe89146106045780632eae0018146106175780633268215c1461062d57806334825a231461067c57806337621da0146106955780633790613f146106ab5780633ac9a77a146106be5780633f4ba83a146106f357806346116e6f1461070657806346d22c701461071c5780634b85fd55146107355780634dfff04f1461074b5780634e0a33791461076d5780635663896e1461078c5780635c975abb146107a25780635fd8c710146107b55780636352211e146107c8578063680eba27146107de57806368f2d6e2146107f15780636af04a57146108045780636b7d9a5c146108175780636fbde40d1461085257806370a0823114610871578063715879881461089057806379b4fd55146108af5780637a7d4937146108c55780638456cb59146108d85780638462151c146108eb57806388c2a0bf1461095d5780638b587b821461096857806391876e571461098757806395d89b411461099a5780639d6fac6f146109ad578063a4acbcd6146109dc578063a9059cbb146109ef578063b047fb5014610a11578063b0c35c0514610a24578063b863bd3714610a37578063bc4006f514610a63578063d3e6f49f14610a76578063da24e40214610a8c578063defb958414610aab578063e17b25af14610abe578063e6cbe35114610add578063ed60ade614610af0578063f1ca941014610afe578063f2b47d5214610b11578063f36c83f014610b24578063f7d8c88314610b92578063ff139dfb14610ba0575b600b5433600160a060020a039081169116148061033e5750600c5433600160a060020a039081169116145b151561034957600080fd5b005b341561035657600080fd5b6103837fffffffff0000000000000000000000000000000000000000000000000000000060043516610bb6565b604051901515815260200160405180910390f35b34156103a257600080fd5b6103aa610e3d565b604051600160a060020a03909116815260200160405180910390f35b34156103d157600080fd5b6103e8600480359060248035908101910135610e4c565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561042457808201518382015260200161040c565b50505050905090810190601f1680156104515780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561046a57600080fd5b610472610f1c565b60405190815260200160405180910390f35b341561048f57600080fd5b6103e8610f22565b34156104a257600080fd5b6103aa610f59565b34156104b557600080fd5b610349600160a060020a0360043516602435610f68565b34156104d757600080fd5b6103aa610ff2565b34156104ea57600080fd5b610472611001565b34156104fd57600080fd5b610349600160a060020a036004351661100d565b341561051c57600080fd5b6104726110ad565b341561052f57600080fd5b6103836004356110b8565b341561054557600080fd5b6104726110fd565b341561055857600080fd5b6103aa611104565b341561056b57600080fd5b610349600160a060020a0360043581169060243516604435611113565b341561059357600080fd5b61034960043560243560443560643561119a565b34156105b257600080fd5b610349600160a060020a0360043516611275565b34156105d157600080fd5b610349600160a060020a0360043516611315565b34156105f057600080fd5b610349600160a060020a0360043516611367565b341561060f57600080fd5b6104726113b9565b341561062257600080fd5b6103496004356113bf565b341561063857600080fd5b610643600435611404565b60405161ffff9586168152938516602085015291841660408085019190915290841660608401529216608082015260a001905180910390f35b341561068757600080fd5b610383600435602435611471565b34156106a057600080fd5b61034960043561152b565b34156106b657600080fd5b610472611570565b34156106c957600080fd5b61034960043561ffff60243581169060443581169060643581169060843581169060a43516611576565b34156106fe57600080fd5b610349611674565b341561071157600080fd5b6103aa6004356116df565b341561072757600080fd5b6103836004356024356116fa565b341561074057600080fd5b61034960043561177a565b341561075657600080fd5b610349600160a060020a036004351660243561179a565b341561077857600080fd5b610349600160a060020a03600435166117f4565b341561079757600080fd5b610349600435611846565b34156107ad57600080fd5b6103836118ae565b34156107c057600080fd5b6103496118be565b34156107d357600080fd5b6103aa60043561192f565b34156107e957600080fd5b610472611953565b34156107fc57600080fd5b610472611959565b341561080f57600080fd5b6103aa611964565b341561082257600080fd5b610349600435600160a060020a036024351661ffff60443581169060643581169060843581169060a43516611973565b341561085d57600080fd5b610349600160a060020a03600435166119e7565b341561087c57600080fd5b610472600160a060020a0360043516611a87565b341561089b57600080fd5b610349600160a060020a0360043516611aa2565b34156108ba57600080fd5b6103aa600435611b30565b34156108d057600080fd5b610472611b4b565b34156108e357600080fd5b610349611b51565b34156108f657600080fd5b61090a600160a060020a0360043516611bdd565b60405160208082528190810183818151815260200191508051906020019060200280838360005b83811015610949578082015183820152602001610931565b505050509050019250505060405180910390f35b610472600435611cbe565b341561097357600080fd5b61034960043560243560443560643561201a565b341561099257600080fd5b6103496120e0565b34156109a557600080fd5b6103e86121cb565b34156109b857600080fd5b6109c3600435612202565b60405163ffffffff909116815260200160405180910390f35b34156109e757600080fd5b61047261222f565b34156109fa57600080fd5b610349600160a060020a0360043516602435612235565b3415610a1c57600080fd5b6103aa6122d8565b3415610a2f57600080fd5b6104726122e7565b3415610a4257600080fd5b610a4d6004356122ed565b60405160ff909116815260200160405180910390f35b3415610a6e57600080fd5b6103aa612362565b3415610a8157600080fd5b610383600435612371565b3415610a9757600080fd5b610349600160a060020a0360043516612484565b3415610ab657600080fd5b610472612524565b3415610ac957600080fd5b610349600160a060020a036004351661252a565b3415610ae857600080fd5b6103aa612567565b610349600435602435612576565b3415610b0957600080fd5b6104726126b8565b3415610b1c57600080fd5b6103aa6126be565b3415610b2f57600080fd5b610b3a6004356126cd565b6040519915158a5297151560208a01526040808a01979097526060890195909552608088019390935260a087019190915260c086015260e0850152610100840152610120830191909152610140909101905180910390f35b61034960043560243561282e565b3415610bab57600080fd5b6103aa600435612aba565b60006040517f737570706f727473496e7465726661636528627974657334290000000000000081526019016040518091039020600160e060020a03191682600160e060020a0319161480610e3557506040517f746f6b656e4d657461646174612875696e743235362c737472696e67290000008152601d0160405180910390206040517f746f6b656e734f664f776e657228616464726573732900000000000000000000815260160160405180910390206040517f7472616e7366657246726f6d28616464726573732c616464726573732c75696e81527f7432353629000000000000000000000000000000000000000000000000000000602082015260250160405180910390206040517f7472616e7366657228616464726573732c75696e743235362900000000000000815260190160405180910390206040517f617070726f766528616464726573732c75696e74323536290000000000000000815260180160405180910390206040517f6f776e65724f662875696e743235362900000000000000000000000000000000815260100160405180910390206040517f62616c616e63654f662861646472657373290000000000000000000000000000815260120160405180910390206040517f746f74616c537570706c792829000000000000000000000000000000000000008152600d0160405180910390206040517f73796d626f6c2829000000000000000000000000000000000000000000000000815260080160405180910390206040517f6e616d652829000000000000000000000000000000000000000000000000000081526006016040518091039020181818181818181818600160e060020a03191682600160e060020a031916145b90505b919050565b600154600160a060020a031681565b610e546136a6565b610e5c6136b8565b600d54600090600160a060020a03161515610e7657600080fd5b600d54600160a060020a031663cb4799f287878760405160e060020a63ffffffff861602815260048101848152604060248301908152604483018490529091606401848480828437820191505094505050505060a060405180830381600087803b1515610ee257600080fd5b5af11515610eef57600080fd5b50505060405180608001805160209091016040529092509050610f128282612ad5565b9695505050505050565b60155481565b60408051908101604052600d81527f43727970746f5075707069657300000000000000000000000000000000000000602082015281565b601454600160a060020a031681565b60025460a060020a900460ff1615610f7f57600080fd5b610f893382612b2a565b1515610f9457600080fd5b610f9e8183612b4a565b7f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925338383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a15050565b600054600160a060020a031681565b67016345785d8a000081565b6000805433600160a060020a0390811691161461102957600080fd5b5080600160a060020a0381166376190f8f6040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561106857600080fd5b5af1151561107557600080fd5b50505060405180519050151561108a57600080fd5b600c8054600160a060020a031916600160a060020a039290921691909117905550565b600654600019015b90565b60008082116110c657600080fd5b60068054839081106110d457fe5b600091825260209091206003909102016001015460c060020a900463ffffffff16151592915050565b6202a30081565b600c54600160a060020a031681565b60025460a060020a900460ff161561112a57600080fd5b600160a060020a038216151561113f57600080fd5b30600160a060020a031682600160a060020a03161415151561116057600080fd5b61116a3382612b78565b151561117557600080fd5b61117f8382612b2a565b151561118a57600080fd5b611195838383612b98565b505050565b60025460a060020a900460ff16156111b157600080fd5b6111bb3385612b2a565b15156111c657600080fd5b6111cf846110b8565b156111d957600080fd5b600b546111f0908590600160a060020a0316612b4a565b600b54600160a060020a03166327ebe40a858585853360405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b151561125f57600080fd5b5af1151561126c57600080fd5b50505050505050565b6000805433600160a060020a0390811691161461129157600080fd5b5080600160a060020a0381166354c15b826040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156112d057600080fd5b5af115156112dd57600080fd5b5050506040518051905015156112f257600080fd5b60138054600160a060020a031916600160a060020a039290921691909117905550565b60005433600160a060020a0390811691161461133057600080fd5b600160a060020a038116151561134557600080fd5b60008054600160a060020a031916600160a060020a0392909216919091179055565b60005433600160a060020a0390811691161461138257600080fd5b600160a060020a038116151561139757600080fd5b60028054600160a060020a031916600160a060020a0392909216919091179055565b60115481565b60025433600160a060020a039081169116146113da57600080fd5b60025460a060020a900460ff16156113f157600080fd5b60105481116113ff57600080fd5b601155565b60008060008060008060068781548110151561141c57fe5b600091825260209091206002600390920201015461ffff808216996201000083048216995064010000000083048216985066010000000000008304821697506801000000000000000090920416945092505050565b60025460009060a060020a900460ff161561148b57600080fd5b601454600160a060020a031615156114a257600080fd5b6114ac3384612b2a565b15156114b757600080fd5b601454600160a060020a0316635d12ace484844360405160e060020a63ffffffff8616028152600481019390935260248301919091526044820152606401602060405180830381600087803b151561150e57600080fd5b5af1151561151b57600080fd5b5050506040518051949350505050565b60025433600160a060020a0390811691161461154657600080fd5b60025460a060020a900460ff161561155d57600080fd5b600281101561156b57600080fd5b601055565b60105481565b60025460009033600160a060020a0390811691161461159457600080fd5b601654613a9890106115a557600080fd5b6115b860008060008a308b8b8b8b612c80565b600b549091506115d2908290600160a060020a0316612b4a565b600b54600160a060020a03166327ebe40a826115ec61301b565b662386f26fc100006202a3003060405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b151561165257600080fd5b5af1151561165f57600080fd5b50506016805460010190555050505050505050565b60005433600160a060020a0390811691161461168f57600080fd5b60025460a060020a900460ff1615156116a757600080fd5b600b54600160a060020a031615156116be57600080fd5b600c54600160a060020a031615156116d557600080fd5b6116dd6130bf565b565b600a60205260009081526040902054600160a060020a031681565b6000808080851161170a57600080fd5b6000841161171757600080fd5b600680548690811061172557fe5b9060005260206000209060030201915060068481548110151561174457fe5b9060005260206000209060030201905061176082868387613112565b801561177157506117718486613292565b95945050505050565b60025433600160a060020a0390811691161461179557600080fd5b600e55565b60025460a060020a900460ff16156117b157600080fd5b6117bb3382612b2a565b15156117c657600080fd5b6000908152600a602052604090208054600160a060020a031916600160a060020a0392909216919091179055565b60005433600160a060020a0390811691161461180f57600080fd5b600160a060020a038116151561182457600080fd5b60018054600160a060020a031916600160a060020a0392909216919091179055565b60025433600160a060020a0390811691161480611871575060005433600160a060020a039081169116145b8061188a575060015433600160a060020a039081169116145b151561189557600080fd5b60035463ffffffff1681106118a957600080fd5b600555565b60025460a060020a900460ff1681565b600154600090819033600160a060020a039081169116146118de57600080fd5b30600160a060020a0316319150600e54600f546001010290508082111561192b57600154600160a060020a031681830380156108fc0290604051600060405180830381858888f150505050505b5050565b600081815260076020526040902054600160a060020a0316801515610e3857600080fd5b613a9881565b662386f26fc1000081565b601754600160a060020a031681565b60025460009033600160a060020a0390811691161461199157600080fd5b5084600160a060020a03811615156119b15750600254600160a060020a03165b60155461138890106119c257600080fd5b6015805460010190556119dd600080808a858a8a8a8a612c80565b5050505050505050565b6000805433600160a060020a03908116911614611a0357600080fd5b5080600160a060020a0381166385b861886040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515611a4257600080fd5b5af11515611a4f57600080fd5b505050604051805190501515611a6457600080fd5b600b8054600160a060020a031916600160a060020a039290921691909117905550565b600160a060020a031660009081526008602052604090205490565b60005433600160a060020a03908116911614611abd57600080fd5b60025460a060020a900460ff161515611ad557600080fd5b60178054600160a060020a031916600160a060020a0383161790557f450db8da6efbe9c22f2347f7c2021231df1fc58d3ae9a2fa75d39fa44619930581604051600160a060020a03909116815260200160405180910390a150565b600760205260009081526040902054600160a060020a031681565b60055481565b60025433600160a060020a0390811691161480611b7c575060005433600160a060020a039081169116145b80611b95575060015433600160a060020a039081169116145b1515611ba057600080fd5b60025460a060020a900460ff1615611bb757600080fd5b6002805474ff0000000000000000000000000000000000000000191660a060020a179055565b611be56136a6565b6000611bef6136a6565b6000806000611bfd87611a87565b9450841515611c2d576000604051805910611c155750595b90808252806020026020018201604052509550611cb4565b84604051805910611c3b5750595b90808252806020026020018201604052509350611c566110ad565b925060009150600190505b828111611cb057600081815260076020526040902054600160a060020a0388811691161415611ca85780848381518110611c9757fe5b602090810290910101526001909101905b600101611c61565b8395505b5050505050919050565b600080600080600080600080600080600080600260149054906101000a900460ff16151515611cec57600080fd5b600680548e908110611cfa57fe5b600091825260209091206003909102016001810154909b5067ffffffffffffffff161515611d2757600080fd5b611e068b6101a0604051908101604090815282548252600183015467ffffffffffffffff8082166020850152680100000000000000008083049091169284019290925263ffffffff608060020a82048116606085015260a060020a82048116608085015260c060020a82041660a084015261ffff60e060020a8204811660c085015260f060020a909104811660e0840152600290930154808416610100840152620100008104841661012084015264010000000081048416610140840152660100000000000081048416610160840152049091166101808201526132e7565b1515611e1157600080fd5b60018b01546006805460c060020a90920463ffffffff169b50908b908110611e3557fe5b600091825260209091206001808e0154600390930290910190810154909a5061ffff60f060020a9283900481169a509190041688901115611e8357600189015460f060020a900461ffff1697505b6013548b548a5460018e0154600160a060020a0390931692630d9f5aed92919068010000000000000000900467ffffffffffffffff166000190160405160e060020a63ffffffff86160281526004810193909352602483019190915267ffffffffffffffff166044820152606401602060405180830381600087803b1515611f0a57600080fd5b5af11515611f1757600080fd5b505050604051805160008f815260076020526040902054909850600160a060020a03169650611f4790508d6122ed565b60ff169450611f55856122ed565b60ff169350611f63846122ed565b60ff169250611f71836122ed565b60ff169150611fa88d8c60010160189054906101000a900463ffffffff1663ffffffff168a60010161ffff168a8a8a8a8a8a612c80565b60018c0180547bffffffff00000000000000000000000000000000000000000000000019169055600f8054600019019055600e54909150600160a060020a0333169080156108fc0290604051600060405180830381858888f1935050505050809b505050505050505050505050919050565b60025460a060020a900460ff161561203157600080fd5b61203b3385612b2a565b151561204657600080fd5b61204f84612371565b151561205a57600080fd5b600c54612071908590600160a060020a0316612b4a565b600c54600160a060020a03166327ebe40a858585853360405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b151561125f57600080fd5b60025433600160a060020a039081169116148061210b575060005433600160a060020a039081169116145b80612124575060015433600160a060020a039081169116145b151561212f57600080fd5b600b54600160a060020a0316635fd8c7106040518163ffffffff1660e060020a028152600401600060405180830381600087803b151561216e57600080fd5b5af1151561217b57600080fd5b5050600c54600160a060020a03169050635fd8c7106040518163ffffffff1660e060020a028152600401600060405180830381600087803b15156121be57600080fd5b5af1151561119557600080fd5b60408051908101604052600281527f4350000000000000000000000000000000000000000000000000000000000000602082015281565b600381600e811061220f57fe5b60089182820401919006600402915054906101000a900463ffffffff1681565b600f5481565b60025460a060020a900460ff161561224c57600080fd5b600160a060020a038216151561226157600080fd5b30600160a060020a031682600160a060020a03161415151561228257600080fd5b600b54600160a060020a038381169116141561229d57600080fd5b600c54600160a060020a03838116911614156122b857600080fd5b6122c23382612b2a565b15156122cd57600080fd5b61192b338383612b98565b600254600160a060020a031681565b600e5481565b6000806001606484600143034041446040519384526020840192909252600160a060020a03166c010000000000000000000000000260408084019190915260548301919091526074909101905190819003902060ff1681151561234c57fe5b06019050606460ff821606600101915050919050565b600d54600160a060020a031681565b60008080831161238057600080fd5b600680548490811061238e57fe5b9060005260206000209060030201905061247d816101a0604051908101604090815282548252600183015467ffffffffffffffff8082166020850152680100000000000000008083049091169284019290925263ffffffff608060020a82048116606085015260a060020a82048116608085015260c060020a82041660a084015261ffff60e060020a8204811660c085015260f060020a909104811660e08401526002909301548084166101008401526201000081048416610120840152640100000000810484166101408401526601000000000000810484166101608401520490911661018082015261331f565b9392505050565b6000805433600160a060020a039081169116146124a057600080fd5b5080600160a060020a03811663100380996040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156124df57600080fd5b5af115156124ec57600080fd5b50505060405180519050151561250157600080fd5b60148054600160a060020a031916600160a060020a039290921691909117905550565b61138881565b60005433600160a060020a0390811691161461254557600080fd5b600d8054600160a060020a031916600160a060020a0392909216919091179055565b600b54600160a060020a031681565b60025460009060a060020a900460ff161561259057600080fd5b61259a3383612b2a565b15156125a557600080fd5b6125ae82612371565b15156125b957600080fd5b6125c38284613392565b15156125ce57600080fd5b600c54600160a060020a031663c55d0f568460405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561261657600080fd5b5af1151561262357600080fd5b5050506040518051600e549092508201341015905061264157600080fd5b600c54600e54600160a060020a039091169063454a2ab39034038560405160e060020a63ffffffff851602815260048101919091526024016000604051808303818588803b151561269157600080fd5b5af1151561269e57600080fd5b505050506111958263ffffffff168463ffffffff166133e1565b60165481565b601354600160a060020a031681565b600080600080600080600080600080600060068c8154811015156126ed57fe5b906000526020600020906003020190508060010160189054906101000a900463ffffffff1663ffffffff16600014159a50438160010160089054906101000a900467ffffffffffffffff1667ffffffffffffffff161115995080600101601c9054906101000a900461ffff1661ffff1698508060010160089054906101000a900467ffffffffffffffff1667ffffffffffffffff1697508060010160189054906101000a900463ffffffff1663ffffffff1696508060010160009054906101000a900467ffffffffffffffff1667ffffffffffffffff1695508060010160109054906101000a900463ffffffff1663ffffffff1694508060010160149054906101000a900463ffffffff1663ffffffff16935080600101601e9054906101000a900461ffff1661ffff16925080600001549150509193959799509193959799565b600254600090819060a060020a900460ff161561284a57600080fd5b600e5434101561285957600080fd5b6128633385612b2a565b151561286e57600080fd5b6128788385613292565b151561288357600080fd5b600680548590811061289157fe5b90600052602060002090600302019150612980826101a0604051908101604090815282548252600183015467ffffffffffffffff8082166020850152680100000000000000008083049091169284019290925263ffffffff608060020a82048116606085015260a060020a82048116608085015260c060020a82041660a084015261ffff60e060020a8204811660c085015260f060020a909104811660e08401526002909301548084166101008401526201000081048416610120840152640100000000810484166101408401526601000000000000810484166101608401520490911661018082015261331f565b151561298b57600080fd5b600680548490811061299957fe5b90600052602060002090600302019050612a88816101a0604051908101604090815282548252600183015467ffffffffffffffff8082166020850152680100000000000000008083049091169284019290925263ffffffff608060020a82048116606085015260a060020a82048116608085015260c060020a82041660a084015261ffff60e060020a8204811660c085015260f060020a909104811660e08401526002909301548084166101008401526201000081048416610120840152640100000000810484166101408401526601000000000000810484166101608401520490911661018082015261331f565b1515612a9357600080fd5b612a9f82858386613112565b1515612aaa57600080fd5b612ab484846133e1565b50505050565b600960205260009081526040902054600160a060020a031681565b612add6136a6565b612ae56136a6565b60008084604051805910612af65750595b818152601f19601f8301168101602001604052905092505060208201905084612b2082828761355d565b5090949350505050565b600090815260076020526040902054600160a060020a0391821691161490565b6000918252600960205260409091208054600160a060020a031916600160a060020a03909216919091179055565b600090815260096020526040902054600160a060020a0391821691161490565b600160a060020a03808316600081815260086020908152604080832080546001019055858352600790915290208054600160a060020a0319169091179055831615612c2b57600160a060020a03831660009081526008602090815260408083208054600019019055838352600a82528083208054600160a060020a03199081169091556009909252909120805490911690555b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef838383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a1505050565b600080612c8b6136e1565b600063ffffffff8d168d14612c9f57600080fd5b63ffffffff8c168c14612cb157600080fd5b61ffff8b168b14612cc157600080fd5b60028b049250600d8361ffff161115612cd957600d92505b6101a0604051908101604052808b81526020014267ffffffffffffffff168152602001600067ffffffffffffffff1681526020018e63ffffffff1681526020018d63ffffffff168152602001600063ffffffff1681526020018461ffff1681526020018c61ffff168152602001600061ffff1681526020018961ffff1681526020018861ffff1681526020018761ffff1681526020018661ffff168152509150600160068054806001018281612d8f919061374d565b6000928352602090922085916003020181518155602082015160018201805467ffffffffffffffff191667ffffffffffffffff9290921691909117905560408201518160010160086101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060608201518160010160106101000a81548163ffffffff021916908363ffffffff16021790555060808201518160010160146101000a81548163ffffffff021916908363ffffffff16021790555060a08201518160010160186101000a81548163ffffffff021916908363ffffffff16021790555060c082015181600101601c6101000a81548161ffff021916908361ffff16021790555060e082015181600101601e6101000a81548161ffff021916908361ffff16021790555061010082015160028201805461ffff191661ffff929092169190911790556101208201518160020160026101000a81548161ffff021916908361ffff1602179055506101408201518160020160046101000a81548161ffff021916908361ffff1602179055506101608201518160020160066101000a81548161ffff021916908361ffff1602179055506101808201516002909101805461ffff92909216680100000000000000000269ffff0000000000000000199092169190911790555003905063ffffffff81168114612f8a57600080fd5b7f0a5311bd2a6608f08a180df2ee7c5946819a649b204b554bb8e39825b2c50ad58982846060015163ffffffff16856080015163ffffffff168651604051600160a060020a03909516855260208501939093526040808501929092526060840152608083019190915260a0909101905180910390a161300b60008a83612b98565b9c9b505050505050505050505050565b600b5460009081908190600160a060020a031663eac9d94c6040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561306157600080fd5b5af1151561306e57600080fd5b50505060405180519250506fffffffffffffffffffffffffffffffff8216821461309757600080fd5b5060028104810167016345785d8a00008110156130b9575067016345785d8a00005b92915050565b60005433600160a060020a039081169116146130da57600080fd5b60025460a060020a900460ff1615156130f257600080fd5b6002805474ff000000000000000000000000000000000000000019169055565b6000818414156131245750600061328a565b6001850154608060020a900463ffffffff168214806131535750600185015460a060020a900463ffffffff1682145b156131605750600061328a565b6001830154608060020a900463ffffffff1684148061318f5750600183015460a060020a900463ffffffff1684145b1561319c5750600061328a565b6001830154608060020a900463ffffffff1615806131c957506001850154608060020a900463ffffffff16155b156131d65750600161328a565b60018581015490840154608060020a9182900463ffffffff90811692909104161480613221575060018086015490840154608060020a900463ffffffff90811660a060020a90920416145b1561322e5750600061328a565b6001808601549084015460a060020a900463ffffffff908116608060020a90920416148061327957506001858101549084015460a060020a9182900463ffffffff9081169290910416145b156132865750600061328a565b5060015b949350505050565b6000818152600760205260408082205484835290822054600160a060020a0391821691168082148061177157506000858152600a6020526040902054600160a060020a03908116908316149250505092915050565b60008160a0015163ffffffff1615801590610e3557504367ffffffffffffffff16826040015167ffffffffffffffff16111592915050565b60008060008360e0015160020261ffff166011540391506010548210156133465760105491505b8184610100015161ffff161090508360a0015163ffffffff1615801561338457504367ffffffffffffffff16846040015167ffffffffffffffff1611155b801561328a57509392505050565b60008060006006858154811015156133a657fe5b906000526020600020906003020191506006848154811015156133c557fe5b9060005260206000209060030201905061177182868387613112565b6000806006838154811015156133f357fe5b9060005260206000209060030201915060068481548110151561341257fe5b600091825260209091206003909102016001810180547bffffffff000000000000000000000000000000000000000000000000191660c060020a63ffffffff8716021790559050613462826135a2565b61346b816135a2565b6134748261368b565b61347d8161368b565b6000848152600a602090815260408083208054600160a060020a031990811690915586845281842080549091169055600f8054600190810190915587845260079092529182902054908301547f241ea03ca20251805084d27d4440371c34a0b85ff108f6bb5611248f73818b8092600160a060020a0390921691879187916801000000000000000090910467ffffffffffffffff1690518085600160a060020a0316600160a060020a031681526020018481526020018381526020018267ffffffffffffffff16815260200194505050505060405180910390a150505050565b60005b602082106135835782518452602084019350602083019250602082039150613560565b6001826020036101000a03905080198351168185511617909352505050565b600554600182015443919060039060e060020a900461ffff16600e81106135c557fe5b600891828204019190066004029054906101000a900463ffffffff1663ffffffff168115156135f057fe5b6001840180546fffffffffffffffff0000000000000000191668010000000000000000939092049390930167ffffffffffffffff16919091021790819055600d60e060020a90910461ffff161015613688576001818101805461ffff60e060020a8083048216909401169092027fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092169190911790555b50565b600201805461ffff8082166001011661ffff19909116179055565b60206040519081016040526000815290565b60806040519081016040526004815b600081526000199190910190602001816136c75790505090565b6101a06040519081016040908152600080835260208301819052908201819052606082018190526080820181905260a0820181905260c0820181905260e08201819052610100820181905261012082018190526101408201819052610160820181905261018082015290565b81548183558181111561119557600083815260209020611195916110b59160039182028101918502015b808211156137a6576000808255600182015560028101805469ffffffffffffffffffff19169055600301613777565b50905600a165627a7a723058206f9f0662bdd35fc92831674806f157c1850e70836c1bf50ce42ef418efa516500029

Swarm Source

bzzr://6f9f0662bdd35fc92831674806f157c1850e70836c1bf50ce42ef418efa51650

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

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.