文件 1 的 20:AbstractRoyalties.sol
pragma solidity ^0.8.6;
import "./LibPart.sol";
abstract contract AbstractRoyalties {
mapping (uint256 => LibPart.Part[]) public royalties;
function _saveRoyalties(uint256 _id, LibPart.Part[] memory _royalties) internal {
for (uint i = 0; i < _royalties.length; i++) {
require(_royalties[i].account != address(0x0), "Recipient should be present");
require(_royalties[i].value != 0, "Royalty value should be positive");
royalties[_id].push(_royalties[i]);
}
_onRoyaltiesSet(_id, _royalties);
}
function _updateAccount(uint256 _id, address _from, address _to) internal {
uint length = royalties[_id].length;
for(uint i = 0; i < length; i++) {
if (royalties[_id][i].account == _from) {
royalties[_id][i].account = payable(address(uint160(_to)));
}
}
}
function _onRoyaltiesSet(uint256 _id, LibPart.Part[] memory _royalties) virtual internal;
}
文件 2 的 20: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);
}
}
}
}
文件 3 的 20: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;
}
}
文件 4 的 20: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 的 20:ERC721.sol
pragma solidity ^0.8.6;
import '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
import '@openzeppelin/contracts/utils/Address.sol';
import '@openzeppelin/contracts/utils/Context.sol';
import '@openzeppelin/contracts/utils/Strings.sol';
import '@openzeppelin/contracts/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 creator,
address to,
uint256 tokenId
) internal virtual {
_safeMint(creator, to, tokenId, '');
}
function _safeMint(
address creator,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(creator, to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
'ERC721: transfer to non ERC721Receiver implementer'
);
}
function _mint(
address creator,
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), creator, tokenId);
emit Transfer(creator, 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(to).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 的 20:IDescriptor.sol
pragma solidity ^0.8.6;
import { ISeeder } from '../seeder/ISeeder.sol';
interface IDescriptor {
event PartsLocked();
event DataURIToggled(bool enabled);
event BaseURIUpdated(string baseURI);
function arePartsLocked() external returns (bool);
function isDataURIEnabled() external returns (bool);
function baseURI() external returns (string memory);
function palettes(uint8 paletteIndex, uint256 colorIndex) external view returns (string memory);
function addManyColorsToPalette(uint8 paletteIndex, string[] calldata newColors) external;
function addColorToPalette(uint8 paletteIndex, string calldata color) external;
function backgrounds(uint256 index) external view returns (string memory);
function backgroundCount() external view returns (uint256);
function addManyBackgrounds(string[] calldata backgrounds) external;
function addBackground(string calldata background) external;
function oneOfOnes(uint256 index) external view returns (bytes memory);
function oneOfOnesCount() external view returns (uint256);
function addOneOfOne(bytes calldata _oneOfOne) external;
function addManyOneOfOnes(bytes[] calldata _oneOfOnes) external;
function skins(uint256 index) external view returns (bytes memory);
function skinsCount() external view returns (uint256);
function addManySkins(bytes[] calldata skins) external;
function addSkin(bytes calldata skin) external;
function hats(uint256 index) external view returns (bytes memory);
function hatsCount() external view returns (uint256);
function addManyHats(bytes[] calldata hats) external;
function addHat(bytes calldata hat) external;
function clothes(uint256 index) external view returns (bytes memory);
function clothesCount() external view returns (uint256);
function addManyClothes(bytes[] calldata ears) external;
function addClothes(bytes calldata ear) external;
function mouths(uint256 index) external view returns (bytes memory);
function mouthsCount() external view returns (uint256);
function addManyMouths(bytes[] calldata mouths) external;
function addMouth(bytes calldata mouth) external;
function eyes(uint256 index) external view returns (bytes memory);
function eyesCount() external view returns (uint256);
function addManyEyes(bytes[] calldata eyes) external;
function addEyes(bytes calldata eye) external;
function accessory(uint256 index) external view returns (bytes memory);
function accessoryCount() external view returns (uint256);
function addManyAccessories(bytes[] calldata noses) external;
function addAccessory(bytes calldata nose) external;
function bgItems(uint256 index) external view returns (bytes memory);
function bgItemsCount() external view returns (uint256);
function addManyBgItems(bytes[] calldata noses) external;
function addBgItem(bytes calldata nose) external;
function lockParts() external;
function toggleDataURIEnabled() external;
function setBaseURI(string calldata baseURI) external;
function tokenURI(uint256 tokenId, ISeeder.Seed memory seed) external view returns (string memory);
function dataURI(uint256 tokenId, ISeeder.Seed memory seed) external view returns (string memory);
function genericDataURI(
string calldata name,
string calldata description,
ISeeder.Seed memory seed
) external view returns (string memory);
function generateSVGImage(ISeeder.Seed memory seed) external view returns (string memory);
}
文件 7 的 20:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 8 的 20: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;
}
文件 9 的 20: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);
}
文件 10 的 20:IERC721Receiver.sol
pragma solidity ^0.8.0;
interface IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
文件 11 的 20:IProxyRegistry.sol
pragma solidity ^0.8.6;
interface IProxyRegistry {
function proxies(address) external view returns (address);
}
文件 12 的 20:ISeeder.sol
pragma solidity ^0.8.6;
import { IDescriptor } from '../descriptor/IDescriptor.sol';
interface ISeeder {
struct Seed {
uint48 background;
uint48 skin;
uint48 clothes;
uint48 eyes;
uint48 mouth;
uint48 accessory;
uint48 bgItem;
uint48 hat;
bool oneOfOne;
uint48 oneOfOneIndex;
}
function generateSeed(uint256 wizardId, IDescriptor descriptor, bool isOneOfOne, uint48 isOneOfOneIndex) external view returns (Seed memory);
}
文件 13 的 20:IWizards.sol
pragma solidity ^0.8.6;
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {ISeeder} from "./seeder/ISeeder.sol";
import {IDescriptor} from "./descriptor/IDescriptor.sol";
interface IWizardToken is IERC721 {
event SupplyUpdated(uint256 indexed supply);
event WizardCreated(uint256 indexed tokenId, ISeeder.Seed seed);
event WizardBurned(uint256 indexed tokenId);
event CreatorsDAOUpdated(address creatorsDAO);
event MinterUpdated(address minter);
event MinterLocked();
event DescriptorUpdated(IDescriptor descriptor);
event DescriptorLocked();
event SeederUpdated(ISeeder seeder);
event SeederLocked();
function mint() external returns (uint256);
function mintOneOfOne(uint48 oneOfOneId) external returns (uint256, bool);
function burn(uint256 tokenId) external;
function dataURI(uint256 tokenId) external returns (string memory);
function setCreatorsDAO(address creatorsDAO) external;
function setMinter(address minter) external;
function lockMinter() external;
function setDescriptor(IDescriptor descriptor) external;
function lockDescriptor() external;
function setSeeder(ISeeder seeder) external;
function lockSeeder() external;
function setSupply(uint256 supply) external;
}
文件 14 的 20:LibPart.sol
pragma solidity ^0.8.6;
library LibPart {
bytes32 public constant TYPE_HASH = keccak256("Part(address account,uint96 value)");
struct Part {
address payable account;
uint96 value;
}
function hash(Part memory part) internal pure returns (bytes32) {
return keccak256(abi.encode(TYPE_HASH, part.account, part.value));
}
}
文件 15 的 20:LibRoyaltiesV2.sol
pragma solidity ^0.8.6;
library LibRoyaltiesV2 {
bytes4 constant _INTERFACE_ID_ROYALTIES = 0x44c74bcc;
}
文件 16 的 20: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());
}
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 {
_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);
}
}
文件 17 的 20:RoyaltiesV2.sol
pragma solidity ^0.8.6;
import "./LibPart.sol";
interface RoyaltiesV2 {
event RoyaltiesSet(uint256 tokenId, LibPart.Part[] royalties);
function getRaribleV2Royalties(uint256 id) external view returns (LibPart.Part[] memory);
}
文件 18 的 20:RoyaltiesV2Impl.sol
pragma solidity ^0.8.6;
import "./AbstractRoyalties.sol";
import "./RoyaltiesV2.sol";
contract RoyaltiesV2Impl is AbstractRoyalties, RoyaltiesV2 {
function getRaribleV2Royalties(uint256 id) override external view returns (LibPart.Part[] memory) {
return royalties[id];
}
function _onRoyaltiesSet(uint256 _id, LibPart.Part[] memory _royalties) override internal {
emit RoyaltiesSet(_id, _royalties);
}
}
文件 19 的 20: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);
}
}
文件 20 的 20:Wizards.sol
pragma solidity ^0.8.6;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IDescriptor} from "./descriptor/IDescriptor.sol";
import {ISeeder} from "./seeder/ISeeder.sol";
import {ERC721} from "../base/ERC721.sol";
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IProxyRegistry} from "../external/opensea/IProxyRegistry.sol";
import {IWizardToken} from "./IWizards.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "../external/rarible/RoyaltiesV2Impl.sol";
import "../external/rarible/LibPart.sol";
import "../external/rarible/LibRoyaltiesV2.sol";
contract WizardToken is IWizardToken, ERC721, Ownable, RoyaltiesV2Impl {
bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a;
address public creatorsDAO;
address public minter;
IDescriptor public descriptor;
ISeeder public seeder;
bool public isMinterLocked;
bool public isDescriptorLocked;
bool public isSeederLocked;
uint256 private supply;
mapping(uint256 => ISeeder.Seed) public seeds;
mapping(uint256 => uint8) private oneOfOneSupply;
uint256 private _currentID;
uint48 public lastOneOfOneId;
string private _contractURIHash =
"QmYURRfzZH7UkUmffxYifyTbyQu5axg8tt9wG92wpSoigi";
IProxyRegistry public immutable proxyRegistry;
uint256 public lastOneOfOneCount;
modifier whenMinterNotLocked() {
require(!isMinterLocked, "Minter is locked");
_;
}
modifier whenDescriptorNotLocked() {
require(!isDescriptorLocked, "Descriptor is locked");
_;
}
modifier whenSeederNotLocked() {
require(!isSeederLocked, "Seeder is locked");
_;
}
modifier onlyCreatorsDAO() {
require(msg.sender == creatorsDAO, "Sender is not the creators DAO");
_;
}
modifier onlyMinter() {
require(msg.sender == minter, "Sender is not the minter");
_;
}
constructor(
address _creatorsDAO,
address _minter,
IDescriptor _descriptor,
ISeeder _seeder,
IProxyRegistry _proxyRegistry,
uint256 _supply
) ERC721("Wizards", "WIZ") {
creatorsDAO = _creatorsDAO;
minter = _minter;
descriptor = _descriptor;
seeder = _seeder;
proxyRegistry = _proxyRegistry;
supply = _supply;
}
function setRoyalties(
uint256 _tokenId,
address payable _royaltiesReceipientAddress,
uint96 _percentageBasisPoints
) public onlyOwner {
LibPart.Part[] memory _royalties = new LibPart.Part[](1);
_royalties[0].value = _percentageBasisPoints;
_royalties[0].account = _royaltiesReceipientAddress;
_saveRoyalties(_tokenId, _royalties);
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721, IERC165)
returns (bool)
{
if (interfaceId == LibRoyaltiesV2._INTERFACE_ID_ROYALTIES) {
return true;
}
if (interfaceId == type(IERC165).interfaceId) {
return true;
}
if (interfaceId == _INTERFACE_ID_ERC2981) {
return true;
}
return super.supportsInterface(interfaceId);
}
function royaltyInfo(uint256 _tokenId, uint256 _salePrice)
external
view
returns (address receiver, uint256 royaltyAmount)
{
LibPart.Part[] memory _royalties = royalties[_tokenId];
if (_royalties.length > 0) {
return (
_royalties[0].account,
(_salePrice * _royalties[0].value) / 10000
);
}
return (address(0), 0);
}
function contractURI() public view returns (string memory) {
return string(abi.encodePacked("ipfs://", _contractURIHash));
}
function setContractURIHash(string memory newContractURIHash)
external
onlyOwner
{
_contractURIHash = newContractURIHash;
}
function isApprovedForAll(address owner, address operator)
public
view
override(IERC721, ERC721)
returns (bool)
{
if (proxyRegistry.proxies(owner) == operator) {
return true;
}
return super.isApprovedForAll(owner, operator);
}
function totalSupply() public view virtual returns (uint256) {
return _currentID;
}
function mint() public override onlyMinter returns (uint256) {
if (_currentID <= 318 && _currentID % 6 == 0) {
_mintTo(creatorsDAO, _currentID++, false, 0);
}
return _mintTo(minter, _currentID++, false, 0);
}
function mintOneOfOne(uint48 oneOfOneId)
public
override
onlyMinter
returns (uint256, bool)
{
uint256 oneCount = descriptor.oneOfOnesCount();
require(
uint256(oneOfOneId) < oneCount && oneOfOneId >= 0,
"one of one does not exist"
);
if (lastOneOfOneCount == oneCount) {
return (_mintTo(minter, _currentID++, false, 0), false);
}
uint8 oo = oneOfOneSupply[oneOfOneId];
if (oo == 0) {
uint256 wizardId = _mintTo(minter, _currentID++, true, oneOfOneId);
oneOfOneSupply[oneOfOneId] = 1;
lastOneOfOneId = oneOfOneId;
return (wizardId, true);
}
for (uint256 i = 0; i < oneCount; i++) {
uint8 ofo = oneOfOneSupply[i];
if (ofo == 0) {
uint256 wizardId = _mintTo(
minter,
_currentID++,
true,
uint48(i)
);
oneOfOneSupply[i] = 1;
lastOneOfOneId = uint48(i);
return (wizardId, true);
}
}
lastOneOfOneCount = oneCount;
return (_mintTo(minter, _currentID++, false, 0), false);
}
function burn(uint256 wizardId) public override onlyMinter {
_burn(wizardId);
emit WizardBurned(wizardId);
}
function tokenURI(uint256 tokenId)
public
view
override
returns (string memory)
{
require(
_exists(tokenId),
"WizardsToken: URI query for nonexistent token"
);
return descriptor.tokenURI(tokenId, seeds[tokenId]);
}
function dataURI(uint256 tokenId)
public
view
override
returns (string memory)
{
require(
_exists(tokenId),
"WizardsToken: URI query for nonexistent token"
);
return descriptor.dataURI(tokenId, seeds[tokenId]);
}
function setCreatorsDAO(address _creatorsDAO)
external
override
onlyCreatorsDAO
{
creatorsDAO = _creatorsDAO;
emit CreatorsDAOUpdated(_creatorsDAO);
}
function setMinter(address _minter)
external
override
onlyOwner
whenMinterNotLocked
{
minter = _minter;
emit MinterUpdated(_minter);
}
function lockMinter() external override onlyOwner whenMinterNotLocked {
isMinterLocked = true;
emit MinterLocked();
}
function setDescriptor(IDescriptor _descriptor)
external
override
onlyOwner
whenDescriptorNotLocked
{
descriptor = _descriptor;
emit DescriptorUpdated(_descriptor);
}
function lockDescriptor()
external
override
onlyOwner
whenDescriptorNotLocked
{
isDescriptorLocked = true;
emit DescriptorLocked();
}
function setSeeder(ISeeder _seeder)
external
override
onlyOwner
whenSeederNotLocked
{
seeder = _seeder;
emit SeederUpdated(_seeder);
}
function lockSeeder() external override onlyOwner whenSeederNotLocked {
isSeederLocked = true;
emit SeederLocked();
}
function setSupply(uint256 _supply) external override onlyOwner {
supply = _supply;
emit SupplyUpdated(_supply);
}
function _mintTo(
address to,
uint256 wizardId,
bool isOneOfOne,
uint48 oneOfOneIndex
) internal returns (uint256) {
require(wizardId < supply, "All wizards have been minted");
ISeeder.Seed memory seed = seeds[wizardId] = seeder.generateSeed(
wizardId,
descriptor,
isOneOfOne,
oneOfOneIndex
);
_mint(owner(), to, wizardId);
emit WizardCreated(wizardId, seed);
return wizardId;
}
}
{
"compilationTarget": {
"contracts/internal/Wizards.sol": "WizardToken"
},
"evmVersion": "berlin",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 10000
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_creatorsDAO","type":"address"},{"internalType":"address","name":"_minter","type":"address"},{"internalType":"contract IDescriptor","name":"_descriptor","type":"address"},{"internalType":"contract ISeeder","name":"_seeder","type":"address"},{"internalType":"contract IProxyRegistry","name":"_proxyRegistry","type":"address"},{"internalType":"uint256","name":"_supply","type":"uint256"}],"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":false,"internalType":"address","name":"creatorsDAO","type":"address"}],"name":"CreatorsDAOUpdated","type":"event"},{"anonymous":false,"inputs":[],"name":"DescriptorLocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IDescriptor","name":"descriptor","type":"address"}],"name":"DescriptorUpdated","type":"event"},{"anonymous":false,"inputs":[],"name":"MinterLocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"minter","type":"address"}],"name":"MinterUpdated","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":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"address payable","name":"account","type":"address"},{"internalType":"uint96","name":"value","type":"uint96"}],"indexed":false,"internalType":"struct LibPart.Part[]","name":"royalties","type":"tuple[]"}],"name":"RoyaltiesSet","type":"event"},{"anonymous":false,"inputs":[],"name":"SeederLocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract ISeeder","name":"seeder","type":"address"}],"name":"SeederUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"supply","type":"uint256"}],"name":"SupplyUpdated","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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"WizardBurned","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"uint48","name":"background","type":"uint48"},{"internalType":"uint48","name":"skin","type":"uint48"},{"internalType":"uint48","name":"clothes","type":"uint48"},{"internalType":"uint48","name":"eyes","type":"uint48"},{"internalType":"uint48","name":"mouth","type":"uint48"},{"internalType":"uint48","name":"accessory","type":"uint48"},{"internalType":"uint48","name":"bgItem","type":"uint48"},{"internalType":"uint48","name":"hat","type":"uint48"},{"internalType":"bool","name":"oneOfOne","type":"bool"},{"internalType":"uint48","name":"oneOfOneIndex","type":"uint48"}],"indexed":false,"internalType":"struct ISeeder.Seed","name":"seed","type":"tuple"}],"name":"WizardCreated","type":"event"},{"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":[{"internalType":"uint256","name":"wizardId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"creatorsDAO","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"dataURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"descriptor","outputs":[{"internalType":"contract IDescriptor","name":"","type":"address"}],"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":"uint256","name":"id","type":"uint256"}],"name":"getRaribleV2Royalties","outputs":[{"components":[{"internalType":"address payable","name":"account","type":"address"},{"internalType":"uint96","name":"value","type":"uint96"}],"internalType":"struct LibPart.Part[]","name":"","type":"tuple[]"}],"stateMutability":"view","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":[],"name":"isDescriptorLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isMinterLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isSeederLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastOneOfOneCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastOneOfOneId","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockDescriptor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lockMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lockSeeder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint48","name":"oneOfOneId","type":"uint48"}],"name":"mintOneOfOne","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","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":"proxyRegistry","outputs":[{"internalType":"contract IProxyRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"royalties","outputs":[{"internalType":"address payable","name":"account","type":"address"},{"internalType":"uint96","name":"value","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"royaltyAmount","type":"uint256"}],"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":[],"name":"seeder","outputs":[{"internalType":"contract ISeeder","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"seeds","outputs":[{"internalType":"uint48","name":"background","type":"uint48"},{"internalType":"uint48","name":"skin","type":"uint48"},{"internalType":"uint48","name":"clothes","type":"uint48"},{"internalType":"uint48","name":"eyes","type":"uint48"},{"internalType":"uint48","name":"mouth","type":"uint48"},{"internalType":"uint48","name":"accessory","type":"uint48"},{"internalType":"uint48","name":"bgItem","type":"uint48"},{"internalType":"uint48","name":"hat","type":"uint48"},{"internalType":"bool","name":"oneOfOne","type":"bool"},{"internalType":"uint48","name":"oneOfOneIndex","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"newContractURIHash","type":"string"}],"name":"setContractURIHash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_creatorsDAO","type":"address"}],"name":"setCreatorsDAO","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IDescriptor","name":"_descriptor","type":"address"}],"name":"setDescriptor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"setMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address payable","name":"_royaltiesReceipientAddress","type":"address"},{"internalType":"uint96","name":"_percentageBasisPoints","type":"uint96"}],"name":"setRoyalties","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISeeder","name":"_seeder","type":"address"}],"name":"setSeeder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_supply","type":"uint256"}],"name":"setSupply","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":"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":"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"}]