ETH Price: $3,992.02 (+2.12%)

Contract

0x74cD98fBD837Fe9200Cf867F4B1ba9573c6D865e
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Give Birth57795312018-06-13 3:44:072378 days ago1528861447IN
0x74cD98fB...73c6D865e
0 ETH0.0002283510
Bid On Sale Auct...57719322018-06-11 19:34:132379 days ago1528745653IN
0x74cD98fB...73c6D865e
0.2005 ETH0.000022931
Give Birth57455862018-06-07 3:34:552384 days ago1528342495IN
0x74cD98fB...73c6D865e
0 ETH0.0002283510
Give Birth57426122018-06-06 14:54:412385 days ago1528296881IN
0x74cD98fB...73c6D865e
0 ETH0.0002283510
Give Birth57425442018-06-06 14:37:572385 days ago1528295877IN
0x74cD98fB...73c6D865e
0 ETH0.0002518811
Give Birth57425352018-06-06 14:35:512385 days ago1528295751IN
0x74cD98fB...73c6D865e
0 ETH0.0002747812
Breed With Auto57281522018-06-04 1:25:402387 days ago1528075540IN
0x74cD98fB...73c6D865e
0.003 ETH0.000049162.1
Breed With Auto57198052018-06-02 13:40:172389 days ago1527946817IN
0x74cD98fB...73c6D865e
0.003 ETH0.0003043413
Give Birth57198022018-06-02 13:39:072389 days ago1527946747IN
0x74cD98fB...73c6D865e
0 ETH0.000114175
Bid On Sale Auct...57175702018-06-02 4:09:112389 days ago1527912551IN
0x74cD98fB...73c6D865e
0.1005 ETH0.000160577
Give Birth57175672018-06-02 4:08:322389 days ago1527912512IN
0x74cD98fB...73c6D865e
0 ETH0.0003071513.45120111
Bid On Sale Auct...57175642018-06-02 4:07:362389 days ago1527912456IN
0x74cD98fB...73c6D865e
0.1005 ETH0.000137636
Set Variation Ad...57068712018-05-31 6:41:182391 days ago1527748878IN
0x74cD98fB...73c6D865e
0 ETH0.0006386820
Bid On Sale Auct...57058952018-05-31 2:24:442391 days ago1527733484IN
0x74cD98fB...73c6D865e
0.1005 ETH0.0003440815
Bid On Sale Auct...57058932018-05-31 2:23:562391 days ago1527733436IN
0x74cD98fB...73c6D865e
0.1005 ETH0.000160577
Give Birth57054672018-05-31 0:38:262391 days ago1527727106IN
0x74cD98fB...73c6D865e
0 ETH0.000182688
Give Birth57053862018-05-31 0:17:322391 days ago1527725852IN
0x74cD98fB...73c6D865e
0 ETH0.0002511811
Give Birth57053832018-05-31 0:16:032391 days ago1527725763IN
0x74cD98fB...73c6D865e
0 ETH0.000207799.1
Breed With Auto57053742018-05-31 0:13:532391 days ago1527725633IN
0x74cD98fB...73c6D865e
0.003 ETH0.000187288
Breed With Auto57053572018-05-31 0:08:522391 days ago1527725332IN
0x74cD98fB...73c6D865e
0.003 ETH0.0002575211
Breed With Auto57053502018-05-31 0:06:522391 days ago1527725212IN
0x74cD98fB...73c6D865e
0.003 ETH0.000187288
Give Birth57052862018-05-30 23:52:462391 days ago1527724366IN
0x74cD98fB...73c6D865e
0 ETH0.000183198
Breed With Auto57052592018-05-30 23:46:322391 days ago1527723992IN
0x74cD98fB...73c6D865e
0.003 ETH0.000187288
Give Birth57019522018-05-30 9:38:112392 days ago1527673091IN
0x74cD98fB...73c6D865e
0 ETH0.0003434815
Pause57019522018-05-30 9:38:112392 days ago1527673091IN
0x74cD98fB...73c6D865e
0 ETH0.0004320615
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block
From
To
57068762018-05-31 6:43:132391 days ago1527748993
0x74cD98fB...73c6D865e
10.81735359 ETH
57018382018-05-30 9:05:412392 days ago1527671141
0x74cD98fB...73c6D865e
0.0005 ETH
57018382018-05-30 9:05:412392 days ago1527671141
0x74cD98fB...73c6D865e
1.28 ETH
57018382018-05-30 9:05:412392 days ago1527671141
0x74cD98fB...73c6D865e
4.88 ETH
57017702018-05-30 8:47:352392 days ago1527670055
0x74cD98fB...73c6D865e
0.003 ETH
57017652018-05-30 8:45:362392 days ago1527669936
0x74cD98fB...73c6D865e
0.0005 ETH
57017652018-05-30 8:45:362392 days ago1527669936
0x74cD98fB...73c6D865e
0.09625 ETH
57017652018-05-30 8:45:362392 days ago1527669936
0x74cD98fB...73c6D865e
0.09625 ETH
57017622018-05-30 8:45:092392 days ago1527669909
0x74cD98fB...73c6D865e
0.0005 ETH
57017622018-05-30 8:45:092392 days ago1527669909
0x74cD98fB...73c6D865e
0.09625 ETH
57017622018-05-30 8:45:092392 days ago1527669909
0x74cD98fB...73c6D865e
0.09625 ETH
57017552018-05-30 8:43:232392 days ago1527669803
0x74cD98fB...73c6D865e
0.003 ETH
57013392018-05-30 6:55:392392 days ago1527663339
0x74cD98fB...73c6D865e
0.003 ETH
57012912018-05-30 6:41:242392 days ago1527662484
0x74cD98fB...73c6D865e
0.0005 ETH
57012912018-05-30 6:41:242392 days ago1527662484
0x74cD98fB...73c6D865e
0.003 ETH
57012702018-05-30 6:35:012392 days ago1527662101
0x74cD98fB...73c6D865e
0.0005 ETH
57012702018-05-30 6:35:012392 days ago1527662101
0x74cD98fB...73c6D865e
0.003 ETH
57011912018-05-30 6:13:242392 days ago1527660804
0x74cD98fB...73c6D865e
0.0005 ETH
57011912018-05-30 6:13:242392 days ago1527660804
0x74cD98fB...73c6D865e
0.003 ETH
57011882018-05-30 6:13:072392 days ago1527660787
0x74cD98fB...73c6D865e
0.0005 ETH
57011882018-05-30 6:13:072392 days ago1527660787
0x74cD98fB...73c6D865e
0.003 ETH
57011862018-05-30 6:12:382392 days ago1527660758
0x74cD98fB...73c6D865e
0.003 ETH
57011842018-05-30 6:12:172392 days ago1527660737
0x74cD98fB...73c6D865e
0.003 ETH
57011772018-05-30 6:10:412392 days ago1527660641
0x74cD98fB...73c6D865e
0.003 ETH
57011772018-05-30 6:10:412392 days ago1527660641
0x74cD98fB...73c6D865e
0.0005 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
DogCore

Compiler Version
v0.4.18+commit.9cf6e910

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2018-05-28
*/

pragma solidity ^0.4.18;

/**
 * @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() public {
        owner = msg.sender;
    }

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

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



/// @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 GeneScienceInterface {
    /// @dev simply a boolean to indicate this is the contract we expect to be
    function isGeneScience() public pure returns (bool);

    /// @dev given genes of kitten 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);
}



contract VariationInterface {

    function isVariation() public pure returns(bool);
    
    function createVariation(uint256 _gene, uint256 _totalSupply) public returns (uint8);
    
    function registerVariation(uint256 _dogId, address _owner) public;
}


contract LotteryInterface {
    
    function isLottery() public pure returns (bool);

    function checkLottery(uint256 genes) public pure returns (uint8 lotclass);
    
    function registerLottery(uint256 _dogId) public payable returns (uint8);

    function getCLottery() 
        public 
        view 
        returns (
            uint8[7]        luckyGenes1,
            uint256         totalAmount1,
            uint256         openBlock1,
            bool            isReward1,
            uint256         term1,
            uint8           currentGenes1,
            uint256         tSupply,
            uint256         sPoolAmount1,
            uint256[]       reward1
        );
}




/// @title A facet of KittyCore that manages special access privileges.
/// @author Axiom Zen (https://www.axiomzen.co)
/// @dev See the KittyCore contract documentation to understand how the various contract facets are arranged.
contract DogAccessControl {
    // This facet controls access control for Cryptodogs. 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 KittyCore constructor.
    //
    //     - The CFO: The CFO can withdraw funds from KittyCore and its auction contracts.
    //
    //     - The COO: The COO can release gen0 dogs to auction, and mint promo cats.
    //
    // 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 Cryptodogs. Holds all common structs, events and base variables.
/// @author Axiom Zen (https://www.axiomzen.co)
/// @dev See the KittyCore contract documentation to understand how the various contract facets are arranged.
contract DogBase is DogAccessControl {
    /*** EVENTS ***/

    /// @dev The Birth event is fired whenever a new kitten comes into existence. This obviously
    ///  includes any time a cat is created through the giveBirth method, but it is also called
    ///  when a new gen0 cat is created.
    event Birth(address owner, uint256 dogId, uint256 matronId, uint256 sireId, uint256 genes, uint16 generation, uint8 variation, uint256 gen0, uint256 birthTime, uint256 income, uint16 cooldownIndex);

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

    /*** DATA TYPES ***/

    /// @dev The main Dog struct. Every cat in Cryptodogs 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 Dog {
        // The Dog's genetic code is packed into these 256-bits, the format is
        // sooper-sekret! A cat's genes never change.
        uint256 genes;

        // The timestamp from the block when this cat came into existence.
        uint256 birthTime;

        // The minimum timestamp after which this cat 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 Dog, set to 0 for gen0 cats.
        // Note that using 32-bit unsigned integers limits us to a "mere"
        // 4 billion cats. 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 cat for matrons that are pregnant,
        // zero otherwise. A non-zero value here is how we know a cat
        // is pregnant. Used to retrieve the genetic material for the new
        // kitten when the birth transpires.
        uint32 siringWithId;

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

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

        //zhangyong
        //变异系数
        uint8  variation;

        //zhangyong
        //0代狗祖先
        uint256 gen0;
    }

    /*** CONSTANTS ***/

    /// @dev A lookup table indicating 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 cat
    ///  is bred, encouraging owners not to just keep breeding the same cat over
    ///  and over again. Caps out at one week (a cat 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(24 hours),
        uint32(2 days),
        uint32(3 days),
        uint32(5 days)
    ];

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

    /*** STORAGE ***/

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

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

    // @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 KittyIDs to an address that has been approved to call
    ///  transferFrom(). Each Dog can only have one approved address for transfer
    ///  at any time. A zero value means no approval is outstanding.
    mapping (uint256 => address) public dogIndexToApproved;

    /// @dev A mapping from KittyIDs to an address that has been approved to use
    ///  this Dog for siring via breedWith(). Each Dog 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 dogs. 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;
  
    uint256 public autoBirthFee = 5000 szabo;

    //zhangyong
    //0代狗获取的繁殖收益
    uint256 public gen0Profit = 500 szabo;

    //zhangyong
    //0代狗获取繁殖收益的系数,可以动态调整,取值范围0到100
    function setGen0Profit(uint256 _value) public onlyCOO{        
        uint256 ration = _value * 100 / autoBirthFee;
        require(ration > 0);
        require(_value <= 100);
        gen0Profit = _value;
    }

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

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

    /// @dev An internal method that creates a new Dog 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 Dog ID of the matron of this cat (zero for gen0)
    /// @param _sireId The Dog ID of the sire of this cat (zero for gen0)
    /// @param _generation The generation number of this cat, must be computed by caller.
    /// @param _genes The Dog's genetic code.
    /// @param _owner The inital owner of this cat, must be non-zero (except for the unKitty, ID 0)
    //zhangyong
    //增加变异系数与0代狗祖先作为参数
    function _createDog(
        uint256 _matronId,
        uint256 _sireId,
        uint256 _generation,
        uint256 _genes,
        address _owner,
        uint8 _variation,
        uint256 _gen0,
        bool _isGen0Siring
    )
        internal
        returns (uint)
    {
        // These requires are not strictly necessary, our calling code should make
        // sure that these conditions are never broken. However! _createDog() 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 Dog starts with the same cooldown as parent gen/2
        uint16 cooldownIndex = uint16(_generation / 2);
        if (cooldownIndex > 13) {
            cooldownIndex = 13;
        }

        Dog memory _dog = Dog({
            genes: _genes,
            birthTime: block.number,
            cooldownEndBlock: 0,
            matronId: uint32(_matronId),
            sireId: uint32(_sireId),
            siringWithId: 0,
            cooldownIndex: cooldownIndex,
            generation: uint16(_generation),
            variation : uint8(_variation),
            gen0 : _gen0
        });
        uint256 newDogId = dogs.push(_dog) - 1;

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

        // emit the birth event
        Birth(
            _owner,
            newDogId,
            uint256(_dog.matronId),
            uint256(_dog.sireId),
            _dog.genes,
            uint16(_generation),
            _variation,
            _gen0,
            block.number,
            _isGen0Siring ? 0 : gen0Profit,
            cooldownIndex
        );

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

        return newDogId;
    }

    // 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 dogs,
///  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 Cryptodogs 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 KittyCore contract documentation to understand how the various contract facets are arranged.
contract DogOwnership is DogBase, ERC721 {

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

    // The contract that will return Dog 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 Dog.
    /// @param _claimant the address we are validating against.
    /// @param _tokenId kitten id, only valid when > 0
    function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) {
        return dogIndexToOwner[_tokenId] == _claimant;
    }

    /// @dev Checks if a given address currently has transferApproval for a particular Dog.
    /// @param _claimant the address we are confirming kitten is approved for.
    /// @param _tokenId kitten id, only valid when > 0
    function _approvedFor(address _claimant, uint256 _tokenId) internal view returns (bool) {
        return dogIndexToApproved[_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 dogs on auction, and
    ///  there is no value in spamming the log with Approval events in that case.
    function _approve(uint256 _tokenId, address _approved) internal {
        dogIndexToApproved[_tokenId] = _approved;
    }

    /// @notice Returns the number of dogs 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 Dog to another address. If transferring to a smart
    ///  contract be VERY CAREFUL to ensure that it is aware of ERC-721 (or
    ///  Cryptodogs specifically) or your Dog may be lost forever. Seriously.
    /// @param _to The address of the recipient, can be a user or contract.
    /// @param _tokenId The ID of the Dog 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 dogs (except very briefly
        // after a gen0 cat 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 dogs
        // through the allow + transferFrom flow.
        require(_to != address(saleAuction));
        require(_to != address(siringAuction));

        // You can only send your own cat.
        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 Dog 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 Dog 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 Dog 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 Dog to be transfered.
    /// @param _to The address that should take ownership of the Dog. Can be any address,
    ///  including the caller.
    /// @param _tokenId The ID of the Dog 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 dogs (except very briefly
        // after a gen0 cat 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 dogs currently in existence.
    /// @dev Required for ERC-721 compliance.
    function totalSupply() public view returns (uint) {
        return dogs.length - 1;
    }

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

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

    /// @notice Returns a list of all Dog IDs assigned to an address.
    /// @param _owner The owner whose dogs we are interested in.
    /// @dev This method MUST NEVER be called by smart contract code. First, it's fairly
    ///  expensive (it walks the entire Dog array looking for cats 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 totalCats = totalSupply();
    //         uint256 resultIndex = 0;

    //         // We count on the fact that all cats have IDs starting at 1 and increasing
    //         // sequentially up to the totalCat count.
    //         uint256 catId;

    //         for (catId = 1; catId <= totalCats; catId++) {
    //             if (dogIndexToOwner[catId] == _owner) {
    //                 result[resultIndex] = catId;
    //                 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 Dog 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 KittyCore that manages Dog siring, gestation, and birth.
/// @author Axiom Zen (https://www.axiomzen.co)
/// @dev See the KittyCore contract documentation to understand how the various contract facets are arranged.
contract DogBreeding is DogOwnership {

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

    /// @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 = 2 finney;

    // Keeps track of number of pregnant dogs.
    uint256 public pregnantDogs;

    /// @dev The address of the sibling contract that is used to implement the sooper-sekret
    ///  genetic combination algorithm.
    GeneScienceInterface public geneScience;
    
    VariationInterface public variation;

    LotteryInterface public lottery;

    /// @dev Update the address of the genetic contract, can only be called by the CEO.
    /// @param _address An address of a GeneScience contract instance to be used from this point forward.
    function setGeneScienceAddress(address _address) external onlyCEO {
        GeneScienceInterface candidateContract = GeneScienceInterface(_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;
    }

    /// @dev Checks that a given kitten is able to breed. Requires that the
    ///  current cooldown is finished (for sires) and also checks that there is
    ///  no pending pregnancy.
    function _isReadyToBreed(Dog _dog) internal view returns (bool) {
        // In addition to checking the cooldownEndBlock, we also need to check to see if
        // the cat has a pending birth; there can be some period of time between the end
        // of the pregnacy timer and the birth event.
        return (_dog.siringWithId == 0) && (_dog.cooldownEndBlock <= uint64(block.number));
    }

    /// @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 = dogIndexToOwner[_matronId];
        address sireOwner = dogIndexToOwner[_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 Dog, based on its current cooldownIndex.
    ///  Also increments the cooldownIndex (unless it has hit the cap).
    /// @param _dog A reference to the Dog in storage which needs its timer started.
    function _triggerCooldown(Dog storage _dog) internal {
        // Compute an estimation of the cooldown time in blocks (based on current cooldownIndex).
        _dog.cooldownEndBlock = uint64((cooldowns[_dog.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 (_dog.cooldownIndex < 13) {
            _dog.cooldownIndex += 1;
        }
    }

    /// @notice Grants approval to another user to sire with one of your dogs.
    /// @param _addr The address that will be able to sire with your Dog. Set to
    ///  address(0) to clear all siring approvals for this Dog.
    /// @param _sireId A Dog 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 {
        require(val > 0);
        autoBirthFee = val;
    }

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

    /// @notice Checks that a given kitten is able to breed (i.e. it is not pregnant or
    ///  in the middle of a siring cooldown).
    /// @param _dogId reference the id of the kitten, any user can inquire about it
    function isReadyToBreed(uint256 _dogId)
        public
        view
        returns (bool)
    {
        //zhangyong
        //创世狗有两只
        require(_dogId > 1);
        Dog storage dog = dogs[_dogId];
        return _isReadyToBreed(dog);
    }

    /// @dev Checks whether a Dog is currently pregnant.
    /// @param _dogId reference the id of the kitten, any user can inquire about it
    function isPregnant(uint256 _dogId)
        public
        view
        returns (bool)
    {
        // A Dog is pregnant if and only if this field is set
        return dogs[_dogId].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 Dog struct of the potential matron.
    /// @param _matronId The matron's ID.
    /// @param _sire A reference to the Dog struct of the potential sire.
    /// @param _sireId The sire's ID
    function _isValidMatingPair(
        Dog storage _matron,
        uint256 _matronId,
        Dog storage _sire,
        uint256 _sireId
    )
        private
        view
        returns(bool)
    {
        // A Dog can't breed with itself!
        if (_matronId == _sireId) {
            return false;
        }

        // dogs 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 cat is
        // gen zero (has a matron ID of zero).
        if (_sire.matronId == 0 || _matron.matronId == 0) {
            return true;
        }

        // dogs 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)
    {
        Dog storage matron = dogs[_matronId];
        Dog storage sire = dogs[_sireId];
        return _isValidMatingPair(matron, _matronId, sire, _sireId);
    }

    // @notice Checks to see if two cats can breed together, including checks for
    //  ownership and siring approvals. Does NOT check that both cats 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 > 1);
    //     require(_sireId > 1);
    //     Dog storage matron = dogs[_matronId];
    //     Dog storage sire = dogs[_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 {
        //zhangyong
        //创世狗不能繁殖
        require(_matronId > 1);
        require(_sireId > 1);
        
        // Grab a reference to the dogs from storage.
        Dog storage sire = dogs[_sireId];
        Dog storage matron = dogs[_matronId];

        //zhangyong
        //变异狗不能繁殖
        require(sire.variation == 0);
        require(matron.variation == 0);

        if (matron.generation > 0) {
            var(,,openBlock,,,,,,) = lottery.getCLottery();
            if (matron.birthTime < openBlock) {
                require(lottery.checkLottery(matron.genes) == 100);
            }
        }

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

        // 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 Dog gets pregnant, counter is incremented.
        pregnantDogs++;

        //zhangyong
        //只能由系统接生,接生费转给公司作为开发费用
        cfoAddress.transfer(autoBirthFee);

        //zhangyong
        //如果母狗是0代狗,那么小狗的祖先就是母狗的ID,否则跟母狗的祖先相同
        if (matron.generation > 0) {
            dogIndexToOwner[matron.gen0].transfer(gen0Profit);
        }

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

    /// @notice Breed a Dog you own (as matron) with a sire that you own, or for which you
    ///  have previously been given Siring approval. Will either make your cat 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 Dog acting as matron (will end up pregnant if successful)
    /// @param _sireId The ID of the Dog acting as sire (will begin its siring cooldown if successful)
    function breedWithAuto(uint256 _matronId, uint256 _sireId)
        external
        payable
        whenNotPaused
    {        
        // zhangyong
        // 如果不是0代狗繁殖,则多收0代狗的繁殖收益
        uint256 totalFee = autoBirthFee;
        Dog storage matron = dogs[_matronId];
        if (matron.generation > 0) {
            totalFee += gen0Profit;
        }

        // Checks for payment.
        require(msg.value >= totalFee);

        // 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 Dog 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 cat
        // 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
        // Dog storage matron = dogs[_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
        Dog storage sire = dogs[_sireId];

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

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

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

        // zhangyong
        // 多余的费用返还给用户
        uint256 breedExcess = msg.value - totalFee;
        if (breedExcess > 0) {
            msg.sender.transfer(breedExcess);
        }
    }

    /// @notice Have a pregnant Dog give birth!
    /// @param _matronId A Dog ready to give birth.
    /// @return The Dog ID of the new kitten.
    /// @dev Looks at a given Dog and, if pregnant and if the gestation period has passed,
    ///  combines the genes of the two parents to create a new kitten. The new Dog is assigned
    ///  to the current owner of the matron. Upon successful completion, both the matron and the
    ///  new kitten will be ready to breed again. Note that anyone can call this function (if they
    ///  are willing to pay the gas!), but the new kitten always goes to the mother's owner.
    //zhangyong
    //只能由系统接生,接生费转给公司作为开发费用,同时避免其他人帮助接生后,后台不知如何处理
    function giveBirth(uint256 _matronId)
        external
        whenNotPaused
        returns(uint256)
    {
        // Grab a reference to the matron in storage.
        Dog storage matron = dogs[_matronId];

        // Check that the matron is a valid cat.
        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;
        Dog storage sire = dogs[sireId];

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

        //zhangyong
        //如果母狗是0代狗,那么小狗的祖先就是母狗的ID,否则跟母狗的祖先相同
        uint256 gen0 = matron.generation == 0 ? _matronId : matron.gen0;

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

        // Make the new kitten!
        address owner = dogIndexToOwner[_matronId];

        uint8 _variation = variation.createVariation(childGenes, dogs.length);

        bool isGen0Siring = matron.generation == 0;

        uint256 kittenId = _createDog(_matronId, matron.siringWithId, parentGen + 1, childGenes, owner, _variation, gen0, isGen0Siring);

        // 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 Dog gives birth counter is decremented.
        pregnantDogs--;

        // Send the balance fee to the person who made birth happen.
       
        if(_variation != 0){
            variation.registerVariation(kittenId, owner);      
            _transfer(owner, address(variation), kittenId);
        }

        // return the new kitten's ID
        return kittenId;
    }
}




/// @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, address _to)
        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);
        uint256 auctioneerCut = computeCut(price);

        //zhangyong
        //两只创世狗每次交易需要收取10%的手续费
        //创世狗无法繁殖,所以只有创世狗交易才会进入到这个方法
        uint256 fee = 0;
        if (_tokenId == 0 || _tokenId == 1) {
            fee = price / 5;
        }        
        require((_bidAmount + auctioneerCut + fee) >= 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 sellerProceeds = price - auctioneerCut - fee;

            // 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.
        // zhangyong
        // _bidAmount在进入这个方法之前已经扣掉了fee,所以买者需要加上这笔费用才等于开始出价
        // uint256 bidExcess = _bidAmount + fee - 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.
        // zhangyong
        // msg.sender是主合约地址,并不是出价人的地址
        // msg.sender.transfer(bidExcess);

        // Tell the world!
        AuctionSuccessful(_tokenId, price, _to);

        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 multiplication 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) public 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() public onlyOwner whenNotPaused returns (bool) {
        paused = true;
        Pause();
        return true;
    }

  /**
   * @dev called by the owner to unpause, returns to normal state
   */
    function unpause() public 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);
    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)"));

    /// @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
        nftAddress.transfer(address(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 allocated
    //     // 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
    {
        // zhangyong
        // 普通用户无法下架创世狗
        require(_tokenId > 1);

        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 KittyCore 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 allocated
        // 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 KittyCore contract because all bid methods
    /// should be wrapped. Also returns the Dog to the
    /// seller rather than the winner.
    function bid(uint256 _tokenId, address _to)
        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, _to);
        // We transfer the Dog back to the seller, the winner will get
        // the offspring
        _transfer(seller, _tokenId);
    }

}





/// @title Clock auction modified for sale of dogs
/// @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 Dog 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 allocated
        // 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, address _to)
        external
        payable
    {
        //zhangyong
        //只能由主合约调用出价竞购,因为要判断当期中奖了的狗无法买卖
        require(msg.sender == address(nonFungibleContract));

        // _bid verifies token ID size
        address seller = tokenIdToAuction[_tokenId].seller;  

        // zhangyong
        // 自己不能买自己卖的同一只狗
        require(seller != _to);

        uint256 price = _bid(_tokenId, msg.value, _to);
        
        //zhangyong
        //当狗被拍卖后,主人变成拍卖合约,主合约并不是狗的购买人,需要额外传入
        _transfer(_to, _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 dogs.
///  This wrapper of ReverseAuction exists only so that users can create
///  auctions with only one transaction.
contract DogAuction is DogBreeding {

    uint256 public constant GEN0_AUCTION_DURATION = 1 days;

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

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

    /// @dev Put a Dog up for auction to be sire.
    ///  Performs checks to ensure the Dog can be sired, then
    ///  delegates to reverse auction.
    function createSiringAuction(
        uint256 _dogId,
        uint256 _startingPrice,
        uint256 _endingPrice,
        uint256 _duration
    )
        external
        whenNotPaused
    {    
        //zhangyong
        Dog storage dog = dogs[_dogId];    
        //变异狗不能繁殖
        require(dog.variation == 0);

        // Auction contract checks input sizes
        // If Dog is already on any auction, this will throw
        // because it will be owned by the auction contract.
        require(_owns(msg.sender, _dogId));
        require(isReadyToBreed(_dogId));
        _approve(_dogId, siringAuction);
        // Siring auction throws if inputs are invalid and clears
        // transfer and sire approval after escrowing the Dog.
        siringAuction.createAuction(
            _dogId,
            _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);
        
        // zhangyong
        // 如果不是0代狗繁殖,则多收0代狗的繁殖收益
        uint256 totalFee = currentPrice + autoBirthFee;
        Dog storage matron = dogs[_matronId];
        if (matron.generation > 0) {
            totalFee += gen0Profit;
        }        
        require(msg.value >= totalFee);

        uint256 auctioneerCut = saleAuction.computeCut(currentPrice);
        // Siring auction will throw if the bid fails.
        siringAuction.bid.value(currentPrice - auctioneerCut)(_sireId, msg.sender);
        _breedWith(uint32(_matronId), uint32(_sireId));

        // zhangyong
        // 额外的钱返还给用户
        uint256 bidExcess = msg.value - totalFee;
        if (bidExcess > 0) {
            msg.sender.transfer(bidExcess);
        }
    }

    // zhangyong
    // 创世狗交易需要收取10%的手续费给CFO
    // 所有交易都要收取3.75%的手续费给买卖合约
    function bidOnSaleAuction(
        uint256 _dogId
    )
        external
        payable
        whenNotPaused
    {
        Dog storage dog = dogs[_dogId];

        //中奖的狗无法交易
        if (dog.generation > 0) {
            var(,,openBlock,,,,,,) = lottery.getCLottery();
            if (dog.birthTime < openBlock) {
                require(lottery.checkLottery(dog.genes) == 100);
            }
        }

        //交易成功之后,买卖合约会被删除,无法获取到当前价格
        uint256 currentPrice = saleAuction.getCurrentPrice(_dogId);

        require(msg.value >= currentPrice);

        //创世狗交易需要收取10%的手续费
        bool isCreationKitty = _dogId == 0 || _dogId == 1;
        uint256 fee = 0;
        if (isCreationKitty) {
            fee = currentPrice / 5;
        }
        uint256 auctioneerCut = saleAuction.computeCut(currentPrice);
        saleAuction.bid.value(currentPrice - (auctioneerCut + fee))(_dogId, msg.sender);

        // 创世狗被交易之后,下次的价格为当前成交价的2倍
        if (isCreationKitty) {
            //转账到主合约进行,因为买卖合约访问不了cfoAddress
            cfoAddress.transfer(fee);

            uint256 nextPrice = uint256(uint128(2 * currentPrice));
            if (nextPrice < currentPrice) {
                nextPrice = currentPrice;
            }
            _approve(_dogId, saleAuction);
            saleAuction.createAuction(
                _dogId,
                nextPrice,
                nextPrice,                                               
                GEN0_AUCTION_DURATION,
                msg.sender);
        }

        uint256 bidExcess = msg.value - currentPrice;
        if (bidExcess > 0) {
            msg.sender.transfer(bidExcess);
        }
    }

    // @dev Transfers the balance of the sale auction contract
    // to the KittyCore 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 kittens
contract DogMinting is DogAuction {

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

    // Constants for gen0 auctions.
    uint256 public constant GEN0_STARTING_PRICE = 200 finney;
    // uint256 public constant GEN0_AUCTION_DURATION = 1 days;
    // Counts the number of cats the contract owner has created.
    // uint256 public promoCreatedCount;
    uint256 public gen0CreatedCount;

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

    //     promoCreatedCount++;
    //     //zhangyong
    //     //增加变异系数与0代狗祖先作为参数
    //     _createDog(0, 0, 0, _genes, kittyOwner, 0, 0, false);
    // }

    // @dev Creates a new gen0 Dog with the given genes
    function createGen0Dog(uint256 _genes) external onlyCLevel returns(uint256) {
        require(gen0CreatedCount < GEN0_CREATION_LIMIT);
        //zhangyong
        //增加变异系数与0代狗祖先作为参数
        uint256 dogId = _createDog(0, 0, 0, _genes, address(this), 0, 0, false);
        
        _approve(dogId, msg.sender);

        gen0CreatedCount++;
        return dogId;
    }

    /// @dev creates an auction for it.
    // function createGen0Auction(uint256 _dogId) external onlyCOO {
    //     require(_owns(address(this), _dogId));

    //     _approve(_dogId, saleAuction);

    //     //zhangyong
    //     //0代狗的价格随时间递减到最低价,起始价与前5只价格相关
    //     uint256 price = _computeNextGen0Price();
    //     saleAuction.createAuction(
    //         _dogId,
    //         price,
    //         price,
    //         GEN0_AUCTION_DURATION,
    //         address(this)
    //     );
    // }

    /// @dev Computes the next gen0 auction starting price, given
    ///  the average of the past 5 prices + 50%.
    function computeNextGen0Price() public 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 Cryptodogs: Collectible, breedable, and oh-so-adorable cats on the Ethereum blockchain.
/// @author Axiom Zen (https://www.axiomzen.co)
/// @dev The main Cryptodogs contract, keeps track of kittens so they don't wander around and get lost.
contract DogCore is DogMinting {

    // This is the main Cryptodogs 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
    // Dog 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:
    //
    //      - KittyBase: 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.
    //
    //      - KittyAccessControl: This contract manages the various addresses and constraints for operations
    //             that can be executed only by specific roles. Namely CEO, CFO and COO.
    //
    //      - KittyOwnership: This provides the methods required for basic non-fungible token
    //             transactions, following the draft ERC-721 spec (https://github.com/ethereum/EIPs/issues/721).
    //
    //      - KittyBreeding: This file contains the methods necessary to breed cats together, including
    //             keeping track of siring offers, and relies on an external genetic combination contract.
    //
    //      - KittyAuctions: Here we have the public methods for auctioning or bidding on cats 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.
    //
    //      - KittyMinting: This final facet contains the functionality we use for creating new gen0 cats.
    //             We can make up to 5000 "promo" cats 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 cats. 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 Cryptodogs smart contract instance.
    function DogCore() 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 kitten 0 - so we don't have generation-0 parent issues
        //zhangyong
        //增加变异系数与0代狗祖先作为参数
        _createDog(0, 0, 0, uint256(0), address(this), 0, 0, false);   
        _approve(0, cooAddress);     
        _createDog(0, 0, 0, uint256(0), address(this), 0, 0, false);   
        _approve(1, cooAddress);
    }

    /// @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 indicating 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) ||
            msg.sender == ceoAddress
        );
    }

    /// @notice Returns all the relevant information about a specific Dog.
    /// @param _id The ID of the Dog of interest.
    function getDog(uint256 _id)
        external
        view
        returns (
        uint256 cooldownIndex,
        uint256 nextActionAt,
        uint256 siringWithId,
        uint256 birthTime,
        uint256 matronId,
        uint256 sireId,
        uint256 generation,
        uint256 genes,
        uint8 variation,
        uint256 gen0
    ) {
        Dog storage dog = dogs[_id];

        // if this variable is 0 then it's not gestating
        cooldownIndex = uint256(dog.cooldownIndex);
        nextActionAt = uint256(dog.cooldownEndBlock);
        siringWithId = uint256(dog.siringWithId);
        birthTime = uint256(dog.birthTime);
        matronId = uint256(dog.matronId);
        sireId = uint256(dog.sireId);
        generation = uint256(dog.generation);
        genes = uint256(dog.genes);
        variation = uint8(dog.variation);
        gen0 = uint256(dog.gen0);
    }

    /// @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(lottery != address(0));
        require(variation != address(0));
        require(newContractAddress == address(0));

        // Actually unpause the contract.
        super.unpause();
    }
      
    function setLotteryAddress(address _address) external onlyCEO {
        LotteryInterface candidateContract = LotteryInterface(_address);

        require(candidateContract.isLottery());

        lottery = candidateContract;
    }  
      
    function setVariationAddress(address _address) external onlyCEO {
        VariationInterface candidateContract = VariationInterface(_address);

        require(candidateContract.isVariation());

        variation = candidateContract;
    }  

    function registerLottery(uint256 _dogId) external returns (uint8) {
        require(_owns(msg.sender, _dogId));
        require(lottery.registerLottery(_dogId) == 0);    
        _transfer(msg.sender, address(lottery), _dogId);
    }

    function sendMoney(address _to, uint256 _money) external {
        require(msg.sender == address(lottery) || msg.sender == address(variation));
        require(address(this).balance >= _money);
        _to.transfer(_money);
    }

}

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":"name","outputs":[{"name":"","type":"string"}],"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":"computeNextGen0Price","outputs":[{"name":"","type":"uint256"}],"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":"_dogId","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":"_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":"_address","type":"address"}],"name":"setLotteryAddress","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":"pregnantDogs","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_dogId","type":"uint256"},{"name":"_startingPrice","type":"uint256"},{"name":"_endingPrice","type":"uint256"},{"name":"_duration","type":"uint256"}],"name":"createSaleAuction","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":false,"inputs":[{"name":"_dogId","type":"uint256"},{"name":"_startingPrice","type":"uint256"},{"name":"_endingPrice","type":"uint256"},{"name":"_duration","type":"uint256"}],"name":"createSiringAuction","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"val","type":"uint256"}],"name":"setAutoBirthFee","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"gen0Profit","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","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":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":"newContractAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_dogId","type":"uint256"}],"name":"registerLottery","outputs":[{"name":"","type":"uint8"}],"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":"secondsPerBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_id","type":"uint256"}],"name":"getDog","outputs":[{"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"},{"name":"variation","type":"uint8"},{"name":"gen0","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_matronId","type":"uint256"}],"name":"giveBirth","outputs":[{"name":"","type":"uint256"}],"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":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"setGen0Profit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"transfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_genes","type":"uint256"}],"name":"createGen0Dog","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_dogId","type":"uint256"}],"name":"bidOnSaleAuction","outputs":[],"payable":true,"stateMutability":"payable","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":"lottery","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_dogId","type":"uint256"}],"name":"isReadyToBreed","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"dogIndexToApproved","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"}],"name":"setVariationAddress","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"variation","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","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":false,"inputs":[{"name":"_to","type":"address"},{"name":"_money","type":"uint256"}],"name":"sendMoney","outputs":[],"payable":false,"stateMutability":"nonpayable","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":false,"inputs":[{"name":"_matronId","type":"uint256"},{"name":"_sireId","type":"uint256"}],"name":"breedWithAuto","outputs":[],"payable":true,"stateMutability":"payable","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":"matronCooldownEndBlock","type":"uint256"},{"indexed":false,"name":"sireCooldownEndBlock","type":"uint256"},{"indexed":false,"name":"matronCooldownIndex","type":"uint256"},{"indexed":false,"name":"sireCooldownIndex","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":"dogId","type":"uint256"},{"indexed":false,"name":"matronId","type":"uint256"},{"indexed":false,"name":"sireId","type":"uint256"},{"indexed":false,"name":"genes","type":"uint256"},{"indexed":false,"name":"generation","type":"uint16"},{"indexed":false,"name":"variation","type":"uint8"},{"indexed":false,"name":"gen0","type":"uint256"},{"indexed":false,"name":"birthTime","type":"uint256"},{"indexed":false,"name":"income","type":"uint256"},{"indexed":false,"name":"cooldownIndex","type":"uint16"}],"name":"Birth","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"newContract","type":"address"}],"name":"ContractUpgrade","type":"event"}]

606060409081526002805460a060020a60ff02191690556101c090519081016040908152603c82526078602083015261012c9082015261025860608201526107086080820152610e1060a0820152611c2060c082015261384060e082015261708061010082015261e100610120820152620151806101408201526202a3006101608201526203f480610180820152620697806101a0820152620000a790600390600e620005d5565b50600f6005556611c37937e08000600d556601c6bf52634000600e553415620000cf57600080fd5b6002805460008054600160a060020a033316600160a060020a03199182168117835560a060020a60ff02199093167401000000000000000000000000000000000000000017169091179091556200013b908080803081808064010000000062002c78620001b482021704565b506002546200016490600090600160a060020a031664010000000062002ab7620004be82021704565b6200018560008080803081808064010000000062002c78620001b482021704565b50600254620001ae90600190600160a060020a031664010000000062002ab7620004be82021704565b6200077b565b600080620001c162000678565b600063ffffffff8c168c14620001d657600080fd5b63ffffffff8b168b14620001e957600080fd5b61ffff8a168a14620001fa57600080fd5b60028a049250600d8361ffff1611156200021357600d92505b61014060405190810160409081528a8252436020830152600090820181905263ffffffff808f1660608401528d16608083015260a082015261ffff80851660c08301528b1660e082015260ff8816610100820152610120810187905260068054919350600191808301620002888382620006cc565b600092835260209092208591600402018151815560208201518160010155604082015160028201805467ffffffffffffffff191667ffffffffffffffff9290921691909117905560608201518160020160086101000a81548163ffffffff021916908363ffffffff160217905550608082015181600201600c6101000a81548163ffffffff021916908363ffffffff16021790555060a08201518160020160106101000a81548163ffffffff021916908363ffffffff16021790555060c08201518160020160146101000a81548161ffff021916908361ffff16021790555060e08201518160020160166101000a81548161ffff021916908361ffff1602179055506101008201518160020160186101000a81548160ff021916908360ff1602179055506101208201516003909101555003905063016c80008110620003cd57600080fd5b7f746319248c02be7f11174ecd7121305fe37ffe8b19a6abef96df84f321a84e338882846060015163ffffffff16856080015163ffffffff1686518f8d8d438e6200041b57600e546200041e565b60005b8d604051600160a060020a03909b168b5260208b01999099526040808b019890985260608a0196909652608089019490945261ffff92831660a089015260ff90911660c088015260e087015261010086019190915261012085019190915291909116610140830152610160909101905180910390a1620004af6000898364010000000062002b05620004ec82021704565b9b9a5050505050505050505050565b6000918252600960205260409091208054600160a060020a031916600160a060020a03909216919091179055565b600160a060020a03808316600081815260086020908152604080832080546001019055858352600790915290208054600160a060020a03191690911790558316156200058057600160a060020a03831660009081526008602090815260408083208054600019019055838352600a82528083208054600160a060020a03199081169091556009909252909120805490911690555b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef838383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a1505050565b600283019183908215620006665791602002820160005b838211156200063257835183826101000a81548163ffffffff021916908363ffffffff1602179055509260200192600401602081600301049283019260010302620005ec565b8015620006645782816101000a81549063ffffffff021916905560040160208160030104928301926001030262000632565b505b506200067492915062000700565b5090565b6101406040519081016040908152600080835260208301819052908201819052606082018190526080820181905260a0820181905260c0820181905260e08201819052610100820181905261012082015290565b815481835581811511620006fb57600402816004028360005260206000209182019101620006fb919062000727565b505050565b6200072491905b808211156200067457805463ffffffff1916815560010162000707565b90565b6200072491905b8082111562000674576000808255600182018190556002820180547fffffffffffffff0000000000000000000000000000000000000000000000000016905560038201556004016200072e565b613755806200078b6000396000f30060606040526004361061029a5763ffffffff60e060020a60003504166301ffc9a781146102eb5780630519ce791461033757806306fdde0314610366578063095ea7b3146103f05780630a0f8168146104125780630e0bc104146104255780630e583df01461044a57806314001f4c1461045d57806318160ddd1461047c5780631940a9361461048f57806319c2f201146104a557806321717ebf146104b857806323b872dd146104cb57806324e7a38a146104f357806327d7874c146105125780632a332b2a146105315780632ba73c15146105505780633369c33d1461056f5780633d7d3f5a146105825780633f4ba83a146105a157806346116e6f146105b45780634ad8c938146105ca5780634b85fd55146105e95780634d42fc66146105ff5780634dfff04f146106125780634e0a3379146106345780635663896e146106535780635c975abb146106695780636352211e1461067c578063680eba27146106925780636af04a57146106a55780636bee2cc3146106b85780636fbde40d146106e457806370a082311461070357806371587988146107225780637a7d4937146107415780637c62e2a4146107545780638456cb59146107c357806388c2a0bf146107d657806395d89b41146107ec5780639d6fac6f146107ff578063a5ef0dd61461082e578063a9059cbb14610844578063ab0a986514610866578063ad25ce571461087c578063b047fb5014610887578063b0c35c051461089a578063ba13a572146108ad578063d3e6f49f146108c0578063d83970a1146108d6578063dff00e92146108ec578063e015d8631461090b578063e6cbe3511461091e578063ed60ade614610931578063ee4ae2c91461093f578063f1ca941014610961578063f2b47d5214610974578063f7d8c88314610987575b600b5433600160a060020a03908116911614806102c55750600c5433600160a060020a039081169116145b806102de575060005433600160a060020a039081169116145b15156102e957600080fd5b005b34156102f657600080fd5b6103237fffffffff0000000000000000000000000000000000000000000000000000000060043516610995565b604051901515815260200160405180910390f35b341561034257600080fd5b61034a610bb8565b604051600160a060020a03909116815260200160405180910390f35b341561037157600080fd5b610379610bc7565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156103b557808201518382015260200161039d565b50505050905090810190601f1680156103e25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103fb57600080fd5b6102e9600160a060020a0360043516602435610bfe565b341561041d57600080fd5b61034a610c88565b341561043057600080fd5b610438610c97565b60405190815260200160405180910390f35b341561045557600080fd5b610438610d47565b341561046857600080fd5b6102e9600160a060020a0360043516610d53565b341561048757600080fd5b610438610e00565b341561049a57600080fd5b610323600435610e0b565b34156104b057600080fd5b610438610e45565b34156104c357600080fd5b61034a610e4c565b34156104d657600080fd5b6102e9600160a060020a0360043581169060243516604435610e5b565b34156104fe57600080fd5b6102e9600160a060020a0360043516610ee2565b341561051d57600080fd5b6102e9600160a060020a0360043516610f8f565b341561053c57600080fd5b6102e9600160a060020a0360043516610fe1565b341561055b57600080fd5b6102e9600160a060020a036004351661108e565b341561057a57600080fd5b6104386110e0565b341561058d57600080fd5b6102e96004356024356044356064356110e6565b34156105ac57600080fd5b6102e96111ef565b34156105bf57600080fd5b61034a6004356112b5565b34156105d557600080fd5b6102e96004356024356044356064356112d0565b34156105f457600080fd5b6102e96004356113ee565b341561060a57600080fd5b61043861141b565b341561061d57600080fd5b6102e9600160a060020a0360043516602435611421565b341561063f57600080fd5b6102e9600160a060020a036004351661147b565b341561065e57600080fd5b6102e96004356114cd565b341561067457600080fd5b610323611535565b341561068757600080fd5b61034a600435611545565b341561069d57600080fd5b610438611569565b34156106b057600080fd5b61034a61156f565b34156106c357600080fd5b6106ce60043561157e565b60405160ff909116815260200160405180910390f35b34156106ef57600080fd5b6102e9600160a060020a0360043516611626565b341561070e57600080fd5b610438600160a060020a03600435166116d3565b341561072d57600080fd5b6102e9600160a060020a03600435166116ee565b341561074c57600080fd5b61043861177c565b341561075f57600080fd5b61076a600435611782565b604051998a5260208a01989098526040808a01979097526060890195909552608088019390935260a087019190915260c086015260e085015260ff16610100840152610120830191909152610140909101905180910390f35b34156107ce57600080fd5b6102e9611897565b34156107e157600080fd5b610438600435611923565b34156107f757600080fd5b610379611cf7565b341561080a57600080fd5b610815600435611d2e565b60405163ffffffff909116815260200160405180910390f35b341561083957600080fd5b6102e9600435611d5b565b341561084f57600080fd5b6102e9600160a060020a0360043516602435611dad565b341561087157600080fd5b610438600435611e54565b6102e9600435611ee8565b341561089257600080fd5b61034a612336565b34156108a557600080fd5b610438612345565b34156108b857600080fd5b61034a61234b565b34156108cb57600080fd5b61032360043561235a565b34156108e157600080fd5b61034a600435612439565b34156108f757600080fd5b6102e9600160a060020a0360043516612454565b341561091657600080fd5b61034a612501565b341561092957600080fd5b61034a612510565b6102e960043560243561251f565b341561094a57600080fd5b6102e9600160a060020a0360043516602435612776565b341561096c57600080fd5b6104386127f5565b341561097f57600080fd5b61034a6127fb565b6102e960043560243561280a565b60006040517f737570706f727473496e7465726661636528627974657334290000000000000081526019016040518091039020600160e060020a03191682600160e060020a0319161480610bb057506040517f7472616e7366657246726f6d28616464726573732c616464726573732c75696e81527f7432353629000000000000000000000000000000000000000000000000000000602082015260250160405180910390206040517f7472616e7366657228616464726573732c75696e743235362900000000000000815260190160405180910390206040517f617070726f766528616464726573732c75696e74323536290000000000000000815260180160405180910390206040517f6f776e65724f662875696e743235362900000000000000000000000000000000815260100160405180910390206040517f62616c616e63654f662861646472657373290000000000000000000000000000815260120160405180910390206040517f746f74616c537570706c792829000000000000000000000000000000000000008152600d0160405180910390206040517f73796d626f6c2829000000000000000000000000000000000000000000000000815260080160405180910390206040517f6e616d65282900000000000000000000000000000000000000000000000000008152600601604051809103902018181818181818600160e060020a03191682600160e060020a031916145b90505b919050565b600154600160a060020a031681565b60408051908101604052600881527f48656c6c6f446f67000000000000000000000000000000000000000000000000602082015281565b60025460a060020a900460ff1615610c1557600080fd5b610c1f3382612a97565b1515610c2a57600080fd5b610c348183612ab7565b7f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925338383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a15050565b600054600160a060020a031681565b600b5460009081908190600160a060020a031663eac9d94c82604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610ce557600080fd5b6102c65a03f11515610cf657600080fd5b50505060405180519250506fffffffffffffffffffffffffffffffff82168214610d1f57600080fd5b506002810481016702c68af0bb140000811015610d4157506702c68af0bb1400005b92915050565b6702c68af0bb14000081565b6000805433600160a060020a03908116911614610d6f57600080fd5b5080600160a060020a0381166376190f8f6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610db757600080fd5b6102c65a03f11515610dc857600080fd5b505050604051805190501515610ddd57600080fd5b600c8054600160a060020a031916600160a060020a039290921691909117905550565b600654600019015b90565b6000600682815481101515610e1c57fe5b6000918252602090912060049091020160020154608060020a900463ffffffff16151592915050565b6201518081565b600c54600160a060020a031681565b60025460a060020a900460ff1615610e7257600080fd5b600160a060020a0382161515610e8757600080fd5b30600160a060020a031682600160a060020a031614151515610ea857600080fd5b610eb23382612ae5565b1515610ebd57600080fd5b610ec78382612a97565b1515610ed257600080fd5b610edd838383612b05565b505050565b6000805433600160a060020a03908116911614610efe57600080fd5b5080600160a060020a0381166354c15b826000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610f4657600080fd5b6102c65a03f11515610f5757600080fd5b505050604051805190501515610f6c57600080fd5b60108054600160a060020a031916600160a060020a039290921691909117905550565b60005433600160a060020a03908116911614610faa57600080fd5b600160a060020a0381161515610fbf57600080fd5b60008054600160a060020a031916600160a060020a0392909216919091179055565b6000805433600160a060020a03908116911614610ffd57600080fd5b5080600160a060020a0381166325698d896000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561104557600080fd5b6102c65a03f1151561105657600080fd5b50505060405180519050151561106b57600080fd5b60128054600160a060020a031916600160a060020a039290921691909117905550565b60005433600160a060020a039081169116146110a957600080fd5b600160a060020a03811615156110be57600080fd5b60028054600160a060020a031916600160a060020a0392909216919091179055565b600f5481565b60025460a060020a900460ff16156110fd57600080fd5b6111073385612a97565b8061111757506111173385612ae5565b151561112257600080fd5b61112b84610e0b565b1561113557600080fd5b600b5461114c908590600160a060020a0316612ab7565b600b546000858152600760205260409081902054600160a060020a03928316926327ebe40a928892889288928892909116905160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b15156111d557600080fd5b6102c65a03f115156111e657600080fd5b50505050505050565b60005433600160a060020a0390811691161461120a57600080fd5b60025460a060020a900460ff16151561122257600080fd5b600b54600160a060020a0316151561123957600080fd5b600c54600160a060020a0316151561125057600080fd5b601054600160a060020a0316151561126757600080fd5b601254600160a060020a0316151561127e57600080fd5b601154600160a060020a0316151561129557600080fd5b601454600160a060020a0316156112ab57600080fd5b6112b3612bed565b565b600a60205260009081526040902054600160a060020a031681565b60025460009060a060020a900460ff16156112ea57600080fd5b60068054869081106112f857fe5b60009182526020909120600490910201600281015490915060c060020a900460ff161561132457600080fd5b61132e3386612a97565b151561133957600080fd5b6113428561235a565b151561134d57600080fd5b600c54611364908690600160a060020a0316612ab7565b600c54600160a060020a03166327ebe40a868686863360405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b15156113d357600080fd5b6102c65a03f115156113e457600080fd5b5050505050505050565b60025433600160a060020a0390811691161461140957600080fd5b6000811161141657600080fd5b600d55565b600e5481565b60025460a060020a900460ff161561143857600080fd5b6114423382612a97565b151561144d57600080fd5b6000908152600a602052604090208054600160a060020a031916600160a060020a0392909216919091179055565b60005433600160a060020a0390811691161461149657600080fd5b600160a060020a03811615156114ab57600080fd5b60018054600160a060020a031916600160a060020a0392909216919091179055565b60025433600160a060020a03908116911614806114f8575060005433600160a060020a039081169116145b80611511575060015433600160a060020a039081169116145b151561151c57600080fd5b60035463ffffffff16811061153057600080fd5b600555565b60025460a060020a900460ff1681565b600081815260076020526040902054600160a060020a0316801515610bb357600080fd5b619c4081565b601454600160a060020a031681565b600061158a3383612a97565b151561159557600080fd5b601254600160a060020a0316636bee2cc38360006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b15156115e657600080fd5b6102c65a03f115156115f757600080fd5b505050604051805160ff1615905061160e57600080fd5b601254610bb3903390600160a060020a031684612b05565b6000805433600160a060020a0390811691161461164257600080fd5b5080600160a060020a0381166385b861886000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561168a57600080fd5b6102c65a03f1151561169b57600080fd5b5050506040518051905015156116b057600080fd5b600b8054600160a060020a031916600160a060020a039290921691909117905550565b600160a060020a031660009081526008602052604090205490565b60005433600160a060020a0390811691161461170957600080fd5b60025460a060020a900460ff16151561172157600080fd5b60148054600160a060020a031916600160a060020a0383161790557f450db8da6efbe9c22f2347f7c2021231df1fc58d3ae9a2fa75d39fa44619930581604051600160a060020a03909116815260200160405180910390a150565b60055481565b600080600080600080600080600080600060068c8154811015156117a257fe5b906000526020600020906004020190508060020160149054906101000a900461ffff1661ffff169a508060020160009054906101000a900467ffffffffffffffff1667ffffffffffffffff1699508060020160109054906101000a900463ffffffff1663ffffffff169850806001015497508060020160089054906101000a900463ffffffff1663ffffffff16965080600201600c9054906101000a900463ffffffff1663ffffffff1695508060020160169054906101000a900461ffff1661ffff169450806000015493508060020160189054906101000a900460ff16925080600301549150509193959799509193959799565b60025433600160a060020a03908116911614806118c2575060005433600160a060020a039081169116145b806118db575060015433600160a060020a039081169116145b15156118e657600080fd5b60025460a060020a900460ff16156118fd57600080fd5b6002805474ff0000000000000000000000000000000000000000191660a060020a179055565b6000806000806000806000806000806000600260149054906101000a900460ff1615151561195057600080fd5b600680548d90811061195e57fe5b90600052602060002090600402019950896001015460001415151561198257600080fd5b611a2c8a61014060405190810160409081528254825260018301546020830152600283015467ffffffffffffffff81169183019190915263ffffffff68010000000000000000820481166060840152606060020a820481166080840152608060020a82041660a083015261ffff60a060020a8204811660c084015260b060020a82041660e083015260ff60c060020a90910416610100820152600390910154610120820152612c40565b1515611a3757600080fd5b60028a015460068054608060020a90920463ffffffff169a50908a908110611a5b57fe5b600091825260209091206002808d015460049093029091019081015490995061ffff60b060020a92839004811699509190041687901115611aa957600288015460b060020a900461ffff1696505b60028a015460b060020a900461ffff1615611ac8578960030154611aca565b8b5b6010548b548a5460028e0154939950600160a060020a0390921692630d9f5aed929067ffffffffffffffff166000190160006040516020015260405160e060020a63ffffffff86160281526004810193909352602483019190915267ffffffffffffffff166044820152606401602060405180830381600087803b1515611b5057600080fd5b6102c65a03f11515611b6157600080fd5b505050604051805160008e81526007602052604080822054601154600654949a50600160a060020a039182169950169350637b039bb69289929091516020015260405160e060020a63ffffffff851602815260048101929092526024820152604401602060405180830381600087803b1515611bdc57600080fd5b6102c65a03f11515611bed57600080fd5b505050604051805160028c015490945061ffff60b060020a82048116159450611c3192508e9163ffffffff608060020a909104169060018b01168888888c89612c78565b60028b01805473ffffffff0000000000000000000000000000000019169055600f8054600019019055905060ff831615611ce857601154600160a060020a0316632d0b7d53828660405160e060020a63ffffffff85160281526004810192909252600160a060020a03166024820152604401600060405180830381600087803b1515611cbc57600080fd5b6102c65a03f11515611ccd57600080fd5b5050601154611ce891508590600160a060020a031683612b05565b9b9a5050505050505050505050565b60408051908101604052600281527f4844000000000000000000000000000000000000000000000000000000000000602082015281565b600381600e8110611d3b57fe5b60089182820401919006600402915054906101000a900463ffffffff1681565b60025460009033600160a060020a03908116911614611d7957600080fd5b600d5482606402811515611d8957fe5b04905060008111611d9957600080fd5b6064821115611da757600080fd5b50600e55565b60025460a060020a900460ff1615611dc457600080fd5b600160a060020a0382161515611dd957600080fd5b30600160a060020a031682600160a060020a031614151515611dfa57600080fd5b600b54600160a060020a0383811691161415611e1557600080fd5b600c54600160a060020a0383811691161415611e3057600080fd5b611e3a3382612a97565b1515611e4557600080fd5b611e50338383612b05565b5050565b600254600090819033600160a060020a0390811691161480611e84575060005433600160a060020a039081169116145b80611e9d575060015433600160a060020a039081169116145b1515611ea857600080fd5b601354619c409010611eb957600080fd5b611ecd600080600086306000806000612c78565b9050611ed98133612ab7565b60138054600101905592915050565b600080600080600080600080600260149054906101000a900460ff16151515611f1057600080fd5b600680548a908110611f1e57fe5b60009182526020822060049190910201600281015490995060b060020a900461ffff16111561207757601254600160a060020a0316631d4f3e8b60006040516101e001526040518163ffffffff1660e060020a0281526004016101e060405180830381600087803b1515611f9157600080fd5b6102c65a03f11515611fa257600080fd5b5050506040518060e001805190602001805190602001805190602001805190602001805190602001805190602001805190602001805190602001604052505050505050985050508688600101541015612077576012548854600160a060020a039091169063f43acb529060006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561204b57600080fd5b6102c65a03f1151561205c57600080fd5b5050506040518051905060ff16606414151561207757600080fd5b600b54600160a060020a031663c55d0f568a60006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b15156120c857600080fd5b6102c65a03f115156120d957600080fd5b505050604051805196505034869010156120f257600080fd5b8815806120ff5750886001145b9450600093508415612112576005860493505b600b54600160a060020a0316632d3a926a8760006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561216357600080fd5b6102c65a03f1151561217457600080fd5b5050506040518051600b54909450600160a060020a03169050639f04996d85850188038b3360405160e060020a63ffffffff86160281526004810192909252600160a060020a031660248201526044016000604051808303818588803b15156121dc57600080fd5b6125ee5a03f115156121ed57600080fd5b5050505084156122ec57600154600160a060020a031684156108fc0285604051600060405180830381858888f19350505050151561222a57600080fd5b856002026fffffffffffffffffffffffffffffffff1691508582101561224e578591505b600b54612265908a90600160a060020a0316612ab7565b600b54600160a060020a03166327ebe40a8a8480620151803360405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b15156122d757600080fd5b6102c65a03f115156122e857600080fd5b5050505b8534039050600081111561232b57600160a060020a03331681156108fc0282604051600060405180830381858888f19350505050151561232b57600080fd5b505050505050505050565b600254600160a060020a031681565b600d5481565b601254600160a060020a031681565b6000806001831161236a57600080fd5b600680548490811061237857fe5b906000526020600020906004020190506124328161014060405190810160409081528254825260018301546020830152600283015467ffffffffffffffff81169183019190915263ffffffff68010000000000000000820481166060840152606060020a820481166080840152608060020a82041660a083015261ffff60a060020a8204811660c084015260b060020a82041660e083015260ff60c060020a90910416610100820152600390910154610120820152612f58565b9392505050565b600960205260009081526040902054600160a060020a031681565b6000805433600160a060020a0390811691161461247057600080fd5b5080600160a060020a0381166327757c496000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156124b857600080fd5b6102c65a03f115156124c957600080fd5b5050506040518051905015156124de57600080fd5b60118054600160a060020a031916600160a060020a039290921691909117905550565b601154600160a060020a031681565b600b54600160a060020a031681565b6000806000806000600260149054906101000a900460ff1615151561254357600080fd5b61254d3387612a97565b151561255857600080fd5b6125618661235a565b151561256c57600080fd5b6125768688612f8f565b151561258157600080fd5b600c54600160a060020a031663c55d0f568860006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b15156125d257600080fd5b6102c65a03f115156125e357600080fd5b505050604051805190509450600d548501935060068681548110151561260557fe5b60009182526020822060049190910201600281015490945060b060020a900461ffff16111561263657600e54840193505b348490101561264457600080fd5b600b54600160a060020a0316632d3a926a8660006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561269557600080fd5b6102c65a03f115156126a657600080fd5b5050506040518051600c54909350600160a060020a03169050639f04996d838703893360405160e060020a63ffffffff86160281526004810192909252600160a060020a031660248201526044016000604051808303818588803b151561270c57600080fd5b6125ee5a03f1151561271d57600080fd5b505050506127378663ffffffff168863ffffffff16612fe7565b833403905060008111156111e657600160a060020a03331681156108fc0282604051600060405180830381858888f1935050505015156111e657600080fd5b60125433600160a060020a03908116911614806127a1575060115433600160a060020a039081169116145b15156127ac57600080fd5b600160a060020a03301631819010156127c457600080fd5b600160a060020a03821681156108fc0282604051600060405180830381858888f193505050501515611e5057600080fd5b60135481565b601054600160a060020a031681565b60025460009081908190819060a060020a900460ff161561282a57600080fd5b600d54935060068681548110151561283e57fe5b60009182526020822060049190910201600281015490945060b060020a900461ffff16111561286f57600e54840193505b348490101561287d57600080fd5b6128873387612a97565b151561289257600080fd5b61289c85876133a4565b15156128a757600080fd5b6129518361014060405190810160409081528254825260018301546020830152600283015467ffffffffffffffff81169183019190915263ffffffff68010000000000000000820481166060840152606060020a820481166080840152608060020a82041660a083015261ffff60a060020a8204811660c084015260b060020a82041660e083015260ff60c060020a90910416610100820152600390910154610120820152612f58565b151561295c57600080fd5b600680548690811061296a57fe5b90600052602060002090600402019150612a248261014060405190810160409081528254825260018301546020830152600283015467ffffffffffffffff81169183019190915263ffffffff68010000000000000000820481166060840152606060020a820481166080840152608060020a82041660a083015261ffff60a060020a8204811660c084015260b060020a82041660e083015260ff60c060020a90910416610100820152600390910154610120820152612f58565b1515612a2f57600080fd5b612a3b838784886133f9565b1515612a4657600080fd5b612a508686612fe7565b83340390506000811115612a8f57600160a060020a03331681156108fc0282604051600060405180830381858888f193505050501515612a8f57600080fd5b505050505050565b600090815260076020526040902054600160a060020a0391821691161490565b6000918252600960205260409091208054600160a060020a031916600160a060020a03909216919091179055565b600090815260096020526040902054600160a060020a0391821691161490565b600160a060020a03808316600081815260086020908152604080832080546001019055858352600790915290208054600160a060020a0319169091179055831615612b9857600160a060020a03831660009081526008602090815260408083208054600019019055838352600a82528083208054600160a060020a03199081169091556009909252909120805490911690555b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef838383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a1505050565b60005433600160a060020a03908116911614612c0857600080fd5b60025460a060020a900460ff161515612c2057600080fd5b6002805474ff000000000000000000000000000000000000000019169055565b60008160a0015163ffffffff1615801590610bb057504367ffffffffffffffff16826040015167ffffffffffffffff16111592915050565b600080612c83613662565b600063ffffffff8c168c14612c9757600080fd5b63ffffffff8b168b14612ca957600080fd5b61ffff8a168a14612cb957600080fd5b60028a049250600d8361ffff161115612cd157600d92505b61014060405190810160409081528a8252436020830152600090820181905263ffffffff808f1660608401528d16608083015260a082015261ffff80851660c08301528b1660e082015260ff8816610100820152610120810187905260068054919350600191808301612d4483826136b6565b600092835260209092208591600402018151815560208201518160010155604082015160028201805467ffffffffffffffff191667ffffffffffffffff9290921691909117905560608201518160020160086101000a81548163ffffffff021916908363ffffffff160217905550608082015181600201600c6101000a81548163ffffffff021916908363ffffffff16021790555060a08201518160020160106101000a81548163ffffffff021916908363ffffffff16021790555060c08201518160020160146101000a81548161ffff021916908361ffff16021790555060e08201518160020160166101000a81548161ffff021916908361ffff1602179055506101008201518160020160186101000a81548160ff021916908360ff1602179055506101208201516003909101555003905063016c80008110612e8857600080fd5b7f746319248c02be7f11174ecd7121305fe37ffe8b19a6abef96df84f321a84e338882846060015163ffffffff16856080015163ffffffff1686518f8d8d438e612ed457600e54612ed7565b60005b8d604051600160a060020a03909b168b5260208b01999099526040808b019890985260608a0196909652608089019490945261ffff92831660a089015260ff90911660c088015260e087015261010086019190915261012085019190915291909116610140830152610160909101905180910390a1611ce860008983612b05565b60008160a0015163ffffffff16158015610bb057504367ffffffffffffffff16826040015167ffffffffffffffff16111592915050565b6000806000600685815481101515612fa357fe5b90600052602060002090600402019150600684815481101515612fc257fe5b90600052602060002090600402019050612fde828683876133f9565b95945050505050565b6000808060018511612ff857600080fd5b6001841161300557600080fd5b600680548590811061301357fe5b9060005260206000209060040201925060068581548110151561303257fe5b600091825260209091206002850154600490920201925060c060020a900460ff161561305d57600080fd5b600282015460c060020a900460ff161561307657600080fd5b6002820154600060b060020a90910461ffff1611156131bf57601254600160a060020a0316631d4f3e8b60006040516101e001526040518163ffffffff1660e060020a0281526004016101e060405180830381600087803b15156130d957600080fd5b6102c65a03f115156130ea57600080fd5b5050506040518060e0018051906020018051906020018051906020018051906020018051906020018051906020018051906020018051906020016040525050505050509250505080826001015410156131bf576012548254600160a060020a039091169063f43acb529060006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561319357600080fd5b6102c65a03f115156131a457600080fd5b5050506040518051905060ff1660641415156131bf57600080fd5b60028201805473ffffffff000000000000000000000000000000001916608060020a63ffffffff8716021790556131f58361359c565b6131fe8261359c565b6000858152600a60205260408082208054600160a060020a0319908116909155868352918190208054909216909155600f8054600190810190915554600d54600160a060020a03909116916108fc821502919051600060405180830381858888f19350505050151561326f57600080fd5b6002820154600060b060020a90910461ffff1611156132d35760038201546000908152600760205260409081902054600e54600160a060020a039091169181156108fc02919051600060405180830381858888f1935050505015156132d357600080fd5b6000858152600760205260409081902054600280850154908601547f1ee9be14ee585b164bf130cf7a98acb8ec21d44ae3cf64cd149aee4dcc59232193600160a060020a03909316928992899267ffffffffffffffff808316939082169261ffff60a060020a9182900481169391909104169051600160a060020a039097168752602087019590955260408087019490945267ffffffffffffffff92831660608701529116608085015261ffff90811660a08501529190911660c083015260e0909101905180910390a15050505050565b6000818152600760205260408082205484835290822054600160a060020a03918216911680821480612fde57506000858152600a6020526040902054600160a060020a03908116908316149250505092915050565b60008184141561340b57506000613594565b600285015468010000000000000000900463ffffffff1682148061343f57506002850154606060020a900463ffffffff1682145b1561344c57506000613594565b600283015468010000000000000000900463ffffffff1684148061348057506002830154606060020a900463ffffffff1684145b1561348d57506000613594565b600283015468010000000000000000900463ffffffff1615806134c45750600285015468010000000000000000900463ffffffff16155b156134d157506001613594565b60028581015490840154680100000000000000009182900463ffffffff9081169290910416148061352657506002808601549084015468010000000000000000900463ffffffff908116606060020a90920416145b1561353357506000613594565b60028086015490840154606060020a900463ffffffff90811668010000000000000000909204161480613583575060028581015490840154606060020a9182900463ffffffff9081169290910416145b1561359057506000613594565b5060015b949350505050565b600554600282015443919060039060a060020a900461ffff16600e81106135bf57fe5b600891828204019190066004029054906101000a900463ffffffff1663ffffffff168115156135ea57fe5b60028401805467ffffffffffffffff1916929091049290920167ffffffffffffffff161790819055600d60a060020a90910461ffff16101561365f5760028101805461ffff60a060020a80830482166001019091160275ffff0000000000000000000000000000000000000000199091161790555b50565b6101406040519081016040908152600080835260208301819052908201819052606082018190526080820181905260a0820181905260c0820181905260e08201819052610100820181905261012082015290565b815481835581811511610edd57600083815260209020610edd91610e089160049182028101918502015b808211156137255760008082556001820181905560028201805478ffffffffffffffffffffffffffffffffffffffffffffffffff1916905560038201556004016136e0565b50905600a165627a7a72305820e01537532351c06f7282172fe62e22f83cd9716c5b9462261446b2fe601c48590029

Deployed Bytecode

0x60606040526004361061029a5763ffffffff60e060020a60003504166301ffc9a781146102eb5780630519ce791461033757806306fdde0314610366578063095ea7b3146103f05780630a0f8168146104125780630e0bc104146104255780630e583df01461044a57806314001f4c1461045d57806318160ddd1461047c5780631940a9361461048f57806319c2f201146104a557806321717ebf146104b857806323b872dd146104cb57806324e7a38a146104f357806327d7874c146105125780632a332b2a146105315780632ba73c15146105505780633369c33d1461056f5780633d7d3f5a146105825780633f4ba83a146105a157806346116e6f146105b45780634ad8c938146105ca5780634b85fd55146105e95780634d42fc66146105ff5780634dfff04f146106125780634e0a3379146106345780635663896e146106535780635c975abb146106695780636352211e1461067c578063680eba27146106925780636af04a57146106a55780636bee2cc3146106b85780636fbde40d146106e457806370a082311461070357806371587988146107225780637a7d4937146107415780637c62e2a4146107545780638456cb59146107c357806388c2a0bf146107d657806395d89b41146107ec5780639d6fac6f146107ff578063a5ef0dd61461082e578063a9059cbb14610844578063ab0a986514610866578063ad25ce571461087c578063b047fb5014610887578063b0c35c051461089a578063ba13a572146108ad578063d3e6f49f146108c0578063d83970a1146108d6578063dff00e92146108ec578063e015d8631461090b578063e6cbe3511461091e578063ed60ade614610931578063ee4ae2c91461093f578063f1ca941014610961578063f2b47d5214610974578063f7d8c88314610987575b600b5433600160a060020a03908116911614806102c55750600c5433600160a060020a039081169116145b806102de575060005433600160a060020a039081169116145b15156102e957600080fd5b005b34156102f657600080fd5b6103237fffffffff0000000000000000000000000000000000000000000000000000000060043516610995565b604051901515815260200160405180910390f35b341561034257600080fd5b61034a610bb8565b604051600160a060020a03909116815260200160405180910390f35b341561037157600080fd5b610379610bc7565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156103b557808201518382015260200161039d565b50505050905090810190601f1680156103e25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103fb57600080fd5b6102e9600160a060020a0360043516602435610bfe565b341561041d57600080fd5b61034a610c88565b341561043057600080fd5b610438610c97565b60405190815260200160405180910390f35b341561045557600080fd5b610438610d47565b341561046857600080fd5b6102e9600160a060020a0360043516610d53565b341561048757600080fd5b610438610e00565b341561049a57600080fd5b610323600435610e0b565b34156104b057600080fd5b610438610e45565b34156104c357600080fd5b61034a610e4c565b34156104d657600080fd5b6102e9600160a060020a0360043581169060243516604435610e5b565b34156104fe57600080fd5b6102e9600160a060020a0360043516610ee2565b341561051d57600080fd5b6102e9600160a060020a0360043516610f8f565b341561053c57600080fd5b6102e9600160a060020a0360043516610fe1565b341561055b57600080fd5b6102e9600160a060020a036004351661108e565b341561057a57600080fd5b6104386110e0565b341561058d57600080fd5b6102e96004356024356044356064356110e6565b34156105ac57600080fd5b6102e96111ef565b34156105bf57600080fd5b61034a6004356112b5565b34156105d557600080fd5b6102e96004356024356044356064356112d0565b34156105f457600080fd5b6102e96004356113ee565b341561060a57600080fd5b61043861141b565b341561061d57600080fd5b6102e9600160a060020a0360043516602435611421565b341561063f57600080fd5b6102e9600160a060020a036004351661147b565b341561065e57600080fd5b6102e96004356114cd565b341561067457600080fd5b610323611535565b341561068757600080fd5b61034a600435611545565b341561069d57600080fd5b610438611569565b34156106b057600080fd5b61034a61156f565b34156106c357600080fd5b6106ce60043561157e565b60405160ff909116815260200160405180910390f35b34156106ef57600080fd5b6102e9600160a060020a0360043516611626565b341561070e57600080fd5b610438600160a060020a03600435166116d3565b341561072d57600080fd5b6102e9600160a060020a03600435166116ee565b341561074c57600080fd5b61043861177c565b341561075f57600080fd5b61076a600435611782565b604051998a5260208a01989098526040808a01979097526060890195909552608088019390935260a087019190915260c086015260e085015260ff16610100840152610120830191909152610140909101905180910390f35b34156107ce57600080fd5b6102e9611897565b34156107e157600080fd5b610438600435611923565b34156107f757600080fd5b610379611cf7565b341561080a57600080fd5b610815600435611d2e565b60405163ffffffff909116815260200160405180910390f35b341561083957600080fd5b6102e9600435611d5b565b341561084f57600080fd5b6102e9600160a060020a0360043516602435611dad565b341561087157600080fd5b610438600435611e54565b6102e9600435611ee8565b341561089257600080fd5b61034a612336565b34156108a557600080fd5b610438612345565b34156108b857600080fd5b61034a61234b565b34156108cb57600080fd5b61032360043561235a565b34156108e157600080fd5b61034a600435612439565b34156108f757600080fd5b6102e9600160a060020a0360043516612454565b341561091657600080fd5b61034a612501565b341561092957600080fd5b61034a612510565b6102e960043560243561251f565b341561094a57600080fd5b6102e9600160a060020a0360043516602435612776565b341561096c57600080fd5b6104386127f5565b341561097f57600080fd5b61034a6127fb565b6102e960043560243561280a565b60006040517f737570706f727473496e7465726661636528627974657334290000000000000081526019016040518091039020600160e060020a03191682600160e060020a0319161480610bb057506040517f7472616e7366657246726f6d28616464726573732c616464726573732c75696e81527f7432353629000000000000000000000000000000000000000000000000000000602082015260250160405180910390206040517f7472616e7366657228616464726573732c75696e743235362900000000000000815260190160405180910390206040517f617070726f766528616464726573732c75696e74323536290000000000000000815260180160405180910390206040517f6f776e65724f662875696e743235362900000000000000000000000000000000815260100160405180910390206040517f62616c616e63654f662861646472657373290000000000000000000000000000815260120160405180910390206040517f746f74616c537570706c792829000000000000000000000000000000000000008152600d0160405180910390206040517f73796d626f6c2829000000000000000000000000000000000000000000000000815260080160405180910390206040517f6e616d65282900000000000000000000000000000000000000000000000000008152600601604051809103902018181818181818600160e060020a03191682600160e060020a031916145b90505b919050565b600154600160a060020a031681565b60408051908101604052600881527f48656c6c6f446f67000000000000000000000000000000000000000000000000602082015281565b60025460a060020a900460ff1615610c1557600080fd5b610c1f3382612a97565b1515610c2a57600080fd5b610c348183612ab7565b7f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925338383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a15050565b600054600160a060020a031681565b600b5460009081908190600160a060020a031663eac9d94c82604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610ce557600080fd5b6102c65a03f11515610cf657600080fd5b50505060405180519250506fffffffffffffffffffffffffffffffff82168214610d1f57600080fd5b506002810481016702c68af0bb140000811015610d4157506702c68af0bb1400005b92915050565b6702c68af0bb14000081565b6000805433600160a060020a03908116911614610d6f57600080fd5b5080600160a060020a0381166376190f8f6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610db757600080fd5b6102c65a03f11515610dc857600080fd5b505050604051805190501515610ddd57600080fd5b600c8054600160a060020a031916600160a060020a039290921691909117905550565b600654600019015b90565b6000600682815481101515610e1c57fe5b6000918252602090912060049091020160020154608060020a900463ffffffff16151592915050565b6201518081565b600c54600160a060020a031681565b60025460a060020a900460ff1615610e7257600080fd5b600160a060020a0382161515610e8757600080fd5b30600160a060020a031682600160a060020a031614151515610ea857600080fd5b610eb23382612ae5565b1515610ebd57600080fd5b610ec78382612a97565b1515610ed257600080fd5b610edd838383612b05565b505050565b6000805433600160a060020a03908116911614610efe57600080fd5b5080600160a060020a0381166354c15b826000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610f4657600080fd5b6102c65a03f11515610f5757600080fd5b505050604051805190501515610f6c57600080fd5b60108054600160a060020a031916600160a060020a039290921691909117905550565b60005433600160a060020a03908116911614610faa57600080fd5b600160a060020a0381161515610fbf57600080fd5b60008054600160a060020a031916600160a060020a0392909216919091179055565b6000805433600160a060020a03908116911614610ffd57600080fd5b5080600160a060020a0381166325698d896000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561104557600080fd5b6102c65a03f1151561105657600080fd5b50505060405180519050151561106b57600080fd5b60128054600160a060020a031916600160a060020a039290921691909117905550565b60005433600160a060020a039081169116146110a957600080fd5b600160a060020a03811615156110be57600080fd5b60028054600160a060020a031916600160a060020a0392909216919091179055565b600f5481565b60025460a060020a900460ff16156110fd57600080fd5b6111073385612a97565b8061111757506111173385612ae5565b151561112257600080fd5b61112b84610e0b565b1561113557600080fd5b600b5461114c908590600160a060020a0316612ab7565b600b546000858152600760205260409081902054600160a060020a03928316926327ebe40a928892889288928892909116905160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b15156111d557600080fd5b6102c65a03f115156111e657600080fd5b50505050505050565b60005433600160a060020a0390811691161461120a57600080fd5b60025460a060020a900460ff16151561122257600080fd5b600b54600160a060020a0316151561123957600080fd5b600c54600160a060020a0316151561125057600080fd5b601054600160a060020a0316151561126757600080fd5b601254600160a060020a0316151561127e57600080fd5b601154600160a060020a0316151561129557600080fd5b601454600160a060020a0316156112ab57600080fd5b6112b3612bed565b565b600a60205260009081526040902054600160a060020a031681565b60025460009060a060020a900460ff16156112ea57600080fd5b60068054869081106112f857fe5b60009182526020909120600490910201600281015490915060c060020a900460ff161561132457600080fd5b61132e3386612a97565b151561133957600080fd5b6113428561235a565b151561134d57600080fd5b600c54611364908690600160a060020a0316612ab7565b600c54600160a060020a03166327ebe40a868686863360405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b15156113d357600080fd5b6102c65a03f115156113e457600080fd5b5050505050505050565b60025433600160a060020a0390811691161461140957600080fd5b6000811161141657600080fd5b600d55565b600e5481565b60025460a060020a900460ff161561143857600080fd5b6114423382612a97565b151561144d57600080fd5b6000908152600a602052604090208054600160a060020a031916600160a060020a0392909216919091179055565b60005433600160a060020a0390811691161461149657600080fd5b600160a060020a03811615156114ab57600080fd5b60018054600160a060020a031916600160a060020a0392909216919091179055565b60025433600160a060020a03908116911614806114f8575060005433600160a060020a039081169116145b80611511575060015433600160a060020a039081169116145b151561151c57600080fd5b60035463ffffffff16811061153057600080fd5b600555565b60025460a060020a900460ff1681565b600081815260076020526040902054600160a060020a0316801515610bb357600080fd5b619c4081565b601454600160a060020a031681565b600061158a3383612a97565b151561159557600080fd5b601254600160a060020a0316636bee2cc38360006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b15156115e657600080fd5b6102c65a03f115156115f757600080fd5b505050604051805160ff1615905061160e57600080fd5b601254610bb3903390600160a060020a031684612b05565b6000805433600160a060020a0390811691161461164257600080fd5b5080600160a060020a0381166385b861886000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561168a57600080fd5b6102c65a03f1151561169b57600080fd5b5050506040518051905015156116b057600080fd5b600b8054600160a060020a031916600160a060020a039290921691909117905550565b600160a060020a031660009081526008602052604090205490565b60005433600160a060020a0390811691161461170957600080fd5b60025460a060020a900460ff16151561172157600080fd5b60148054600160a060020a031916600160a060020a0383161790557f450db8da6efbe9c22f2347f7c2021231df1fc58d3ae9a2fa75d39fa44619930581604051600160a060020a03909116815260200160405180910390a150565b60055481565b600080600080600080600080600080600060068c8154811015156117a257fe5b906000526020600020906004020190508060020160149054906101000a900461ffff1661ffff169a508060020160009054906101000a900467ffffffffffffffff1667ffffffffffffffff1699508060020160109054906101000a900463ffffffff1663ffffffff169850806001015497508060020160089054906101000a900463ffffffff1663ffffffff16965080600201600c9054906101000a900463ffffffff1663ffffffff1695508060020160169054906101000a900461ffff1661ffff169450806000015493508060020160189054906101000a900460ff16925080600301549150509193959799509193959799565b60025433600160a060020a03908116911614806118c2575060005433600160a060020a039081169116145b806118db575060015433600160a060020a039081169116145b15156118e657600080fd5b60025460a060020a900460ff16156118fd57600080fd5b6002805474ff0000000000000000000000000000000000000000191660a060020a179055565b6000806000806000806000806000806000600260149054906101000a900460ff1615151561195057600080fd5b600680548d90811061195e57fe5b90600052602060002090600402019950896001015460001415151561198257600080fd5b611a2c8a61014060405190810160409081528254825260018301546020830152600283015467ffffffffffffffff81169183019190915263ffffffff68010000000000000000820481166060840152606060020a820481166080840152608060020a82041660a083015261ffff60a060020a8204811660c084015260b060020a82041660e083015260ff60c060020a90910416610100820152600390910154610120820152612c40565b1515611a3757600080fd5b60028a015460068054608060020a90920463ffffffff169a50908a908110611a5b57fe5b600091825260209091206002808d015460049093029091019081015490995061ffff60b060020a92839004811699509190041687901115611aa957600288015460b060020a900461ffff1696505b60028a015460b060020a900461ffff1615611ac8578960030154611aca565b8b5b6010548b548a5460028e0154939950600160a060020a0390921692630d9f5aed929067ffffffffffffffff166000190160006040516020015260405160e060020a63ffffffff86160281526004810193909352602483019190915267ffffffffffffffff166044820152606401602060405180830381600087803b1515611b5057600080fd5b6102c65a03f11515611b6157600080fd5b505050604051805160008e81526007602052604080822054601154600654949a50600160a060020a039182169950169350637b039bb69289929091516020015260405160e060020a63ffffffff851602815260048101929092526024820152604401602060405180830381600087803b1515611bdc57600080fd5b6102c65a03f11515611bed57600080fd5b505050604051805160028c015490945061ffff60b060020a82048116159450611c3192508e9163ffffffff608060020a909104169060018b01168888888c89612c78565b60028b01805473ffffffff0000000000000000000000000000000019169055600f8054600019019055905060ff831615611ce857601154600160a060020a0316632d0b7d53828660405160e060020a63ffffffff85160281526004810192909252600160a060020a03166024820152604401600060405180830381600087803b1515611cbc57600080fd5b6102c65a03f11515611ccd57600080fd5b5050601154611ce891508590600160a060020a031683612b05565b9b9a5050505050505050505050565b60408051908101604052600281527f4844000000000000000000000000000000000000000000000000000000000000602082015281565b600381600e8110611d3b57fe5b60089182820401919006600402915054906101000a900463ffffffff1681565b60025460009033600160a060020a03908116911614611d7957600080fd5b600d5482606402811515611d8957fe5b04905060008111611d9957600080fd5b6064821115611da757600080fd5b50600e55565b60025460a060020a900460ff1615611dc457600080fd5b600160a060020a0382161515611dd957600080fd5b30600160a060020a031682600160a060020a031614151515611dfa57600080fd5b600b54600160a060020a0383811691161415611e1557600080fd5b600c54600160a060020a0383811691161415611e3057600080fd5b611e3a3382612a97565b1515611e4557600080fd5b611e50338383612b05565b5050565b600254600090819033600160a060020a0390811691161480611e84575060005433600160a060020a039081169116145b80611e9d575060015433600160a060020a039081169116145b1515611ea857600080fd5b601354619c409010611eb957600080fd5b611ecd600080600086306000806000612c78565b9050611ed98133612ab7565b60138054600101905592915050565b600080600080600080600080600260149054906101000a900460ff16151515611f1057600080fd5b600680548a908110611f1e57fe5b60009182526020822060049190910201600281015490995060b060020a900461ffff16111561207757601254600160a060020a0316631d4f3e8b60006040516101e001526040518163ffffffff1660e060020a0281526004016101e060405180830381600087803b1515611f9157600080fd5b6102c65a03f11515611fa257600080fd5b5050506040518060e001805190602001805190602001805190602001805190602001805190602001805190602001805190602001805190602001604052505050505050985050508688600101541015612077576012548854600160a060020a039091169063f43acb529060006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561204b57600080fd5b6102c65a03f1151561205c57600080fd5b5050506040518051905060ff16606414151561207757600080fd5b600b54600160a060020a031663c55d0f568a60006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b15156120c857600080fd5b6102c65a03f115156120d957600080fd5b505050604051805196505034869010156120f257600080fd5b8815806120ff5750886001145b9450600093508415612112576005860493505b600b54600160a060020a0316632d3a926a8760006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561216357600080fd5b6102c65a03f1151561217457600080fd5b5050506040518051600b54909450600160a060020a03169050639f04996d85850188038b3360405160e060020a63ffffffff86160281526004810192909252600160a060020a031660248201526044016000604051808303818588803b15156121dc57600080fd5b6125ee5a03f115156121ed57600080fd5b5050505084156122ec57600154600160a060020a031684156108fc0285604051600060405180830381858888f19350505050151561222a57600080fd5b856002026fffffffffffffffffffffffffffffffff1691508582101561224e578591505b600b54612265908a90600160a060020a0316612ab7565b600b54600160a060020a03166327ebe40a8a8480620151803360405160e060020a63ffffffff88160281526004810195909552602485019390935260448401919091526064830152600160a060020a0316608482015260a401600060405180830381600087803b15156122d757600080fd5b6102c65a03f115156122e857600080fd5b5050505b8534039050600081111561232b57600160a060020a03331681156108fc0282604051600060405180830381858888f19350505050151561232b57600080fd5b505050505050505050565b600254600160a060020a031681565b600d5481565b601254600160a060020a031681565b6000806001831161236a57600080fd5b600680548490811061237857fe5b906000526020600020906004020190506124328161014060405190810160409081528254825260018301546020830152600283015467ffffffffffffffff81169183019190915263ffffffff68010000000000000000820481166060840152606060020a820481166080840152608060020a82041660a083015261ffff60a060020a8204811660c084015260b060020a82041660e083015260ff60c060020a90910416610100820152600390910154610120820152612f58565b9392505050565b600960205260009081526040902054600160a060020a031681565b6000805433600160a060020a0390811691161461247057600080fd5b5080600160a060020a0381166327757c496000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156124b857600080fd5b6102c65a03f115156124c957600080fd5b5050506040518051905015156124de57600080fd5b60118054600160a060020a031916600160a060020a039290921691909117905550565b601154600160a060020a031681565b600b54600160a060020a031681565b6000806000806000600260149054906101000a900460ff1615151561254357600080fd5b61254d3387612a97565b151561255857600080fd5b6125618661235a565b151561256c57600080fd5b6125768688612f8f565b151561258157600080fd5b600c54600160a060020a031663c55d0f568860006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b15156125d257600080fd5b6102c65a03f115156125e357600080fd5b505050604051805190509450600d548501935060068681548110151561260557fe5b60009182526020822060049190910201600281015490945060b060020a900461ffff16111561263657600e54840193505b348490101561264457600080fd5b600b54600160a060020a0316632d3a926a8660006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561269557600080fd5b6102c65a03f115156126a657600080fd5b5050506040518051600c54909350600160a060020a03169050639f04996d838703893360405160e060020a63ffffffff86160281526004810192909252600160a060020a031660248201526044016000604051808303818588803b151561270c57600080fd5b6125ee5a03f1151561271d57600080fd5b505050506127378663ffffffff168863ffffffff16612fe7565b833403905060008111156111e657600160a060020a03331681156108fc0282604051600060405180830381858888f1935050505015156111e657600080fd5b60125433600160a060020a03908116911614806127a1575060115433600160a060020a039081169116145b15156127ac57600080fd5b600160a060020a03301631819010156127c457600080fd5b600160a060020a03821681156108fc0282604051600060405180830381858888f193505050501515611e5057600080fd5b60135481565b601054600160a060020a031681565b60025460009081908190819060a060020a900460ff161561282a57600080fd5b600d54935060068681548110151561283e57fe5b60009182526020822060049190910201600281015490945060b060020a900461ffff16111561286f57600e54840193505b348490101561287d57600080fd5b6128873387612a97565b151561289257600080fd5b61289c85876133a4565b15156128a757600080fd5b6129518361014060405190810160409081528254825260018301546020830152600283015467ffffffffffffffff81169183019190915263ffffffff68010000000000000000820481166060840152606060020a820481166080840152608060020a82041660a083015261ffff60a060020a8204811660c084015260b060020a82041660e083015260ff60c060020a90910416610100820152600390910154610120820152612f58565b151561295c57600080fd5b600680548690811061296a57fe5b90600052602060002090600402019150612a248261014060405190810160409081528254825260018301546020830152600283015467ffffffffffffffff81169183019190915263ffffffff68010000000000000000820481166060840152606060020a820481166080840152608060020a82041660a083015261ffff60a060020a8204811660c084015260b060020a82041660e083015260ff60c060020a90910416610100820152600390910154610120820152612f58565b1515612a2f57600080fd5b612a3b838784886133f9565b1515612a4657600080fd5b612a508686612fe7565b83340390506000811115612a8f57600160a060020a03331681156108fc0282604051600060405180830381858888f193505050501515612a8f57600080fd5b505050505050565b600090815260076020526040902054600160a060020a0391821691161490565b6000918252600960205260409091208054600160a060020a031916600160a060020a03909216919091179055565b600090815260096020526040902054600160a060020a0391821691161490565b600160a060020a03808316600081815260086020908152604080832080546001019055858352600790915290208054600160a060020a0319169091179055831615612b9857600160a060020a03831660009081526008602090815260408083208054600019019055838352600a82528083208054600160a060020a03199081169091556009909252909120805490911690555b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef838383604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a1505050565b60005433600160a060020a03908116911614612c0857600080fd5b60025460a060020a900460ff161515612c2057600080fd5b6002805474ff000000000000000000000000000000000000000019169055565b60008160a0015163ffffffff1615801590610bb057504367ffffffffffffffff16826040015167ffffffffffffffff16111592915050565b600080612c83613662565b600063ffffffff8c168c14612c9757600080fd5b63ffffffff8b168b14612ca957600080fd5b61ffff8a168a14612cb957600080fd5b60028a049250600d8361ffff161115612cd157600d92505b61014060405190810160409081528a8252436020830152600090820181905263ffffffff808f1660608401528d16608083015260a082015261ffff80851660c08301528b1660e082015260ff8816610100820152610120810187905260068054919350600191808301612d4483826136b6565b600092835260209092208591600402018151815560208201518160010155604082015160028201805467ffffffffffffffff191667ffffffffffffffff9290921691909117905560608201518160020160086101000a81548163ffffffff021916908363ffffffff160217905550608082015181600201600c6101000a81548163ffffffff021916908363ffffffff16021790555060a08201518160020160106101000a81548163ffffffff021916908363ffffffff16021790555060c08201518160020160146101000a81548161ffff021916908361ffff16021790555060e08201518160020160166101000a81548161ffff021916908361ffff1602179055506101008201518160020160186101000a81548160ff021916908360ff1602179055506101208201516003909101555003905063016c80008110612e8857600080fd5b7f746319248c02be7f11174ecd7121305fe37ffe8b19a6abef96df84f321a84e338882846060015163ffffffff16856080015163ffffffff1686518f8d8d438e612ed457600e54612ed7565b60005b8d604051600160a060020a03909b168b5260208b01999099526040808b019890985260608a0196909652608089019490945261ffff92831660a089015260ff90911660c088015260e087015261010086019190915261012085019190915291909116610140830152610160909101905180910390a1611ce860008983612b05565b60008160a0015163ffffffff16158015610bb057504367ffffffffffffffff16826040015167ffffffffffffffff16111592915050565b6000806000600685815481101515612fa357fe5b90600052602060002090600402019150600684815481101515612fc257fe5b90600052602060002090600402019050612fde828683876133f9565b95945050505050565b6000808060018511612ff857600080fd5b6001841161300557600080fd5b600680548590811061301357fe5b9060005260206000209060040201925060068581548110151561303257fe5b600091825260209091206002850154600490920201925060c060020a900460ff161561305d57600080fd5b600282015460c060020a900460ff161561307657600080fd5b6002820154600060b060020a90910461ffff1611156131bf57601254600160a060020a0316631d4f3e8b60006040516101e001526040518163ffffffff1660e060020a0281526004016101e060405180830381600087803b15156130d957600080fd5b6102c65a03f115156130ea57600080fd5b5050506040518060e0018051906020018051906020018051906020018051906020018051906020018051906020018051906020018051906020016040525050505050509250505080826001015410156131bf576012548254600160a060020a039091169063f43acb529060006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561319357600080fd5b6102c65a03f115156131a457600080fd5b5050506040518051905060ff1660641415156131bf57600080fd5b60028201805473ffffffff000000000000000000000000000000001916608060020a63ffffffff8716021790556131f58361359c565b6131fe8261359c565b6000858152600a60205260408082208054600160a060020a0319908116909155868352918190208054909216909155600f8054600190810190915554600d54600160a060020a03909116916108fc821502919051600060405180830381858888f19350505050151561326f57600080fd5b6002820154600060b060020a90910461ffff1611156132d35760038201546000908152600760205260409081902054600e54600160a060020a039091169181156108fc02919051600060405180830381858888f1935050505015156132d357600080fd5b6000858152600760205260409081902054600280850154908601547f1ee9be14ee585b164bf130cf7a98acb8ec21d44ae3cf64cd149aee4dcc59232193600160a060020a03909316928992899267ffffffffffffffff808316939082169261ffff60a060020a9182900481169391909104169051600160a060020a039097168752602087019590955260408087019490945267ffffffffffffffff92831660608701529116608085015261ffff90811660a08501529190911660c083015260e0909101905180910390a15050505050565b6000818152600760205260408082205484835290822054600160a060020a03918216911680821480612fde57506000858152600a6020526040902054600160a060020a03908116908316149250505092915050565b60008184141561340b57506000613594565b600285015468010000000000000000900463ffffffff1682148061343f57506002850154606060020a900463ffffffff1682145b1561344c57506000613594565b600283015468010000000000000000900463ffffffff1684148061348057506002830154606060020a900463ffffffff1684145b1561348d57506000613594565b600283015468010000000000000000900463ffffffff1615806134c45750600285015468010000000000000000900463ffffffff16155b156134d157506001613594565b60028581015490840154680100000000000000009182900463ffffffff9081169290910416148061352657506002808601549084015468010000000000000000900463ffffffff908116606060020a90920416145b1561353357506000613594565b60028086015490840154606060020a900463ffffffff90811668010000000000000000909204161480613583575060028581015490840154606060020a9182900463ffffffff9081169290910416145b1561359057506000613594565b5060015b949350505050565b600554600282015443919060039060a060020a900461ffff16600e81106135bf57fe5b600891828204019190066004029054906101000a900463ffffffff1663ffffffff168115156135ea57fe5b60028401805467ffffffffffffffff1916929091049290920167ffffffffffffffff161790819055600d60a060020a90910461ffff16101561365f5760028101805461ffff60a060020a80830482166001019091160275ffff0000000000000000000000000000000000000000199091161790555b50565b6101406040519081016040908152600080835260208301819052908201819052606082018190526080820181905260a0820181905260c0820181905260e08201819052610100820181905261012082015290565b815481835581811511610edd57600083815260209020610edd91610e089160049182028101918502015b808211156137255760008082556001820181905560028201805478ffffffffffffffffffffffffffffffffffffffffffffffffff1916905560038201556004016136e0565b50905600a165627a7a72305820e01537532351c06f7282172fe62e22f83cd9716c5b9462261446b2fe601c48590029

Swarm Source

bzzr://e01537532351c06f7282172fe62e22f83cd9716c5b9462261446b2fe601c4859

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.