This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contract SaleClockAuction is ClockAuction { | |
| bool public isSaleClockAuction = true; | |
| // Tracks last 5 sale price of gen0 kitty sales | |
| uint256 public gen0SaleCount; | |
| uint256[5] public lastGen0SalePrices; | |
| // Updates lastSalePrice if seller is the nft contract | |
| // Otherwise, works the same as default bid method. | |
| function bid(uint256 _tokenId) external payable { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contract KittyAuction is KittyBreeding { | |
| SaleClockAuction public saleAuction; | |
| SiringClockAuction public siringAuction; | |
| function setSaleAuctionAddress(address _address) external onlyCEO { | |
| SaleClockAuction candidateContract = SaleClockAuction(_address); | |
| require(candidateContract.isSaleClockAuction()); | |
| saleAuction = candidateContract; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contract ClockAuction is Pausable, ClockAuctionBase { | |
| // 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 | |
| function withdrawBalance() external { | |
| address nftAddress = address(nonFungibleContract); | |
| require(msg.sender == owner || msg.sender == nftAddress); | |
| bool res = nftAddress.send(this.balance); | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contract ClockAuctionBase { | |
| struct Auction { | |
| address seller; | |
| uint128 startingPrice; | |
| uint128 endingPrice; | |
| uint64 duration; | |
| uint64 startedAt; // 0 if this auction has been concluded | |
| } | |
| uint256 public ownerCut; // measured in basis points (1/100 of a percent) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contract KittyBreeding is KittyOwnership { | |
| // The address of the sibling contract that is used to implement the sooper-sekret | |
| // genetic combination algorithm. | |
| GeneScienceInterface public geneScience; | |
| function setGeneScienceAddress(address _address) external onlyCEO { | |
| GeneScienceInterface candidateContract = GeneScienceInterface(_address); | |
| require(candidateContract.isGeneScience()); | |
| geneScience = candidateContract; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contract KittyBreeding is KittyOwnership { | |
| uint256 public autoBirthFee = 2 finney; // autoBirth is explained in the article | |
| uint256 public pregnantKitties; // number of pregnant kitties | |
| function _isReadyToBreed(Kitty _kit) internal view returns (bool) { | |
| return (_kit.siringWithId == 0) && (_kit.cooldownEndBlock <= uint64(block.number)); | |
| } | |
| function _isReadyToGiveBirth(Kitty _matron) private view returns (bool) { | |
| return (_matron.siringWithId != 0) && (_matron.cooldownEndBlock <= uint64(block.number)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contract KittyCore is KittyMinting { | |
| function KittyCore() public { | |
| paused = true; | |
| // the creator of the contract is the initial CEO and COO | |
| ceoAddress = msg.sender; | |
| cooAddress = msg.sender; | |
| // start with the mythical kitten 0 - so we don't have generation-0 parent issues | |
| _createKitty(0, 0, 0, uint256(-1), address(0)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contract KittyMinting is KittyAuction { | |
| uint256 public constant PROMO_CREATION_LIMIT = 5000; | |
| uint256 public constant GEN0_CREATION_LIMIT = 45000; | |
| uint256 public constant GEN0_STARTING_PRICE = 10 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contract KittyBase is KittyAccessControl { | |
| struct Kitty { | |
| uint256 genes; // genetic code packed into 256 bits | |
| uint64 birthTime; | |
| uint64 cooldownEndBlock; // cooldown after breeding | |
| uint32 matronId; // mom's ID | |
| uint32 sireId; // dad's ID | |
| uint32 siringWithId; // if set then pregnant | |
| uint16 cooldownIndex; // like age. bigger it is, longer is the cooldown | |
| uint16 generation; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contract KittyAccessControl { | |
| address public ceoAddress; | |
| address public cfoAddress; | |
| address public cooAddress; | |
| modifier onlyCEO() { | |
| require(msg.sender == ceoAddress); | |
| _; | |
| } | |
| // ...same functions for CFO and COO |