文件 1 的 24:Address.sol
pragma solidity ^0.8.0;
library Address {
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 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 functionCall(target, data, "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");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(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) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(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) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
文件 2 的 24: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;
}
}
文件 3 的 24:CubComposition.sol
pragma solidity ^0.8.0;
import "../interfaces/ICubTraits.sol";
import "./SVG.sol";
library CubComposition {
using Strings for uint256;
function colorBottomFromRandom(bytes memory source, uint256 indexRed, uint256 indexGreen, uint256 indexBlue, ICubTraits.CubSpeciesType species) internal pure returns (ISVG.Color memory) {
return SVG.randomizeColors(
_colorBottomFloorForSpecies(species),
_colorBottomCeilingForSpecies(species),
ISVG.Color(uint8(source[indexRed]), uint8(source[indexGreen]), uint8(source[indexBlue]), 0xFF)
);
}
function colorTopFromRandom(bytes memory source, uint256 indexRed, uint256 indexGreen, uint256 indexBlue, ICubTraits.CubSpeciesType species) internal pure returns (ISVG.Color memory) {
return SVG.randomizeColors(
_colorTopFloorForSpecies(species),
_colorTopCeilingForSpecies(species),
ISVG.Color(uint8(source[indexRed]), uint8(source[indexGreen]), uint8(source[indexBlue]), 0xFF)
);
}
function randomColorFromColors(ISVG.Color memory color1, ISVG.Color memory color2, bytes memory source, uint256 indexRatio, uint256 indexPercentage) internal pure returns (ISVG.Color memory color) {
color = SVG.mixColors(color1, color2, uint8(source[indexRatio]) % 101, 97 + (uint8(source[indexPercentage]) % 7));
color.alpha = 0xFF;
}
function createSvg(ICubTraits.TraitsV1 memory traits, uint256 adultAge) internal pure returns (bytes memory) {
string memory transform = svgTransform(traits, adultAge);
return abi.encodePacked(
SVG.svgOpen(1080, 1080),
_createPath(SVG.brightenColor(traits.topColor, 7), "Head", "M405 675 L540 675 540 540 405 540 Z", "M370 675 L570 675 570 540 370 560 Z", transform),
_createPath(traits.topColor, "HeadShadow", "M540 675 L675 675 675 540 540 540 Z", "M570 675 L710 675 710 564 570 540 Z", transform),
_createPath(SVG.brightenColor(traits.bottomColor, 7), "Torso", "M405 810 L540 810 540 675 405 675 Z", "M370 790 L570 810 570 675 370 675 Z", transform),
_createPath(traits.bottomColor, "TorsoShadow", "M540 810 L675 810 675 675 540 675 Z", "M570 810 L710 786 710 675 570 675 Z", transform),
"</svg>"
);
}
function _createPath(ISVG.Color memory color, string memory name, string memory path1, string memory path2, string memory transform) private pure returns (bytes memory) {
return abi.encodePacked(
"<path id='", name, "' d='", path1, "'", SVG.svgColorWithType(color, ISVG.ColorType.Fill), transform, "><animate attributeName='d' values='", path1, ";", path2, "' begin='4s' dur='1s' fill='freeze'/></path>"
);
}
function randomIndexFromPercentages(uint8 random, uint8[] memory percentages) internal pure returns (uint256) {
uint256 spread = random % 100;
uint256 remainingPercent = 100;
for (uint256 i = 0; i < percentages.length; i++) {
remainingPercent -= percentages[i];
if (spread >= remainingPercent) {
return i;
}
}
return percentages.length;
}
function svgTransform(ICubTraits.TraitsV1 memory traits, uint256 adultAge) internal pure returns (string memory) {
(string memory yScale, string memory yTranslate) = _yTransforms(traits, adultAge);
return string(abi.encodePacked(" transform='translate(0,", yTranslate, "),scale(1,", yScale, ")'"));
}
function toSvgColor(uint24 packedColor) internal pure returns (ISVG.Color memory color) {
color.red = uint8(packedColor >> 16);
color.green = uint8(packedColor >> 8);
color.blue = uint8(packedColor);
color.alpha = 0xFF;
}
function _colorBottomFloorForSpecies(ICubTraits.CubSpeciesType species) private pure returns (ISVG.Color memory) {
if (species == ICubTraits.CubSpeciesType.Brown) {
return toSvgColor(0x40260E);
} else if (species == ICubTraits.CubSpeciesType.Black) {
return toSvgColor(0x222225);
} else if (species == ICubTraits.CubSpeciesType.Polar) {
return toSvgColor(0xB1B6B4);
} else {
return toSvgColor(0x000000);
}
}
function _colorBottomCeilingForSpecies(ICubTraits.CubSpeciesType species) private pure returns (ISVG.Color memory) {
if (species == ICubTraits.CubSpeciesType.Brown) {
return toSvgColor(0x77512D);
} else if (species == ICubTraits.CubSpeciesType.Black) {
return toSvgColor(0x48484D);
} else if (species == ICubTraits.CubSpeciesType.Polar) {
return toSvgColor(0xDFE7E6);
} else {
return toSvgColor(0x121213);
}
}
function _colorTopFloorForSpecies(ICubTraits.CubSpeciesType species) private pure returns (ISVG.Color memory) {
if (species == ICubTraits.CubSpeciesType.Brown) {
return toSvgColor(0x8D5D33);
} else if (species == ICubTraits.CubSpeciesType.Black) {
return toSvgColor(0x383840);
} else if (species == ICubTraits.CubSpeciesType.Polar) {
return toSvgColor(0xD0E5E2);
} else {
return toSvgColor(0xDDDDDE);
}
}
function _colorTopCeilingForSpecies(ICubTraits.CubSpeciesType species) private pure returns (ISVG.Color memory) {
if (species == ICubTraits.CubSpeciesType.Brown) {
return toSvgColor(0xC1A286);
} else if (species == ICubTraits.CubSpeciesType.Black) {
return toSvgColor(0x575C6D);
} else if (species == ICubTraits.CubSpeciesType.Polar) {
return toSvgColor(0xEBF0EF);
} else {
return toSvgColor(0xE2E1E8);
}
}
function _yTransforms(ICubTraits.TraitsV1 memory traits, uint256 adultAge) private pure returns (string memory scale, string memory translate) {
if (traits.age >= adultAge) {
translate = "-810";
scale = "2";
} else if (traits.age > 0) {
uint256 fraction = traits.age * 810 / adultAge;
translate = fraction < 1 ? "-1" : string(abi.encodePacked("-", fraction.toString()));
fraction = traits.age * 100 / adultAge;
scale = string(abi.encodePacked(fraction < 10 ? "1.0" : "1.", fraction.toString()));
} else {
translate = "0";
scale = "1";
}
}
}
文件 4 的 24: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;
}
}
文件 5 的 24: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: balance query for the zero address");
return _balances[owner];
}
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
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) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
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 owner nor approved for all"
);
_approve(to, tokenId);
}
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_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: transfer caller is not owner nor 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: transfer caller is not owner nor 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 _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, 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);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
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 tokenId
) internal virtual {}
}
文件 6 的 24: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 tokenId
) internal virtual override {
super._beforeTokenTransfer(from, to, tokenId);
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();
}
}
文件 7 的 24:IBearable.sol
pragma solidity ^0.8.0;
import "./ISVG.sol";
interface IBearable {
enum BearSpeciesType {
Brown, Black, Polar, Panda
}
enum BearMoodType {
Happy, Hungry, Sleepy, Grumpy
}
function ownsBear(address possibleOwner, uint256 tokenId) external view returns (bool);
function totalBears() external view returns (uint256);
function bearBottomColor(uint256 tokenId) external view returns (ISVG.Color memory color);
function bearMood(uint256 tokenId) external view returns (BearMoodType);
function bearSpecies(uint256 tokenId) external view returns (BearSpeciesType);
function bearTopColor(uint256 tokenId) external view returns (ISVG.Color memory color);
}
文件 8 的 24:ICubTraitProvider.sol
pragma solidity ^0.8.0;
pragma abicoder v2;
import "./ICubTraits.sol";
interface ICubTraitProvider{
function familyForTraits(ICubTraits.TraitsV1 memory traits) external pure returns (string memory);
function isAdopted(ICubTraits.DNA memory dna) external pure returns (bool);
function moodForType(ICubTraits.CubMoodType moodType) external pure returns (string memory);
function moodFromParents(uint256 firstParentTokenId, uint256 secondParentTokenId) external view returns (ICubTraits.CubMoodType);
function nameForTraits(ICubTraits.TraitsV1 memory traits) external pure returns (string memory);
function speciesForType(ICubTraits.CubSpeciesType speciesType) external pure returns (string memory);
function traitsV1(uint256 tokenId) external view returns (ICubTraits.TraitsV1 memory traits);
}
文件 9 的 24:ICubTraits.sol
pragma solidity ^0.8.0;
import "./ISVG.sol";
interface ICubTraits {
enum CubSpeciesType {
Brown, Black, Polar, Panda
}
enum CubMoodType {
Happy, Hungry, Sleepy, Grumpy, Cheerful, Excited, Snuggly, Confused, Ravenous, Ferocious, Hangry, Drowsy, Cranky, Furious
}
struct DNA {
uint256 genes;
uint16 firstParentTokenId;
uint16 secondParentTokenId;
}
struct TraitsV1 {
uint256 age;
ISVG.Color topColor;
ISVG.Color bottomColor;
uint8 nameIndex;
uint8 familyIndex;
CubMoodType mood;
CubSpeciesType species;
}
}
文件 10 的 24:IERC1155.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC1155 is IERC165 {
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
event URI(string value, uint256 indexed id);
function balanceOf(address account, uint256 id) external view returns (uint256);
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
external
view
returns (uint256[] memory);
function setApprovalForAll(address operator, bool approved) external;
function isApprovedForAll(address account, address operator) external view returns (bool);
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}
文件 11 的 24:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 12 的 24: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
) external;
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
function approve(address to, uint256 tokenId) external;
function getApproved(uint256 tokenId) external view returns (address operator);
function setApprovalForAll(address operator, bool _approved) external;
function isApprovedForAll(address owner, address operator) external view returns (bool);
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
文件 13 的 24: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 tokenId);
function tokenByIndex(uint256 index) external view returns (uint256);
}
文件 14 的 24: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);
}
文件 15 的 24:IERC721Receiver.sol
pragma solidity ^0.8.0;
interface IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
文件 16 的 24:ISVG.sol
pragma solidity ^0.8.0;
interface ISVG {
struct Color {
uint8 red;
uint8 green;
uint8 blue;
uint8 alpha;
}
enum ColorType {
Fill, Stroke, None
}
}
文件 17 的 24: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() {
_setOwner(_msgSender());
}
function owner() public view virtual returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 18 的 24: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() {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
_;
_status = _NOT_ENTERED;
}
}
文件 19 的 24:SVG.sol
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/utils/Strings.sol";
import "../interfaces/ISVG.sol";
error RatioInvalid();
library SVG {
using Strings for uint256;
function brightenColor(ISVG.Color memory source, uint32 percentage) internal pure returns (ISVG.Color memory color) {
color.red = _brightenComponent(source.red, percentage);
color.green = _brightenComponent(source.green, percentage);
color.blue = _brightenComponent(source.blue, percentage);
color.alpha = source.alpha;
}
function mixColors(ISVG.Color memory color1, ISVG.Color memory color2, uint32 ratioPercentage, uint32 totalPercentage) internal pure returns (ISVG.Color memory color) {
if (ratioPercentage > 100) revert RatioInvalid();
color.red = _mixComponents(color1.red, color2.red, ratioPercentage, totalPercentage);
color.green = _mixComponents(color1.green, color2.green, ratioPercentage, totalPercentage);
color.blue = _mixComponents(color1.blue, color2.blue, ratioPercentage, totalPercentage);
color.alpha = _mixComponents(color1.alpha, color2.alpha, ratioPercentage, totalPercentage);
}
function randomizeColors(ISVG.Color memory floor, ISVG.Color memory ceiling, ISVG.Color memory random) internal pure returns (ISVG.Color memory color) {
uint16 percent = (uint16(random.red) + uint16(random.green) + uint16(random.blue)) % 101;
color.red = _randomizeComponent(floor.red, ceiling.red, random.red, percent);
color.green = _randomizeComponent(floor.green, ceiling.green, random.green, percent);
color.blue = _randomizeComponent(floor.blue, ceiling.blue, random.blue, percent);
color.alpha = 0xFF;
}
function svgColorWithType(ISVG.Color memory color, ISVG.ColorType colorType) internal pure returns (string memory) {
require(uint(colorType) < 3, "Invalid colorType");
if (colorType == ISVG.ColorType.Fill) return string(abi.encodePacked(" fill='rgb(", _rawColor(color), ")'"));
if (colorType == ISVG.ColorType.Stroke) return string(abi.encodePacked(" stroke='rgb(", _rawColor(color), ")'"));
return string(abi.encodePacked("rgb(", _rawColor(color), ")"));
}
function svgOpen(uint256 width, uint256 height) internal pure returns (string memory) {
return string(abi.encodePacked("<svg viewBox='0 0 ", width.toString(), " ", height.toString(), "' xmlns='http://www.w3.org/2000/svg' version='1.1'>"));
}
function _brightenComponent(uint8 component, uint32 percentage) private pure returns (uint8 result) {
uint32 brightenedComponent = (component == 0 ? 1 : component) * (percentage + 100) / 100;
if (brightenedComponent > 0xFF) {
result = 0xFF;
} else {
result = uint8(brightenedComponent);
}
}
function _mixComponents(uint8 component1, uint8 component2, uint32 ratioPercentage, uint32 totalPercentage) private pure returns (uint8 component) {
uint32 mixedComponent = (uint32(component1) * ratioPercentage + uint32(component2) * (100 - ratioPercentage)) * totalPercentage / 10000;
if (mixedComponent > 0xFF) {
component = 0xFF;
} else {
component = uint8(mixedComponent);
}
}
function _randomizeComponent(uint8 floor, uint8 ceiling, uint8 random, uint16 percent) private pure returns (uint8 component) {
component = floor + uint8(uint16(ceiling - (random & 0x01) - floor) * percent / uint16(100));
}
function _rawColor(ISVG.Color memory color) private pure returns (string memory) {
return string(abi.encodePacked(uint256(color.red).toString(), ",", uint256(color.green).toString(), ",", uint256(color.blue).toString()));
}
}
文件 20 的 24:Strings.sol
pragma solidity ^0.8.0;
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
function toString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
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] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
文件 21 的 24:TwoBitCubErrors.sol
pragma solidity ^0.8.4;
error AdoptionLimitReached();
error AgingAlreadyStarted();
error BearNotOwned(uint256 tokenId);
error CubNotOwned(uint256 tokenId);
error InvalidAdoptionQuantity();
error InvalidParentCombination();
error InvalidPriceSent();
error NoMoreCubs();
error NonexistentCub();
error NotOpenForMinting();
error NotYetRevealed();
文件 22 的 24:TwoBitCubs.sol
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "base64-sol/base64.sol";
import "../interfaces/ICubTraitProvider.sol";
import "../utils/CubComposition.sol";
import "../utils/TwoBitCubErrors.sol";
import "./TwoBitHoney.sol";
contract TwoBitCubs is ERC721Enumerable, ICubTraitProvider, Ownable, ReentrancyGuard {
using Strings for uint256;
uint256 public constant ADOPTION_PRICE = 0.15 ether;
uint256 public constant ADULT_AGE = 44000;
uint256 public constant MAX_CUBS = 7500;
uint256 public constant MAX_ADOPT_QUANTITY = 10;
uint256 public constant TOTAL_ADOPTIONS = 2500;
TwoBitHoney internal immutable _twoBitHoney;
uint256 private _adoptedCubs;
uint256 private _tokenCounter;
uint256 private _seed;
uint256 private _wenMint;
bool private _wenReveal;
mapping(uint256 => ICubTraits.DNA) private _tokenIdsToCubDNA;
mapping(uint256 => uint256) private _tokenIdsToBirthday;
constructor(address twoBitHoney) ERC721("TwoBitCubs", "TBC") {
_seed = uint256(keccak256(abi.encodePacked(msg.sender, blockhash(block.number-1), uint24(block.number))));
_twoBitHoney = TwoBitHoney(twoBitHoney);
_wenMint = 0;
_wenReveal = false;
}
function adoptCub(uint256 quantity) public payable nonReentrant {
if (_wenMint == 0 || block.number < _wenMint) revert NotOpenForMinting();
if (quantity == 0 || quantity > MAX_ADOPT_QUANTITY) revert InvalidAdoptionQuantity();
if (quantity > remainingAdoptions()) revert AdoptionLimitReached();
if (msg.value < ADOPTION_PRICE * quantity) revert InvalidPriceSent();
_mintCubs(0xFFFF, 0xFFFF, quantity);
_adoptedCubs += quantity;
}
function decimals() public pure returns (uint256) {
return 0;
}
function familyForTraits(ICubTraits.TraitsV1 memory traits) public pure override returns (string memory) {
string[18] memory families = ["Maeda", "Buffett", "Milonakis", "Petty", "VanDough", "Dammrich", "Pleasr", "Farmer", "Evan Dennis", "Hobbs", "Viselner", "Ghxsts", "Greenawalt", "Capacity", "Sheridan", "Ong", "Orrell", "Kong"];
return families[traits.familyIndex];
}
function mateBears(uint256 parentBearOne, uint256 parentBearTwo) public nonReentrant {
if (_wenMint == 0 || block.number < _wenMint) revert NotOpenForMinting();
if (parentBearOne == parentBearTwo || _twoBitHoney.bearSpecies(parentBearOne) != _twoBitHoney.bearSpecies(parentBearTwo)) revert InvalidParentCombination();
if (!_twoBitHoney.ownsBear(msg.sender, parentBearOne)) revert BearNotOwned(parentBearOne);
if (!_twoBitHoney.ownsBear(msg.sender, parentBearTwo)) revert BearNotOwned(parentBearTwo);
_twoBitHoney.burnHoneyForAddress(msg.sender);
uint8 siblingSeed = uint8(_seed % 256);
uint256 quantity = 1 + CubComposition.randomIndexFromPercentages(siblingSeed, _cubSiblingPercentages());
_mintCubs(uint16(parentBearOne), uint16(parentBearTwo), quantity);
}
function wakeCub(uint256 tokenId) public nonReentrant {
if (msg.sender != ownerOf(tokenId)) revert CubNotOwned(tokenId);
if (_tokenIdsToBirthday[tokenId] > 0) revert AgingAlreadyStarted();
_tokenIdsToBirthday[tokenId] = block.number;
}
function isAdopted(ICubTraits.DNA memory dna) public pure override returns (bool) {
return dna.firstParentTokenId == 0xFFFF;
}
function moodForType(ICubTraits.CubMoodType moodType) public pure override returns (string memory) {
string[14] memory moods = ["Happy", "Hungry", "Sleepy", "Grumpy", "Cheerful", "Excited", "Snuggly", "Confused", "Ravenous", "Ferocious", "Hangry", "Drowsy", "Cranky", "Furious"];
return moods[uint256(moodType)];
}
function moodFromParents(uint256 firstParentTokenId, uint256 secondParentTokenId) public view returns (ICubTraits.CubMoodType) {
IBearable.BearMoodType moodOne = _twoBitHoney.bearMood(firstParentTokenId);
IBearable.BearMoodType moodTwo = _twoBitHoney.bearMood(secondParentTokenId);
(uint8 smaller, uint8 larger) = moodOne < moodTwo ? (uint8(moodOne), uint8(moodTwo)) : (uint8(moodTwo), uint8(moodOne));
if (smaller == 0) {
return ICubTraits.CubMoodType(4 + larger - smaller);
} else if (smaller == 1) {
return ICubTraits.CubMoodType(8 + larger - smaller);
} else if (smaller == 2) {
return ICubTraits.CubMoodType(11 + larger - smaller);
}
return ICubTraits.CubMoodType(13 + larger - smaller);
}
function nameForTraits(ICubTraits.TraitsV1 memory traits) public pure override returns (string memory) {
string[18] memory names = ["Rhett", "Clon", "2476", "Tank", "Gremplin", "eBoy", "Pablo", "Chuck", "Justin", "MouseDev", "Pranksy", "Rik", "Joshua", "Racecar", "0xInuarashi", "OhhShiny", "Gary", "Kilo"];
return names[traits.nameIndex];
}
function remainingAdoptions() public view returns (uint256) {
return TOTAL_ADOPTIONS - _adoptedCubs;
}
function speciesForType(ICubTraits.CubSpeciesType speciesType) public pure override returns (string memory) {
string[4] memory species = ["Brown", "Black", "Polar", "Panda"];
return species[uint256(speciesType)];
}
function traitsV1(uint256 tokenId) public view override returns (ICubTraits.TraitsV1 memory traits) {
if (!_exists(tokenId)) revert NonexistentCub();
if (!_wenReveal) revert NotYetRevealed();
ICubTraits.DNA memory dna = _tokenIdsToCubDNA[tokenId];
bytes memory genes = abi.encodePacked(dna.genes);
uint256 increment = (tokenId % 20) + 1;
uint256 birthday = _tokenIdsToBirthday[tokenId];
if (birthday > 0) {
traits.age = block.number - birthday;
}
if (isAdopted(dna)) {
traits.species = ICubTraits.CubSpeciesType(CubComposition.randomIndexFromPercentages(uint8(genes[9 + increment]), _adoptedPercentages()));
traits.topColor = CubComposition.colorTopFromRandom(genes, 6 + increment, 3 + increment, 4 + increment, traits.species);
traits.bottomColor = CubComposition.colorBottomFromRandom(genes, 5 + increment, 7 + increment, 1 + increment, traits.species);
traits.mood = ICubTraits.CubMoodType(CubComposition.randomIndexFromPercentages(uint8(genes[increment]), _adoptedPercentages()));
} else {
traits.species = ICubTraits.CubSpeciesType(uint8(_twoBitHoney.bearSpecies(dna.firstParentTokenId)));
traits.topColor = CubComposition.randomColorFromColors(_twoBitHoney.bearTopColor(dna.firstParentTokenId), _twoBitHoney.bearTopColor(dna.secondParentTokenId), genes, 6 + increment, 3 + increment);
traits.bottomColor = CubComposition.randomColorFromColors(_twoBitHoney.bearBottomColor(dna.firstParentTokenId), _twoBitHoney.bearBottomColor(dna.secondParentTokenId), genes, 5 + increment, 7 + increment);
traits.mood = moodFromParents(dna.firstParentTokenId, dna.secondParentTokenId);
}
traits.nameIndex = uint8(uint8(genes[2 + increment]) % 18);
traits.familyIndex = uint8(uint8(genes[8 + increment]) % 18);
}
function revealCubs() public onlyOwner {
_wenReveal = true;
}
function setMintingBlock(uint256 wenMint) public onlyOwner {
_wenMint = wenMint;
}
function imageSVG(uint256 tokenId) public view returns (string memory) {
ICubTraits.TraitsV1 memory traits = traitsV1(tokenId);
return string(CubComposition.createSvg(traits, ADULT_AGE));
}
function imageURI(uint256 tokenId) public view returns (string memory) {
return string(abi.encodePacked(_baseImageURI(), Base64.encode(bytes(imageSVG(tokenId)))));
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (!_exists(tokenId)) revert NonexistentCub();
return string(abi.encodePacked(_baseURI(), Base64.encode(_metadataForToken(tokenId))));
}
function withdrawAll() public payable onlyOwner {
payable(0xDC009bCb27c70A6Da5A083AA8C606dEB26806a01).transfer(address(this).balance);
}
function _adoptedPercentages() private pure returns (uint8[] memory percentages) {
uint8[] memory array = new uint8[](3);
array[0] = 54;
array[1] = 30;
array[2] = 15;
return array;
}
function _attributesFromTraits(ICubTraits.TraitsV1 memory traits) private pure returns (bytes memory) {
return abi.encodePacked(
"trait_type\":\"Species\",\"value\":\"", speciesForType(traits.species),
_attributePair("Mood", moodForType(traits.mood)),
_attributePair("Name", nameForTraits(traits)),
_attributePair("Family", familyForTraits(traits)),
_attributePair("Realistic Head Fur", SVG.svgColorWithType(traits.topColor, ISVG.ColorType.None)),
_attributePair("Realistic Body Fur", SVG.svgColorWithType(traits.bottomColor, ISVG.ColorType.None))
);
}
function _attributePair(string memory name, string memory value) private pure returns (bytes memory) {
return abi.encodePacked("\"},{\"trait_type\":\"", name, "\",\"value\":\"", value);
}
function _baseImageURI() private pure returns (string memory) {
return "data:image/svg+xml;base64,";
}
function _baseURI() internal pure virtual override returns (string memory) {
return "data:application/json;base64,";
}
function _cubSiblingPercentages() private pure returns (uint8[] memory percentages) {
uint8[] memory array = new uint8[](2);
array[0] = 70;
array[1] = 25;
return array;
}
function _metadataForToken(uint256 tokenId) private view returns (bytes memory) {
if (_wenReveal) {
ICubTraits.DNA memory dna = _tokenIdsToCubDNA[tokenId];
ICubTraits.TraitsV1 memory traits = traitsV1(tokenId);
return abi.encodePacked(
"{\"name\":\"",
_nameFromTraits(traits, tokenId),
"\",\"description\":\"",
moodForType(traits.mood), " ", speciesForType(traits.species),
"\",\"attributes\":[{\"",
_attributesFromTraits(traits), _parentAttributesFromDNA(dna),
"\"}],\"image\":\"",
_baseImageURI(), Base64.encode(CubComposition.createSvg(traits, ADULT_AGE)),
"\"}"
);
}
return abi.encodePacked(
"{\"name\":\"Rendering Cub #", tokenId.toString(), "...\",\"description\":\"Unrevealed\",\"image\":\"ipfs://Qmc5YVyzKZ6D3wjqLFcfUBPtp9yh7NKxst2M2N3nDFdKDZ\"}"
);
}
function _mintCubs(uint16 parentBearOne, uint16 parentBearTwo, uint256 quantity) private {
if (_tokenCounter + quantity > MAX_CUBS) revert NoMoreCubs();
uint256 localSeed = _seed;
uint256 tokenId = _tokenCounter;
for (uint256 i = 0; i < quantity; i++) {
_safeMint(msg.sender, tokenId);
_tokenIdsToCubDNA[tokenId] = ICubTraits.DNA(_seed, parentBearOne, parentBearTwo);
tokenId += 1;
if (i + 1 < quantity) {
localSeed = uint256(keccak256(abi.encodePacked(localSeed >> 1)));
}
}
_tokenCounter = tokenId;
_seed = uint256(keccak256(abi.encodePacked(localSeed >> 1, msg.sender, blockhash(block.number-1), uint24(block.number))));
}
function _nameFromTraits(ICubTraits.TraitsV1 memory traits, uint256 tokenId) private pure returns (string memory) {
string memory speciesSuffix = traits.age < ADULT_AGE ? " Cub #" : " Bear #";
return string(abi.encodePacked(nameForTraits(traits), " ", familyForTraits(traits), " the ", moodForType(traits.mood), " ", speciesForType(traits.species), speciesSuffix, tokenId.toString()));
}
function _parentAttributesFromDNA(ICubTraits.DNA memory dna) private pure returns (bytes memory) {
if (dna.firstParentTokenId == 0xFFFF) {
return "";
}
(uint256 smaller, uint256 larger) = dna.firstParentTokenId < dna.secondParentTokenId ?
(dna.firstParentTokenId, dna.secondParentTokenId) :
(dna.secondParentTokenId, dna.firstParentTokenId);
string memory parents = string(abi.encodePacked("#", (smaller + 1).toString(), " & #", (larger + 1).toString()));
return _attributePair("Parents", parents);
}
}
文件 23 的 24:TwoBitHoney.sol
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "../interfaces/IBearable.sol";
abstract contract TwoBitHoney is IERC1155, IBearable {
function setCubsContractAddress(address cubsContract) external virtual;
function burnHoneyForAddress(address burnTokenAddress) external virtual;
}
文件 24 的 24:base64.sol
pragma solidity >=0.6.0;
library Base64 {
string internal constant TABLE_ENCODE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
bytes internal constant TABLE_DECODE = hex"0000000000000000000000000000000000000000000000000000000000000000"
hex"00000000000000000000003e0000003f3435363738393a3b3c3d000000000000"
hex"00000102030405060708090a0b0c0d0e0f101112131415161718190000000000"
hex"001a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132330000000000";
function encode(bytes memory data) internal pure returns (string memory) {
if (data.length == 0) return '';
string memory table = TABLE_ENCODE;
uint256 encodedLen = 4 * ((data.length + 2) / 3);
string memory result = new string(encodedLen + 32);
assembly {
mstore(result, encodedLen)
let tablePtr := add(table, 1)
let dataPtr := data
let endPtr := add(dataPtr, mload(data))
let resultPtr := add(result, 32)
for {} 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 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) }
case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) }
}
return result;
}
function decode(string memory _data) internal pure returns (bytes memory) {
bytes memory data = bytes(_data);
if (data.length == 0) return new bytes(0);
require(data.length % 4 == 0, "invalid base64 decoder input");
bytes memory table = TABLE_DECODE;
uint256 decodedLen = (data.length / 4) * 3;
bytes memory result = new bytes(decodedLen + 32);
assembly {
let lastBytes := mload(add(data, mload(data)))
if eq(and(lastBytes, 0xFF), 0x3d) {
decodedLen := sub(decodedLen, 1)
if eq(and(lastBytes, 0xFFFF), 0x3d3d) {
decodedLen := sub(decodedLen, 1)
}
}
mstore(result, decodedLen)
let tablePtr := add(table, 1)
let dataPtr := data
let endPtr := add(dataPtr, mload(data))
let resultPtr := add(result, 32)
for {} lt(dataPtr, endPtr) {}
{
dataPtr := add(dataPtr, 4)
let input := mload(dataPtr)
let output := add(
add(
shl(18, and(mload(add(tablePtr, and(shr(24, input), 0xFF))), 0xFF)),
shl(12, and(mload(add(tablePtr, and(shr(16, input), 0xFF))), 0xFF))),
add(
shl( 6, and(mload(add(tablePtr, and(shr( 8, input), 0xFF))), 0xFF)),
and(mload(add(tablePtr, and( input , 0xFF))), 0xFF)
)
)
mstore(resultPtr, shl(232, output))
resultPtr := add(resultPtr, 3)
}
}
return result;
}
}
{
"compilationTarget": {
"contracts/nfts/TwoBitCubs.sol": "TwoBitCubs"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"twoBitHoney","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AdoptionLimitReached","type":"error"},{"inputs":[],"name":"AgingAlreadyStarted","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"BearNotOwned","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"CubNotOwned","type":"error"},{"inputs":[],"name":"InvalidAdoptionQuantity","type":"error"},{"inputs":[],"name":"InvalidParentCombination","type":"error"},{"inputs":[],"name":"InvalidPriceSent","type":"error"},{"inputs":[],"name":"NoMoreCubs","type":"error"},{"inputs":[],"name":"NonexistentCub","type":"error"},{"inputs":[],"name":"NotOpenForMinting","type":"error"},{"inputs":[],"name":"NotYetRevealed","type":"error"},{"inputs":[],"name":"RatioInvalid","type":"error"},{"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":"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":"ADOPTION_PRICE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ADULT_AGE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_ADOPT_QUANTITY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_CUBS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOTAL_ADOPTIONS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"adoptCub","outputs":[],"stateMutability":"payable","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":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"age","type":"uint256"},{"components":[{"internalType":"uint8","name":"red","type":"uint8"},{"internalType":"uint8","name":"green","type":"uint8"},{"internalType":"uint8","name":"blue","type":"uint8"},{"internalType":"uint8","name":"alpha","type":"uint8"}],"internalType":"struct ISVG.Color","name":"topColor","type":"tuple"},{"components":[{"internalType":"uint8","name":"red","type":"uint8"},{"internalType":"uint8","name":"green","type":"uint8"},{"internalType":"uint8","name":"blue","type":"uint8"},{"internalType":"uint8","name":"alpha","type":"uint8"}],"internalType":"struct ISVG.Color","name":"bottomColor","type":"tuple"},{"internalType":"uint8","name":"nameIndex","type":"uint8"},{"internalType":"uint8","name":"familyIndex","type":"uint8"},{"internalType":"enum ICubTraits.CubMoodType","name":"mood","type":"uint8"},{"internalType":"enum ICubTraits.CubSpeciesType","name":"species","type":"uint8"}],"internalType":"struct ICubTraits.TraitsV1","name":"traits","type":"tuple"}],"name":"familyForTraits","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"imageSVG","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"imageURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"genes","type":"uint256"},{"internalType":"uint16","name":"firstParentTokenId","type":"uint16"},{"internalType":"uint16","name":"secondParentTokenId","type":"uint16"}],"internalType":"struct ICubTraits.DNA","name":"dna","type":"tuple"}],"name":"isAdopted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","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":"parentBearOne","type":"uint256"},{"internalType":"uint256","name":"parentBearTwo","type":"uint256"}],"name":"mateBears","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum ICubTraits.CubMoodType","name":"moodType","type":"uint8"}],"name":"moodForType","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"firstParentTokenId","type":"uint256"},{"internalType":"uint256","name":"secondParentTokenId","type":"uint256"}],"name":"moodFromParents","outputs":[{"internalType":"enum ICubTraits.CubMoodType","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"age","type":"uint256"},{"components":[{"internalType":"uint8","name":"red","type":"uint8"},{"internalType":"uint8","name":"green","type":"uint8"},{"internalType":"uint8","name":"blue","type":"uint8"},{"internalType":"uint8","name":"alpha","type":"uint8"}],"internalType":"struct ISVG.Color","name":"topColor","type":"tuple"},{"components":[{"internalType":"uint8","name":"red","type":"uint8"},{"internalType":"uint8","name":"green","type":"uint8"},{"internalType":"uint8","name":"blue","type":"uint8"},{"internalType":"uint8","name":"alpha","type":"uint8"}],"internalType":"struct ISVG.Color","name":"bottomColor","type":"tuple"},{"internalType":"uint8","name":"nameIndex","type":"uint8"},{"internalType":"uint8","name":"familyIndex","type":"uint8"},{"internalType":"enum ICubTraits.CubMoodType","name":"mood","type":"uint8"},{"internalType":"enum ICubTraits.CubSpeciesType","name":"species","type":"uint8"}],"internalType":"struct ICubTraits.TraitsV1","name":"traits","type":"tuple"}],"name":"nameForTraits","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","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":[],"name":"remainingAdoptions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revealCubs","outputs":[],"stateMutability":"nonpayable","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":"uint256","name":"wenMint","type":"uint256"}],"name":"setMintingBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum ICubTraits.CubSpeciesType","name":"speciesType","type":"uint8"}],"name":"speciesForType","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","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":"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":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"traitsV1","outputs":[{"components":[{"internalType":"uint256","name":"age","type":"uint256"},{"components":[{"internalType":"uint8","name":"red","type":"uint8"},{"internalType":"uint8","name":"green","type":"uint8"},{"internalType":"uint8","name":"blue","type":"uint8"},{"internalType":"uint8","name":"alpha","type":"uint8"}],"internalType":"struct ISVG.Color","name":"topColor","type":"tuple"},{"components":[{"internalType":"uint8","name":"red","type":"uint8"},{"internalType":"uint8","name":"green","type":"uint8"},{"internalType":"uint8","name":"blue","type":"uint8"},{"internalType":"uint8","name":"alpha","type":"uint8"}],"internalType":"struct ISVG.Color","name":"bottomColor","type":"tuple"},{"internalType":"uint8","name":"nameIndex","type":"uint8"},{"internalType":"uint8","name":"familyIndex","type":"uint8"},{"internalType":"enum ICubTraits.CubMoodType","name":"mood","type":"uint8"},{"internalType":"enum ICubTraits.CubSpeciesType","name":"species","type":"uint8"}],"internalType":"struct ICubTraits.TraitsV1","name":"traits","type":"tuple"}],"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":"uint256","name":"tokenId","type":"uint256"}],"name":"wakeCub","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAll","outputs":[],"stateMutability":"payable","type":"function"}]