编译器
0.8.15+commit.e14f2714
文件 1 的 27:Address.sol
pragma solidity ^0.8.1;
library Address {
function isContract(address account) internal view returns (bool) {
return account.code.length > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
文件 2 的 27:Barn.sol
pragma solidity 0.8.15;
import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';
import '@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol';
import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/security/ReentrancyGuard.sol';
import '@openzeppelin/contracts/vendor/arbitrum/IArbSys.sol';
import './CatMouse.sol';
import './Rice.sol';
contract Barn is Ownable, IERC721Receiver, ERC721Holder, ReentrancyGuard {
struct UserInfo {
uint256 alphaTotal;
uint256 rewardDebt;
uint256 unclaimedRewards;
}
struct UserInvitedInfo {
uint256 totalInvited;
uint256 totalRewards;
uint256 claimedRewards;
}
mapping(address => mapping(uint16 => uint16)) private _ownedTokens;
mapping(uint16 => uint16) private _ownedTokensIndex;
mapping(address => uint16) private _balances;
mapping(uint16 => address) public ownerOf;
mapping(address => UserInfo) public mouseStaked;
mapping(address => UserInfo) public catStaked;
mapping(address => address) public invitedBy;
mapping(address => UserInvitedInfo) public invitedInfo;
uint256 public referralRewardBalance = 10_000_000 ether;
uint256 public mouseLastRewardBlock;
uint256 public mouseAccAlphaPerShare;
uint256 public mouseTotalAlphaStaked;
uint256 public catAccAlphaPerShare;
uint256 public catTotalAlphaStaked;
uint8 public constant rice_claim_tax_percentage = 20;
uint256 public totalRiceSupply = 150_000_000 ether;
uint256[6] public rewardBlockHeights;
uint256[6] public rewardAmountsPerBlock;
bool public rescueEnabled = false;
CatMouse public immutable catMouse;
Rice public immutable rice;
event Claimed(address owner, uint256 cat, uint256 mouse, uint256 ReferReward);
constructor(address _catMouse, address _rice) {
catMouse = CatMouse(_catMouse);
rice = Rice(_rice);
}
modifier updatePool_Mouse() {
uint256 bkn = blockNumber();
if (totalRiceSupply > 0 && bkn > mouseLastRewardBlock) {
if (mouseTotalAlphaStaked > 0) {
uint256 tokenReward = calculateRewards(bkn, mouseLastRewardBlock);
if (tokenReward > 0) {
if (tokenReward > totalRiceSupply) tokenReward = totalRiceSupply;
unchecked {
totalRiceSupply -= tokenReward;
}
mouseAccAlphaPerShare += _updatePool_Cat(tokenReward * 1e12) / mouseTotalAlphaStaked;
}
}
mouseLastRewardBlock = bkn;
}
_;
}
function blockNumber() internal view returns (uint256) {
return IArbSys(0x0000000000000000000000000000000000000064).arbBlockNumber();
}
function _updatePool_Cat(uint256 mouseReward) internal returns (uint256) {
if (catTotalAlphaStaked == 0) return mouseReward;
uint256 catReward = (mouseReward * rice_claim_tax_percentage) / 100;
catAccAlphaPerShare += catReward / catTotalAlphaStaked;
return mouseReward - catReward;
}
function uncalcMouseAlphaPerShare() public view returns (uint256) {
uint256 bkn = blockNumber();
if (bkn <= mouseLastRewardBlock) return 0;
if (mouseTotalAlphaStaked == 0) return 0;
uint256 tokenReward = calculateRewards(bkn, mouseLastRewardBlock);
if (tokenReward > totalRiceSupply) tokenReward = totalRiceSupply;
if (catTotalAlphaStaked == 0) return (tokenReward * 1e12) / mouseTotalAlphaStaked;
return ((tokenReward * 1e12) * (100 - rice_claim_tax_percentage)) / 100 / mouseTotalAlphaStaked;
}
function uncalcCatAlphaPerShare() public view returns (uint256) {
uint256 bkn = blockNumber();
if (bkn <= mouseLastRewardBlock) return 0;
if (mouseTotalAlphaStaked == 0) return 0;
if (catTotalAlphaStaked == 0) return 0;
uint256 tokenReward = calculateRewards(bkn, mouseLastRewardBlock);
if (tokenReward > totalRiceSupply) tokenReward = totalRiceSupply;
return ((tokenReward * 1e12) * rice_claim_tax_percentage) / 100 / catTotalAlphaStaked;
}
function pendingMouse(address _user) external view returns (uint256) {
UserInfo storage user = mouseStaked[_user];
uint256 accTokenPerShare = mouseAccAlphaPerShare + uncalcMouseAlphaPerShare();
return user.unclaimedRewards + (user.alphaTotal * accTokenPerShare) / 1e12 - user.rewardDebt;
}
function pendingCat(address _user) external view returns (uint256) {
UserInfo storage user = catStaked[_user];
uint256 accTokenPerShare = catAccAlphaPerShare + uncalcCatAlphaPerShare();
return user.unclaimedRewards + (user.alphaTotal * accTokenPerShare) / 1e12 - user.rewardDebt;
}
function setInviter(address user, address inviter) external {
require(_msgSender() == address(catMouse), 'ONLY CATMOUSE');
_setInviter(user, inviter);
}
function _setInviter(address user, address inviter) internal {
if (invitedBy[user] != address(0)) return;
if (inviter == user) return;
invitedBy[user] = inviter;
invitedInfo[inviter].totalInvited++;
}
function stake(address account, uint256[] calldata tokenIds, address inviter) external updatePool_Mouse nonReentrant {
address msgSender = _msgSender();
require(!rescueEnabled, 'RESCUE MODE');
require(account == msgSender || msgSender == address(catMouse), 'DONT GIVE YOUR TOKENS AWAY');
_setInviter(account, inviter);
UserInfo storage userMouse = mouseStaked[account];
userMouse.unclaimedRewards += (userMouse.alphaTotal * mouseAccAlphaPerShare) / 1e12 - userMouse.rewardDebt;
UserInfo storage userCat = catStaked[account];
userCat.unclaimedRewards += (userCat.alphaTotal * catAccAlphaPerShare) / 1e12 - userCat.rewardDebt;
uint8[8][] memory tokenListTraits = catMouse.getTokenListTraits(tokenIds);
uint256 catAlphaAdd = 0;
uint256 mouseAlphaAdd = 0;
for (uint16 i = 0; i < tokenIds.length; i++) {
if (tokenListTraits[i][0] == 0) {
catAlphaAdd += tokenListTraits[i][7];
} else {
mouseAlphaAdd += tokenListTraits[i][7];
}
_addTokenToOwnerEnumeration(account, uint16(tokenIds[i]));
}
userCat.alphaTotal += catAlphaAdd;
catTotalAlphaStaked += catAlphaAdd;
userMouse.alphaTotal += mouseAlphaAdd;
mouseTotalAlphaStaked += mouseAlphaAdd;
userMouse.rewardDebt = (userMouse.alphaTotal * mouseAccAlphaPerShare) / 1e12;
userCat.rewardDebt = (userCat.alphaTotal * catAccAlphaPerShare) / 1e12;
if (msgSender != address(catMouse)) {
catMouse.batchTransferFrom(msgSender, address(this), tokenIds);
}
}
function claim(bool unstake) external updatePool_Mouse nonReentrant {
address account = _msgSender();
uint256 reward_mouse = _claimMouse(account);
uint256 reward_cat = _claimCat(account);
uint256 reward_ref = _claimReferral(account);
uint256 reward = reward_mouse + reward_cat + reward_ref;
_referralReward(account, reward);
if (unstake) {
uint16 balance = balanceOf(account);
require(balance > 0, 'Barn: balance is 0');
mouseTotalAlphaStaked -= mouseStaked[account].alphaTotal;
catTotalAlphaStaked -= catStaked[account].alphaTotal;
delete mouseStaked[account];
delete catStaked[account];
uint256[] memory tokenIds = new uint256[](balance);
for (uint16 i = 0; i < balance; i++) {
tokenIds[i] = _ownedTokens[account][0];
_removeTokenFromOwnerEnumeration(account, _ownedTokens[account][0]);
}
catMouse.batchTransferFrom(address(this), account, tokenIds);
if (reward == 0) return;
} else {
require(reward > 0);
}
rice.transfer(account, reward);
emit Claimed(account, reward_cat, reward_mouse, reward_ref);
}
function _referralReward(address account, uint256 reward) internal {
address inviter = invitedBy[account];
if (inviter == address(0)) return;
if (mouseStaked[inviter].alphaTotal == 0 && catStaked[inviter].alphaTotal == 0) return;
reward = reward / 10;
if (reward > referralRewardBalance) reward = referralRewardBalance;
if (reward == 0) return;
unchecked {
referralRewardBalance -= reward;
}
invitedInfo[inviter].totalRewards += reward;
}
function _claimMouse(address account) internal returns (uint256 reward) {
UserInfo storage user = mouseStaked[account];
uint256 debt = (user.alphaTotal * mouseAccAlphaPerShare) / 1e12;
reward = user.unclaimedRewards + debt - user.rewardDebt;
user.rewardDebt = debt;
user.unclaimedRewards = 0;
}
function _claimCat(address account) internal returns (uint256 reward) {
UserInfo storage user = catStaked[account];
uint256 debt = (user.alphaTotal * catAccAlphaPerShare) / 1e12;
reward = user.unclaimedRewards + debt - user.rewardDebt;
user.rewardDebt = debt;
user.unclaimedRewards = 0;
}
function _claimReferral(address account) internal returns (uint256 reward) {
UserInvitedInfo storage user = invitedInfo[account];
reward = user.totalRewards - user.claimedRewards;
user.claimedRewards = user.totalRewards;
}
function calculateRewards(uint256 currentBlock, uint256 lastBlock) public view returns (uint256 earned) {
for (uint256 i = 0; i < rewardBlockHeights.length; i++) {
uint256 height = rewardBlockHeights[i];
if (lastBlock >= height) continue;
uint256 rewardPerBlock = rewardAmountsPerBlock[i];
if (currentBlock <= height) {
earned += (currentBlock - lastBlock) * rewardPerBlock;
return earned;
}
earned += (height - lastBlock) * rewardPerBlock;
lastBlock = height;
}
earned += (currentBlock - lastBlock) * rewardAmountsPerBlock[5];
}
function rescue(uint16 count) external {
require(rescueEnabled, 'RESCUE DISABLED');
address account = _msgSender();
uint256[] memory tokenIds = new uint256[](count);
for (uint16 i = 0; i < count; i++) {
tokenIds[i] = _ownedTokens[account][0];
_removeTokenFromOwnerEnumeration(account, _ownedTokens[account][0]);
}
catMouse.batchTransferFrom(address(this), account, tokenIds);
}
function leaveByIds(uint256[] calldata tokenIds) external updatePool_Mouse nonReentrant {
address account = _msgSender();
UserInfo storage userMouse = mouseStaked[account];
userMouse.unclaimedRewards += (userMouse.alphaTotal * mouseAccAlphaPerShare) / 1e12 - userMouse.rewardDebt;
UserInfo storage userCat = catStaked[account];
userCat.unclaimedRewards += (userCat.alphaTotal * catAccAlphaPerShare) / 1e12 - userCat.rewardDebt;
uint8[8][] memory tokenListTraits = catMouse.getTokenListTraits(tokenIds);
uint256 catAlphaSub = 0;
uint256 mouseAlphaSub = 0;
for (uint16 i = 0; i < tokenIds.length; i++) {
if (tokenListTraits[i][0] == 0) {
catAlphaSub += tokenListTraits[i][7];
} else {
mouseAlphaSub += tokenListTraits[i][7];
}
_removeTokenFromOwnerEnumeration(account, uint16(tokenIds[i]));
}
userCat.alphaTotal -= catAlphaSub;
catTotalAlphaStaked -= catAlphaSub;
userMouse.alphaTotal -= mouseAlphaSub;
mouseTotalAlphaStaked -= mouseAlphaSub;
userMouse.rewardDebt = (userMouse.alphaTotal * mouseAccAlphaPerShare) / 1e12;
userCat.rewardDebt = (userCat.alphaTotal * catAccAlphaPerShare) / 1e12;
catMouse.batchTransferFrom(address(this), account, tokenIds);
}
function tokenOfOwnerByIndex(address user, uint256 index) public view virtual returns (uint256) {
return uint256(_ownedTokens[user][uint16(index)]);
}
function balanceOf(address user) public view virtual returns (uint16) {
require(user != address(0), 'ERC721: balance query for the zero address');
return _balances[user];
}
function _addTokenToOwnerEnumeration(address to, uint16 tokenId) private {
uint16 length = _balances[to];
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
_balances[to] = length + 1;
ownerOf[tokenId] = to;
}
function _removeTokenFromOwnerEnumeration(address from, uint16 tokenId) private {
require(ownerOf[tokenId] == from, 'Barn: not owner');
uint16 lastTokenIndex = _balances[from] - 1;
uint16 tokenIndex = _ownedTokensIndex[tokenId];
if (tokenIndex != lastTokenIndex) {
uint16 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId;
_ownedTokensIndex[lastTokenId] = tokenIndex;
}
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
delete ownerOf[tokenId];
_balances[from]--;
}
function setRescueEnabled(bool _enabled) external onlyOwner {
rescueEnabled = _enabled;
}
function initialize(uint256 beginBlock, uint256 blocksPerSec) external onlyOwner {
require(rewardBlockHeights[0] == 0, 'ALREADY INITIALIZED');
require(rice.balanceOf(address(this)) >= (totalRiceSupply + referralRewardBalance), 'NOT ENOUGH RICE');
uint256 stageSupply = 25_000_000 ether;
uint256 stageBlocks = 30 days * blocksPerSec;
uint256 rewardPerBlock = stageSupply / stageBlocks;
rewardBlockHeights = [
beginBlock,
beginBlock + stageBlocks,
beginBlock + (stageBlocks * 2),
beginBlock + (stageBlocks * 4),
beginBlock + (stageBlocks * 8),
beginBlock + (stageBlocks * 16)
];
rewardAmountsPerBlock = [
0,
rewardPerBlock * 2,
rewardPerBlock,
rewardPerBlock / 2,
rewardPerBlock / 4,
rewardPerBlock / 8
];
}
}
文件 3 的 27:Base64.sol
pragma solidity ^0.8.0;
library Base64 {
string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
function encode(bytes memory data) internal pure returns (string memory) {
if (data.length == 0) return "";
string memory table = _TABLE;
string memory result = new string(4 * ((data.length + 2) / 3));
assembly {
let tablePtr := add(table, 1)
let resultPtr := add(result, 32)
for {
let dataPtr := data
let endPtr := add(data, mload(data))
} lt(dataPtr, endPtr) {
} {
dataPtr := add(dataPtr, 3)
let input := mload(dataPtr)
mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))
resultPtr := add(resultPtr, 1)
mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))
resultPtr := add(resultPtr, 1)
mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))
resultPtr := add(resultPtr, 1)
mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))
resultPtr := add(resultPtr, 1)
}
switch mod(mload(data), 3)
case 1 {
mstore8(sub(resultPtr, 1), 0x3d)
mstore8(sub(resultPtr, 2), 0x3d)
}
case 2 {
mstore8(sub(resultPtr, 1), 0x3d)
}
}
return result;
}
}
文件 4 的 27:CatMouse.sol
pragma solidity 0.8.15;
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol';
import '@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol';
import '@openzeppelin/contracts/token/ERC721/ERC721.sol';
import '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';
import '@openzeppelin/contracts/vendor/arbitrum/IArbSys.sol';
import './Traits.sol';
import './Rice.sol';
import './Barn.sol';
import './CatMouseAlpha.sol';
contract CatMouse is CatMouseAlpha, ERC721Enumerable, ERC721Holder, Ownable {
using ECDSA for bytes32;
uint256 public constant MINT_PRICE_0 = .01 ether;
uint256 public constant MINT_PRICE_1 = .02 ether;
uint256 public constant MINT_PRICE_2 = .04 ether;
uint16 public PAY_ETH_0 = 1000;
uint16 public constant PAY_ETH_1 = 4000;
uint16 public constant PAY_ETH_2 = 10000;
uint16 public constant TOTAL_SUPPLY = 50000;
uint256 public constant RICE_COST_INC = 0.1 ether;
uint16 public minted;
address public commitmentAdmin;
struct Commitment {
bool stake;
bool claimed;
address account;
uint256 commitment;
}
mapping(uint16 => Commitment) public commitments;
mapping(address => uint8) public whitelistMintedCount;
mapping(address => uint16[]) public catches;
Barn public barn;
Rice public immutable rice;
Traits public traits;
event Mint(address indexed account, uint256[] tokenIds);
event Catch(address indexed account, uint16 tokenId);
constructor(address _rice, address _traits, address _commitmentAdmin) ERC721('Cat & Mouse', 'Cat Mouse Game') {
rice = Rice(_rice);
traits = Traits(_traits);
commitmentAdmin = _commitmentAdmin;
}
function createCommitment() internal view returns (uint256) {
uint256 bkn = IArbSys(0x0000000000000000000000000000000000000064).arbBlockNumber();
return uint256(keccak256(abi.encodePacked(tx.origin, minted, IArbSys(0x0000000000000000000000000000000000000064).arbBlockHash(bkn - 1))));
}
function mint(uint8 amount, bool stake, address inviter, bytes calldata signature) external payable {
require(tx.origin == _msgSender(), 'Only EOA');
require(whitelistMintedCount[tx.origin] + amount <= 6, 'Exceeds max mint amount');
require(minted + amount <= PAY_ETH_0, 'All tokens minted');
require(amount > 0, 'Invalid mint amount');
require(amount * MINT_PRICE_0 == msg.value, 'Invalid payment amount');
bytes32 message = keccak256(abi.encodePacked(tx.origin, address(this), 'mint'));
require(message.toEthSignedMessageHash().recover(signature) == commitmentAdmin, 'Invalid signature');
whitelistMintedCount[tx.origin] += amount;
_preMint(tx.origin, amount, stake);
barn.setInviter(tx.origin, inviter);
}
function mint(uint8 amount, bool stake, address inviter) external payable {
require(minted >= PAY_ETH_0, 'Pre-minter enabled');
require(tx.origin == _msgSender(), 'Only EOA');
require(amount > 0 && amount <= 10, 'Invalid mint amount');
if (minted < PAY_ETH_1) {
require(minted + amount <= PAY_ETH_1, 'All tokens on-sale already sold');
require(amount * MINT_PRICE_1 == msg.value, 'Invalid payment amount');
} else if (minted < PAY_ETH_2) {
require(minted + amount <= PAY_ETH_2, 'All tokens on-sale already sold');
require(amount * MINT_PRICE_2 == msg.value, 'Invalid payment amount');
} else {
require(minted + amount <= TOTAL_SUPPLY, 'All tokens minted');
require(msg.value == 0);
rice.burnFrom(tx.origin, minted * RICE_COST_INC * amount + (RICE_COST_INC * (amount * (amount + 1))) / 2);
}
_preMint(tx.origin, amount, stake);
barn.setInviter(tx.origin, inviter);
}
function _preMint(address to, uint8 amount, bool stake) internal {
uint256[] memory tokenIds = new uint256[](amount);
uint256 commitment = createCommitment();
uint16 tokenId = minted;
for (uint8 i = 0; i < amount; i++) {
tokenId++;
tokenIds[i] = tokenId;
commitments[tokenId] = Commitment({ stake: stake, claimed: false, account: to, commitment: commitment });
}
minted = tokenId;
emit Mint(to, tokenIds);
}
function hatch(uint16[] calldata tokenIds, bytes[] calldata signatures) external {
for (uint256 i = 0; i < tokenIds.length; i++) {
uint16 tokenId = tokenIds[i];
Commitment storage cmt = commitments[tokenId];
require(!cmt.claimed, 'token already claimed');
require(cmt.commitment > 0, 'invalid token id');
cmt.claimed = true;
bytes32 message = keccak256(abi.encodePacked(tokenId, cmt.account, cmt.commitment, address(this), 'hatch'));
require(message.toEthSignedMessageHash().recover(signatures[i]) == commitmentAdmin, 'Invalid signature');
uint256 seed = uint256(message);
_selectTraits(tokenId, seed);
address recipient = _selectRecipient(cmt.account, seed, tokenId);
alphaAdd(tokenId);
if (recipient != cmt.account) {
catches[recipient].push(tokenId);
_safeMint(address(this), tokenId);
emit Catch(recipient, tokenId);
} else if (cmt.stake) {
_safeMint(address(barn), tokenId);
uint256[] memory stakeIds = new uint256[](1);
stakeIds[0] = tokenId;
barn.stake(cmt.account, stakeIds, address(0));
} else {
_safeMint(cmt.account, tokenId);
}
}
}
function mintCatches(uint16 count) external {
require(count > 0, 'Invalid mint amount');
uint256 len = catches[msg.sender].length;
require(len > 0, 'No catch tokens');
uint16 mintCount;
while (len > 0) {
uint16 tokenId = catches[msg.sender][len - 1];
catches[msg.sender].pop();
mintCount++;
_safeTransfer(address(this), msg.sender, tokenId, '');
if (mintCount >= count) return;
len = catches[msg.sender].length;
}
}
function batchTransferFrom(address from, address to, uint256[] memory tokenIds) external {
for (uint16 i = 0; i < tokenIds.length; i++) {
transferFrom(from, to, tokenIds[i]);
}
}
function batchTransferFrom(address from, address[] memory toList, uint256[] memory tokenIds) external {
for (uint16 i = 0; i < toList.length; i++) {
transferFrom(from, toList[i], tokenIds[i]);
}
}
function _selectRecipient(address user, uint256 seed, uint16 tokenId) internal view returns (address) {
if (tokenId <= PAY_ETH_2 || ((seed >> 245) % 10) != 0) return user;
address thief = randomCatOwner(seed >> 144);
if (thief == address(0)) return user;
return thief;
}
function getTokenTraits(uint16 tokenId) public view returns (uint8[8] memory) {
return tokenTraits[tokenId];
}
function getTokenListTraits(uint256[] memory tokenIds) public view returns (uint8[8][] memory list) {
list = new uint8[8][](tokenIds.length);
for (uint256 i = 0; i < tokenIds.length; i++) {
list[i] = tokenTraits[tokenIds[i]];
}
}
function getCatches(address account) public view returns (uint16[] memory) {
return catches[account];
}
function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
return traits.tokenURI(uint16(tokenId));
}
function randomCatOwner(uint256 seed) public view returns (address) {
if (alphaOfCat.length == 0) return address(0);
return ownerAddress(alphaOfCat[seed % alphaOfCat.length]);
}
function ownerAddress(uint16 tokenId) public view returns (address) {
address tokenOwner = ownerOf(tokenId);
if (tokenOwner == address(barn)) return barn.ownerOf(tokenId);
if (tokenOwner == address(this)) return address(0);
return tokenOwner;
}
function setBarn(address newBarn) external onlyOwner {
require(address(barn) == address(0), 'Barn already set');
barn = Barn(newBarn);
}
function closeWhitelist() external onlyOwner {
require(minted < PAY_ETH_0, 'Whitelist already closed');
PAY_ETH_0 = minted;
}
function setCommitmentAdmin(address newCommitmentAdmin) external onlyOwner {
commitmentAdmin = newCommitmentAdmin;
}
function withdraw(IERC20 token, address to, uint256 amount) external onlyOwner {
if (address(token) == address(0)) {
payable(to).transfer(amount);
} else {
token.transfer(to, amount);
}
}
function setTraits(address newTraits) external onlyOwner {
traits = Traits(newTraits);
}
}
文件 5 的 27:CatMouseAlpha.sol
pragma solidity 0.8.15;
contract CatMouseAlpha {
uint8[][14] public aliases;
uint8[][14] public rarities;
mapping(uint256 => uint8[8]) public tokenTraits;
uint16[] public alphaOfCat;
uint16[] public alphaOfMouse;
constructor() {
rarities[0] = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255];
aliases[0] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
rarities[1] = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255];
aliases[1] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
rarities[2] = [255, 170, 170, 170];
aliases[2] = [0, 0, 0, 0];
rarities[3] = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255];
aliases[3] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18];
rarities[4] = [239, 239, 191, 255, 239, 239, 239, 239, 239, 239, 239, 239];
aliases[4] = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3];
rarities[5] = [255, 255, 255, 255, 255, 255, 255, 255];
aliases[5] = [0, 1, 2, 3, 4, 5, 6, 7];
rarities[6] = [0, 0, 0, 0, 0, 255, 127, 229, 114];
aliases[6] = [5, 5, 5, 6, 6, 5, 5, 6, 6];
rarities[7] = [255, 255, 255, 255, 255, 255];
aliases[7] = [0, 1, 2, 3, 4, 5];
rarities[8] = [255, 255, 255, 255];
aliases[8] = [0, 1, 2, 3];
rarities[9] = [255, 159, 159, 159, 159];
aliases[9] = [0, 0, 0, 0, 0];
rarities[10] = [255, 255, 255, 255, 255, 255, 255];
aliases[10] = [0, 1, 2, 3, 4, 5, 6];
rarities[11] = [255, 255, 255, 255, 255];
aliases[11] = [0, 1, 2, 3, 4];
rarities[12] = [255, 255, 255, 255, 255];
aliases[12] = [0, 1, 2, 3, 4];
rarities[13] = [0, 255];
aliases[13] = [1, 1];
}
function alphaAdd(uint16 tokenId) internal {
uint8 alpha = tokenTraits[tokenId][7];
if (isMouse(tokenId)) {
for (uint8 i = 0; i < alpha; i++) {
alphaOfMouse.push(tokenId);
}
} else {
for (uint8 i = 0; i < alpha; i++) {
alphaOfCat.push(tokenId);
}
}
}
function _selectTraits(uint256 tokenId, uint256 seed) internal returns (uint8[8] memory traits) {
traits[0] = (seed & 0xFFFF) % 10 == 0 ? 0 : 1;
uint8 shift = traits[0] == 1 ? 7 : 0;
for (uint8 i = 0; i < 7; i++) {
seed >>= 16;
traits[1 + i] = _selectTrait(uint16(seed & 0xFFFF), i + shift);
}
tokenTraits[tokenId] = traits;
}
function _selectTrait(uint16 seed, uint8 traitType) internal view returns (uint8) {
uint8 trait = uint8(seed) % uint8(rarities[traitType].length);
if (seed >> 8 < rarities[traitType][trait]) return trait;
return aliases[traitType][trait];
}
function alphaOfCatLength() public view returns (uint256) {
return alphaOfCat.length;
}
function alphaOfMouseLength() public view returns (uint256) {
return alphaOfMouse.length;
}
function isCat(uint256 tokenId) public view returns (bool) {
return tokenTraits[tokenId][0] == 0;
}
function isMouse(uint256 tokenId) public view returns (bool) {
return tokenTraits[tokenId][0] == 1;
}
function isCats(uint256[] memory tokenIds) public view returns (bool[] memory bools) {
bools = new bool[](tokenIds.length);
for (uint16 i = 0; i < tokenIds.length; i++) {
bools[i] = tokenTraits[tokenIds[i]][0] == 0;
}
}
}
文件 6 的 27:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 7 的 27:ECDSA.sol
pragma solidity ^0.8.0;
import "../Strings.sol";
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return;
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
}
}
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
文件 8 的 27:ERC165.sol
pragma solidity ^0.8.0;
import "./IERC165.sol";
abstract contract ERC165 is IERC165 {
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
文件 9 的 27:ERC20.sol
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
function transferFrom(
address from,
address to,
uint256 amount
) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _spendAllowance(
address owner,
address spender,
uint256 amount
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
文件 10 的 27:ERC20Burnable.sol
pragma solidity ^0.8.0;
import "../ERC20.sol";
import "../../../utils/Context.sol";
abstract contract ERC20Burnable is Context, ERC20 {
function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
function burnFrom(address account, uint256 amount) public virtual {
_spendAllowance(account, _msgSender(), amount);
_burn(account, amount);
}
}
文件 11 的 27:ERC721.sol
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
string private _name;
string private _symbol;
mapping(uint256 => address) private _owners;
mapping(address => uint256) private _balances;
mapping(uint256 => address) private _tokenApprovals;
mapping(address => mapping(address => bool)) private _operatorApprovals;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: address zero is not a valid owner");
return _balances[owner];
}
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _ownerOf(tokenId);
require(owner != address(0), "ERC721: invalid token ID");
return owner;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
_requireMinted(tokenId);
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
function _baseURI() internal view virtual returns (string memory) {
return "";
}
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not token owner or approved for all"
);
_approve(to, tokenId);
}
function getApproved(uint256 tokenId) public view virtual override returns (address) {
_requireMinted(tokenId);
return _tokenApprovals[tokenId];
}
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
_transfer(from, to, tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
_safeTransfer(from, to, tokenId, data);
}
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
}
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
return _owners[tokenId];
}
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _ownerOf(tokenId) != address(0);
}
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
}
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
function _safeMint(
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId, 1);
require(!_exists(tokenId), "ERC721: token already minted");
unchecked {
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId, 1);
}
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId, 1);
owner = ERC721.ownerOf(tokenId);
delete _tokenApprovals[tokenId];
unchecked {
_balances[owner] -= 1;
}
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId, 1);
}
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId, 1);
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
delete _tokenApprovals[tokenId];
unchecked {
_balances[from] -= 1;
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId, 1);
}
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
function _requireMinted(uint256 tokenId) internal view virtual {
require(_exists(tokenId), "ERC721: invalid token ID");
}
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
function _beforeTokenTransfer(
address from,
address to,
uint256,
uint256 batchSize
) internal virtual {
if (batchSize > 1) {
if (from != address(0)) {
_balances[from] -= batchSize;
}
if (to != address(0)) {
_balances[to] += batchSize;
}
}
}
function _afterTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
) internal virtual {}
}
文件 12 的 27:ERC721Enumerable.sol
pragma solidity ^0.8.0;
import "../ERC721.sol";
import "./IERC721Enumerable.sol";
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
mapping(uint256 => uint256) private _ownedTokensIndex;
uint256[] private _allTokens;
mapping(uint256 => uint256) private _allTokensIndex;
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
return _ownedTokens[owner][index];
}
function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
return _allTokens[index];
}
function _beforeTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
) internal virtual override {
super._beforeTokenTransfer(from, to, firstTokenId, batchSize);
if (batchSize > 1) {
revert("ERC721Enumerable: consecutive transfers not supported");
}
uint256 tokenId = firstTokenId;
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId;
_ownedTokensIndex[lastTokenId] = tokenIndex;
}
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId;
_allTokensIndex[lastTokenId] = tokenIndex;
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
}
文件 13 的 27:ERC721Holder.sol
pragma solidity ^0.8.0;
import "../IERC721Receiver.sol";
contract ERC721Holder is IERC721Receiver {
function onERC721Received(
address,
address,
uint256,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC721Received.selector;
}
}
文件 14 的 27:IArbSys.sol
pragma solidity >=0.4.21 <0.9.0;
interface IArbSys {
function arbBlockNumber() external view returns (uint256);
function arbBlockHash(uint256 arbBlockNum) external view returns (bytes32);
function arbChainID() external view returns (uint256);
function arbOSVersion() external view returns (uint256);
function getStorageGasAvailable() external view returns (uint256);
function isTopLevelCall() external view returns (bool);
function mapL1SenderContractAddressToL2Alias(address sender, address unused) external pure returns (address);
function wasMyCallersAddressAliased() external view returns (bool);
function myCallersAddressWithoutAliasing() external view returns (address);
function withdrawEth(address destination) external payable returns (uint256);
function sendTxToL1(address destination, bytes calldata data) external payable returns (uint256);
function sendMerkleTreeState()
external
view
returns (
uint256 size,
bytes32 root,
bytes32[] memory partials
);
event L2ToL1Tx(
address caller,
address indexed destination,
uint256 indexed hash,
uint256 indexed position,
uint256 arbBlockNum,
uint256 ethBlockNum,
uint256 timestamp,
uint256 callvalue,
bytes data
);
event L2ToL1Transaction(
address caller,
address indexed destination,
uint256 indexed uniqueId,
uint256 indexed batchNumber,
uint256 indexInBatch,
uint256 arbBlockNum,
uint256 ethBlockNum,
uint256 timestamp,
uint256 callvalue,
bytes data
);
event SendMerkleUpdate(uint256 indexed reserved, bytes32 indexed hash, uint256 indexed position);
}
文件 15 的 27:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 16 的 27:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
文件 17 的 27:IERC20Metadata.sol
pragma solidity ^0.8.0;
import "../IERC20.sol";
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
文件 18 的 27:IERC721.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC721 is IERC165 {
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
function balanceOf(address owner) external view returns (uint256 balance);
function ownerOf(uint256 tokenId) external view returns (address owner);
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
function approve(address to, uint256 tokenId) external;
function setApprovalForAll(address operator, bool _approved) external;
function getApproved(uint256 tokenId) external view returns (address operator);
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
文件 19 的 27:IERC721Enumerable.sol
pragma solidity ^0.8.0;
import "../IERC721.sol";
interface IERC721Enumerable is IERC721 {
function totalSupply() external view returns (uint256);
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
function tokenByIndex(uint256 index) external view returns (uint256);
}
文件 20 的 27:IERC721Metadata.sol
pragma solidity ^0.8.0;
import "../IERC721.sol";
interface IERC721Metadata is IERC721 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function tokenURI(uint256 tokenId) external view returns (string memory);
}
文件 21 的 27:IERC721Receiver.sol
pragma solidity ^0.8.0;
interface IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
文件 22 的 27:Math.sol
pragma solidity ^0.8.0;
library Math {
enum Rounding {
Down,
Up,
Zero
}
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function average(uint256 a, uint256 b) internal pure returns (uint256) {
return (a & b) + (a ^ b) / 2;
}
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
return a == 0 ? 0 : (a - 1) / b + 1;
}
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
uint256 prod0;
uint256 prod1;
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
if (prod1 == 0) {
return prod0 / denominator;
}
require(denominator > prod1);
uint256 remainder;
assembly {
remainder := mulmod(x, y, denominator)
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
uint256 twos = denominator & (~denominator + 1);
assembly {
denominator := div(denominator, twos)
prod0 := div(prod0, twos)
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
uint256 inverse = (3 * denominator) ^ 2;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
result = prod0 * inverse;
return result;
}
}
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 result = 1 << (log2(a) >> 1);
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
result += 2;
}
if (value >= 10**1) {
result += 1;
}
}
return result;
}
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}
文件 23 的 27:Ownable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 24 的 27:ReentrancyGuard.sol
pragma solidity ^0.8.0;
abstract contract ReentrancyGuard {
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
}
function _nonReentrantAfter() private {
_status = _NOT_ENTERED;
}
}
文件 25 的 27:Rice.sol
pragma solidity 0.8.15;
import '@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol';
contract Rice is ERC20Burnable {
constructor(address fundation) ERC20('RICE', 'RICE') {
_mint(fundation, 20_000_000 ether);
_mint(msg.sender, 180_000_000 ether);
}
}
文件 26 的 27:Strings.sol
pragma solidity ^0.8.0;
import "./math/Math.sol";
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}
文件 27 的 27:Traits.sol
pragma solidity 0.8.15;
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/utils/Strings.sol';
import '@openzeppelin/contracts/utils/Base64.sol';
import './CatMouse.sol';
contract Traits is Ownable {
using Strings for uint16;
struct Trait {
string name;
string data;
}
mapping(uint32 => mapping(uint32 => Trait)) public traitData;
mapping(uint8 => string) public traitName;
string public pre =
'<svg width="100%" height="100%" version="1.1" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><style>image{x:4;y:4;width:32;height:32;image-rendering:pixelated;transition:all ease .4s;}svg:hover image[data-glasses]{y:6;}svg:hover image[data-headwear]{y:0;transition:all ease .2s;}</style>';
string public end = '</svg>';
CatMouse public catMouse;
function getAttr(uint16 tokenId_) public view returns (Trait[8] memory, uint8) {
uint8[8] memory s = catMouse.getTokenTraits(tokenId_);
Trait[8] memory args;
uint8 begin_ = 0;
if (s[0] == 1) begin_ = 8;
for (uint8 i = 1; i < s.length; i++) {
args[i] = traitData[i + begin_][s[i]];
}
return (args, begin_);
}
function drawSVG(uint16 tokenId_) public view returns (string memory) {
(Trait[8] memory args, ) = getAttr(tokenId_);
return
string(
abi.encodePacked(
pre,
args[0].data,
args[1].data,
args[2].data,
args[3].data,
abi.encodePacked(
args[4].data,
args[5].data,
args[6].data,
args[7].data,
end
)
)
);
}
function attributeForTypeAndValue(string memory typeName_, Trait memory trait_) internal pure returns (string memory) {
if (bytes(trait_.data).length == 0) return '';
return string(abi.encodePacked('{"trait_type":"', typeName_, '","value":"', trait_.name, '"},'));
}
function compileAttributes(uint16 tokenId_) public view returns (string memory) {
(Trait[8] memory args, uint8 begin_) = getAttr(tokenId_);
string memory traits = string(
abi.encodePacked(
attributeForTypeAndValue(traitName[0 + begin_], args[0]),
attributeForTypeAndValue(traitName[1 + begin_], args[1]),
attributeForTypeAndValue(traitName[2 + begin_], args[2]),
attributeForTypeAndValue(traitName[3 + begin_], args[3]),
abi.encodePacked(
attributeForTypeAndValue(traitName[4 + begin_], args[4]),
attributeForTypeAndValue(traitName[5 + begin_], args[5]),
attributeForTypeAndValue(traitName[6 + begin_], args[6]),
attributeForTypeAndValue(traitName[7 + begin_], args[7])
)
)
);
return
string(
abi.encodePacked(
'[{"trait_type":"type","value":"',
begin_ == 0 ? 'Cat' : 'Mouse',
'"},',
traits,
'{"trait_type":"generation","value":"Gen ',
tokenId_ <= catMouse.PAY_ETH_1() ? '0' : '1',
'"}]'
)
);
}
function tokenURI(uint16 tokenId_) public view returns (string memory) {
(, uint16 begin_) = getAttr(tokenId_);
string memory metadata = string(
abi.encodePacked(
'{"name": "',
begin_ == 0 ? 'Cat #' : 'Mouse #',
tokenId_.toString(),
'", "description": "https://catmouse.world Cat and Mouse is a pixel game built on Arbitrum, with a total supply of 50,000, 10% cats and 90% mice in a completely randomised style. 100% Creative and completely on-chain game.","image": "data:image/svg+xml;base64,',
Base64.encode(bytes(drawSVG(tokenId_))),
'", "attributes":',
compileAttributes(tokenId_),
'}'
)
);
return string(abi.encodePacked('data:application/json;base64,', Base64.encode(bytes(metadata))));
}
function setPre(string calldata pre_) external onlyOwner {
pre = pre_;
}
function setEnd(string calldata end_) external onlyOwner {
end = end_;
}
function updateTraitName(uint8[] calldata indexs, string[] calldata names) external onlyOwner {
for (uint8 i = 0; i < indexs.length; i++) {
traitName[indexs[i]] = names[i];
}
}
function uploadTraits(uint32 traitType, uint32[] calldata traitIds, Trait[] calldata traits) external onlyOwner {
for (uint256 i = 0; i < traits.length; i++) {
traitData[traitType][traitIds[i]] = traits[i];
}
}
function setCatMouse(address _catMouse) external onlyOwner {
catMouse = CatMouse(_catMouse);
}
}
{
"compilationTarget": {
"contracts/CatMouse.sol": "CatMouse"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 1000
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_rice","type":"address"},{"internalType":"address","name":"_traits","type":"address"},{"internalType":"address","name":"_commitmentAdmin","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint16","name":"tokenId","type":"uint16"}],"name":"Catch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"MINT_PRICE_0","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINT_PRICE_1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINT_PRICE_2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAY_ETH_0","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAY_ETH_1","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAY_ETH_2","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RICE_COST_INC","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOTAL_SUPPLY","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"aliases","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"alphaOfCat","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"alphaOfCatLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"alphaOfMouse","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"alphaOfMouseLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"barn","outputs":[{"internalType":"contract Barn","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address[]","name":"toList","type":"address[]"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"batchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"batchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"catches","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closeWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"commitmentAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"commitments","outputs":[{"internalType":"bool","name":"stake","type":"bool"},{"internalType":"bool","name":"claimed","type":"bool"},{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"commitment","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getCatches","outputs":[{"internalType":"uint16[]","name":"","type":"uint16[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"getTokenListTraits","outputs":[{"internalType":"uint8[8][]","name":"list","type":"uint8[8][]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"tokenId","type":"uint16"}],"name":"getTokenTraits","outputs":[{"internalType":"uint8[8]","name":"","type":"uint8[8]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16[]","name":"tokenIds","type":"uint16[]"},{"internalType":"bytes[]","name":"signatures","type":"bytes[]"}],"name":"hatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"isCat","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"isCats","outputs":[{"internalType":"bool[]","name":"bools","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"isMouse","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"amount","type":"uint8"},{"internalType":"bool","name":"stake","type":"bool"},{"internalType":"address","name":"inviter","type":"address"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint8","name":"amount","type":"uint8"},{"internalType":"bool","name":"stake","type":"bool"},{"internalType":"address","name":"inviter","type":"address"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint16","name":"count","type":"uint16"}],"name":"mintCatches","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minted","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"tokenId","type":"uint16"}],"name":"ownerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"seed","type":"uint256"}],"name":"randomCatOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"rarities","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rice","outputs":[{"internalType":"contract Rice","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newBarn","type":"address"}],"name":"setBarn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newCommitmentAdmin","type":"address"}],"name":"setCommitmentAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newTraits","type":"address"}],"name":"setTraits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenTraits","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"traits","outputs":[{"internalType":"contract Traits","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistMintedCount","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]