ERC-1155
Overview
Max Total Supply
8,992
Holders
187
Market
Volume (24H)
N/A
Min Price (24H)
N/A
Max Price (24H)
N/A
Other Info
Token Contract
Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Name:
MagicFolkItems
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Common.sol"; import "../utils/SigVer.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol"; import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "./MagicFolk.sol"; import "./MagicFolkGems.sol"; contract MagicFolkItems is ERC1155, ERC1155Holder, SigVer, Ownable, AccessControl, Pausable, ERC1155Supply, ReentrancyGuard { using ECDSA for bytes32; using Counters for Counters.Counter; MagicFolk _magicFolk; MagicFolkGems _magicFolkGems; address _signer; Counters.Counter private _itemCount; ItemType public immutable _itemType; string public _contractURI; mapping(uint256 => Item) public _items; mapping(uint256 => uint256) public _prices; mapping(uint256 => address) public _collabs; mapping(uint256 => uint256) public _collabAllowancePerNFT; // NFT Address => (tokenID => Amount Redeemed) mapping(address => mapping(uint256 => uint256)) public _collabItemsRedeemed; constructor(address signer, ItemType itemType) ERC1155("https://api.magicfolk.com/") { _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); _itemType = itemType; _pause(); _signer = signer; } function setMagicFolkGemsAddress(address magicFolkGems) public onlyRole(DEFAULT_ADMIN_ROLE) { _magicFolkGems = MagicFolkGems(magicFolkGems); } function setMagicFolkContractAddress(address magicFolk) public onlyRole(DEFAULT_ADMIN_ROLE) { _magicFolk = MagicFolk(magicFolk); } function setSignerAddress(address newSigner) external onlyRole(DEFAULT_ADMIN_ROLE) { _signer = newSigner; } function setURI(string memory newuri) public onlyRole(DEFAULT_ADMIN_ROLE) { _setURI(newuri); } function setContractURI(string memory newuri) public onlyRole(DEFAULT_ADMIN_ROLE) { _contractURI = newuri; } function contractURI() public view returns (string memory) { return _contractURI; } function pause() public onlyRole(DEFAULT_ADMIN_ROLE) { _pause(); } function unpause() public onlyRole(DEFAULT_ADMIN_ROLE) { _unpause(); } /** @dev function for equipping items to ERC721 NFT @param from address of NFT holder (must be sender also) @param itemId id of item they wish to equip @param magicFolkId tokenId of NFT they wish to equip the item to */ function equip( address from, uint256 itemId, uint256 magicFolkId ) public whenNotPaused { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" ); Item memory item = _getItem(itemId); bytes memory ownerIdAndItem = encodeOwnerIdAndItem(magicFolkId, item); _safeTransferFrom(from, address(_magicFolk), itemId, 1, ownerIdAndItem); } /** @dev function for unequipping items from ERC721 NFT @param from address of holder (must be sender) @param itemId id of item they wish to unequip @param magicFolkId tokenId of NFT they wish to unequip the item from */ function unequip( address from, uint256 itemId, uint256 magicFolkId ) public whenNotPaused { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" ); Item memory item = _getItem(itemId); bytes memory ownerIdAndItem = encodeOwnerIdAndItem(magicFolkId, item); _magicFolk.unequip(from, ownerIdAndItem); } /** @return total number of items in this contract */ function itemCount() public view returns (uint256) { return _itemCount.current(); } function getItem(uint256 itemId) public view returns (Item memory) { require(_isInitialised(itemId), "Item not initalised"); return _getItem(itemId); } function _getItem(uint256 itemId) internal view returns (Item memory) { return _items[itemId]; } function _setPrice(uint256 itemId, uint256 price) internal { _prices[itemId] = price; } function setPrice(uint256 itemId, uint256 price) public onlyRole(DEFAULT_ADMIN_ROLE) { _setPrice(itemId, price); } function _getPrice(uint256 itemId) internal view returns (uint256) { return _prices[itemId]; } function getPrice(uint256 itemId) public view returns (uint256) { return _getPrice(itemId); } function getStockLeft(uint256 itemId) public view returns (uint256) { return balanceOf(address(this), itemId); } /** @dev Returns an array, A, in which A[id] is the balance of item with itemId of id. e.g. If there are 10 items that have been created, and I own 2 of the item with an itemId of 4, but zero of all other items, the array would look like: [0, 0, 0, 0, 1, 0, 0, 0, 0, 0] */ function getOwnedItems(address owner) public view returns (uint256[] memory) { uint256[] memory tokens = new uint256[](_itemCount.current()); for (uint256 i = 0; i < tokens.length; i++) { tokens[i] = balanceOf(owner, i); } return tokens; } /** @dev a bit like the mint function on our ERC721 contract, this is when the buyer actually pays for and receives an item that we've already minted a supply of in our store. @param to buyer's address @param itemId id of item they wish to buy @param amount amount they wish to buy */ function buyItem( address to, uint256 itemId, uint256 amount ) external nonReentrant { require(!_isCollabItem(itemId), "COLLAB_ITEM"); uint256 totalPrice = amount * _getPrice(itemId); uint256 gemBalance = _magicFolkGems.balanceOf(to); require(gemBalance >= totalPrice, "Insufficient funds"); require(_isInitialised(itemId), "Item not initialised"); _safeTransferFrom(address(this), to, itemId, amount, ""); _magicFolkGems.burn(to, totalPrice); } /** @dev A "whitelist" version of buyItem() for collab items @param itemId id of the collab item @param amount qty they wish to buy @param tokenId tokenId of collab NFT they're using to "redeem" this item, this is so we can check ownership and track how many items have been "redeemed" for each token in a collection we've collab'd with @param msgHash hashed message, should match the message that's been signed by our keypair on frontend. (['address', 'uint256'], [buyerAddress, tokenId]) @param signature signed version of msgHash */ function buyCollabItem( uint256 itemId, uint256 amount, uint256 tokenId, bytes32 msgHash, bytes calldata signature ) external nonReentrant { address to = msg.sender; require(_isCollabItem(itemId), "NOT_COLLAB_ITEM"); require(_ownsToken(to, _collabs[itemId], tokenId), "NOT_YOUR_TOKEN"); uint256 totalPrice = amount * _getPrice(itemId); uint256 gemBalance = _magicFolkGems.balanceOf(to); require(gemBalance >= totalPrice, "INSUFFICIENT_FUNDS"); require(_isInitialised(itemId), "Item not initialised"); require( amount + _getRedeemed(itemId, tokenId) <= _collabAllowancePerNFT[itemId], "TX_WILL_EXCEED_ALLOWANCE" ); require( _verifyMsg(to, tokenId, msgHash, signature, _signer), "INVALID_SIG" ); _safeTransferFrom(address(this), to, itemId, amount, ""); _magicFolkGems.burn(to, totalPrice); _redeemCollabItem(itemId, tokenId, amount); } /** @dev Once an item has been 'created' with the mint function, this function can be used to change the stats for the item. @param itemId the id assigned to this item in the mint function @param powerLevel the power level to be assigned to this item @param itemType ItemType.Mainhand || ItemType.offhand || ItemType.pet, should be the same as the contracts _itemType value @param price price in gems that buyers will have to pay, can be altered later with setPrice() also. */ function setItem( uint256 itemId, uint8 powerLevel, ItemType itemType, uint256 price ) public onlyRole(DEFAULT_ADMIN_ROLE) { _setItem(itemId, powerLevel, itemType, price); } function _setItem( uint256 itemId, uint8 powerLevel, ItemType itemType, uint256 price ) internal { require(itemType == _itemType); Item memory item; item.itemId = itemId; item.powerLevel = powerLevel; item.itemType = itemType; _items[itemId] = item; _setPrice(itemId, price); } /** @dev Mint more tokens for an item that has been created @param itemId The id for the item you're minting @param amount The quantity to be minted */ function mint(uint256 itemId, uint256 amount) public whenNotPaused onlyRole(DEFAULT_ADMIN_ROLE) { require(itemId < _itemCount.current(), "ITEM_NOT_EXIST"); _mint(address(this), itemId, amount, ""); } /** @dev Create a new *non*-collab item with stats provided. Stats can be updated later with setItem() if a mistake has been made. @param initialSupply The initial token supply for this item. More can be minted in future if needed. But in most situations this will be the only stock we create for an item. @param powerLevel Power level stat for item. @param itemType ItemType enum for this item, simply ensures the correct contract is being used. Tx will revert if incorrect itemType is provided. @param price Initial price for item in $GEMZ */ function createItem( uint256 initialSupply, uint8 powerLevel, ItemType itemType, uint256 price ) public onlyRole(DEFAULT_ADMIN_ROLE) { uint256 itemId = _itemCount.current(); _setItem(itemId, powerLevel, itemType, price); _mint(address(this), itemId, initialSupply, ""); _itemCount.increment(); } /** @dev Overload of standard createItem function with 2 extra parameters, creates a collab item. Apart from this, it's exactly the same. First 4 params are the same. @param initialSupply The initial token supply for this item. More can be minted in future if needed. But in most situations this will be the only stock we create for an item. @param powerLevel Power level stat for item. @param itemType ItemType enum for this item, simply ensures the correct contract is being used. Tx will revert if incorrect itemType is provided. @param price Initial price for item in $GEMZ. For collab items this will sometimes be zero. @param nftContract Address of contract for the Collab NFT. For example, if the collab is with BAYC the address would be: 0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D (mainnet) @param allowancePerNFT The amount of items someone can mint for every eligible NFT they hold. In 99% of cases, this will be 1, but there may be some situations where we want a higher number. */ function createItem( uint256 initialSupply, uint8 powerLevel, ItemType itemType, uint256 price, address nftContract, uint256 allowancePerNFT ) public onlyRole(DEFAULT_ADMIN_ROLE) { uint256 itemId = _itemCount.current(); _addCollabItem(itemId, nftContract, allowancePerNFT); _setItem(itemId, powerLevel, itemType, price); _mint(address(this), itemId, initialSupply, ""); _itemCount.increment(); } function mintBatch( address, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public onlyRole(DEFAULT_ADMIN_ROLE) { _mintBatch(address(this), ids, amounts, data); } function _ownsToken( address to, address nftContract, uint256 tokenId ) internal view returns (bool) { return IERC721(nftContract).ownerOf(tokenId) == to; } function _addCollabItem( uint256 itemId, address nftContract, uint256 allowance ) internal { _collabs[itemId] = nftContract; _collabAllowancePerNFT[itemId] = allowance; } function _redeemCollabItem( uint256 itemId, uint256 tokenId, uint256 qty ) internal { _collabItemsRedeemed[_collabs[itemId]][tokenId] += qty; } function _getRedeemed(uint256 itemId, uint256 tokenId) internal view returns (uint256) { return _collabItemsRedeemed[_collabs[itemId]][tokenId]; } function isCollabItem(uint256 itemId) external view returns (bool) { return _isCollabItem(itemId); } function _isCollabItem(uint256 itemId) internal view returns (bool) { return _collabs[itemId] != address(0); } function _isInitialised(uint256 itemId) internal view returns (bool) { Item memory item = _getItem(itemId); return (item.itemType != ItemType.Empty); } function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal override(ERC1155, ERC1155Supply) whenNotPaused { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); } function supportsInterface(bytes4 interfaceID) public view virtual override(ERC1155, ERC1155Receiver, AccessControl) returns (bool) { return super.supportsInterface(interfaceID) || interfaceID == type(IERC1155Receiver).interfaceId || // ERC165 interfaceID == 0x01ffc9a7 || // ERC1155_ACCEPTED ^ ERC1155_BATCH_ACCEPTED; interfaceID == 0x4e2312e0; } /// TEST FUNCTIONS /// TODO: remove before mainnet function encodeItem(uint256 itemId) public view returns (bytes memory) { return encodeOwnerIdAndItem(0, _items[itemId]); } function decodeItem(bytes calldata encodedOwnerIdAndItem) public pure returns (uint256, Item memory) { require(encodedOwnerIdAndItem.length == 128, "wronglen"); return decodeOwnerIdAndItem(encodedOwnerIdAndItem); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; enum ItemType { Empty, // 0 Mainhand, // 1 Offhand, // 2 Pet // 3 } /// 288 bytes struct Item { uint256 itemId; uint8 powerLevel; ItemType itemType; } /// ownerId is the tokenId of the nft that the item is being equipped to, this /// nft essentially "owns" the item while it's held in the MagicFolk contract function encodeOwnerIdAndItem( uint256 ownerId, Item memory item ) pure returns (bytes memory) { // bytes memory _ownerId = abi.encodePacked(ownerId); // bytes memory _item = abi.encode(item); // return bytes.concat(_ownerId, _item); return abi.encode(ownerId, item); } function decodeOwnerIdAndItem( bytes calldata _data ) pure returns (uint256, Item memory) { uint256 ownerId = abi.decode(_data[:32], (uint256)); // Item memory item = abi.decode(_data[32:], (Item)); // Life is pain... Item memory item; item.itemId = abi.decode(_data[32:64], (uint256)); item.powerLevel = abi.decode(_data[64:96], (uint8)); item.itemType = abi.decode(_data[96:], (ItemType)); return (ownerId, item); } contract CommonConstants { bytes4 constant internal ERC1155_RECEIVED_VALUE = 0xf23a6e61; bytes4 constant internal ERC1155_BATCH_RECEIVED_VALUE = 0xbc197c81; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; contract SigVer { using ECDSA for bytes32; function verifyMsg( address sender, uint256 value, bytes32 msgHash, bytes memory signature, address _signer ) public pure returns (bool) { return _verifyMsg(sender, value, msgHash, signature, _signer); } function hashMsg( address sender, uint256 value ) public pure returns (bytes32) { return _hashMsg(sender, value); } function verifySigner( bytes32 msgHash, bytes memory signature, address _signer ) public pure returns (bool) { return _verifySigner(msgHash, signature, _signer); } function _verifyMsg( address sender, uint256 value, bytes32 msgHash, bytes memory signature, address _signer ) internal pure returns (bool) { return ( _verifySigner(msgHash, signature, _signer) && _hashMsg(sender, value) == msgHash ); } function _hashMsg( address sender, uint256 value ) internal pure returns (bytes32) { return keccak256(abi.encodePacked(sender, value)); } function _verifySigner( bytes32 msgHash, bytes memory signature, address _signer ) internal pure returns (bool) { return msgHash.toEthSignedMessageHash().recover(signature) == _signer; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.0; import "./IERC1155.sol"; import "./IERC1155Receiver.sol"; import "./extensions/IERC1155MetadataURI.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { using Address for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) public view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: address zero is not a valid owner"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner nor approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner nor approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, to, ids, amounts, data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); _balances[id][to] += amount; emit TransferSingle(operator, address(0), to, id, amount); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `from` * * Emits a {TransferSingle} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ function _burn( address from, uint256 id, uint256 amount ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } emit TransferSingle(operator, from, address(0), id, amount); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch( address from, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } } emit TransferBatch(operator, from, address(0), ids, amounts); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `ids` and `amounts` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155Receiver.onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155Receiver.onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC1155/extensions/ERC1155Supply.sol) pragma solidity ^0.8.0; import "../ERC1155.sol"; /** * @dev Extension of ERC1155 that adds tracking of total supply per id. * * Useful for scenarios where Fungible and Non-fungible tokens have to be * clearly identified. Note: While a totalSupply of 1 might mean the * corresponding is an NFT, there is no guarantees that no other token with the * same id are not going to be minted. */ abstract contract ERC1155Supply is ERC1155 { mapping(uint256 => uint256) private _totalSupply; /** * @dev Total amount of tokens in with a given id. */ function totalSupply(uint256 id) public view virtual returns (uint256) { return _totalSupply[id]; } /** * @dev Indicates whether any token exist with a given id, or not. */ function exists(uint256 id) public view virtual returns (bool) { return ERC1155Supply.totalSupply(id) > 0; } /** * @dev See {ERC1155-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); if (from == address(0)) { for (uint256 i = 0; i < ids.length; ++i) { _totalSupply[ids[i]] += amounts[i]; } } if (to == address(0)) { for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 supply = _totalSupply[id]; require(supply >= amount, "ERC1155: burn amount exceeds totalSupply"); unchecked { _totalSupply[id] = supply - amount; } } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol) pragma solidity ^0.8.0; import "./ERC1155Receiver.sol"; /** * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens. * * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be * stuck. * * @dev _Available since v3.1._ */ contract ERC1155Holder is ERC1155Receiver { function onERC1155Received( address, address, uint256, uint256, bytes memory ) public virtual override returns (bytes4) { return this.onERC1155Received.selector; } function onERC1155BatchReceived( address, address, uint256[] memory, uint256[] memory, bytes memory ) public virtual override returns (bytes4) { return this.onERC1155BatchReceived.selector; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Common.sol"; import "../utils/SigVer.sol"; import "./MagicFolkGems.sol"; import "./MagicFolkItems.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/interfaces/IERC721.sol"; import "@openzeppelin/contracts/interfaces/IERC1155.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; contract MagicFolk is ERC165, ERC721, ERC721Enumerable, ERC721Holder, CommonConstants, IERC1155Receiver, ReentrancyGuard, SigVer, AccessControl, Ownable { using Counters for Counters.Counter; struct Stats { uint8 powerLevel; Item mainHand; Item offHand; Item pet; } struct Payee { address wallet; uint16 percentagePoints; bytes24 payeeId; } // Setup payees // Hardcoded here instead of being added by an external function // for the sake of immutability and transparency. Payee[11] public _payees; event Equipped( uint256 indexed _tokenId, uint256 indexed _itemId, ItemType _itemType ); event Unequipped( uint256 indexed _tokenId, uint256 indexed _itemId, ItemType _itemType ); event Staked(uint256 indexed _tokenId, address owner); event Unstaked(uint256 indexed _tokenId, address owner); event publicSaleToggled(bool state); event privateSaleToggled(bool state); event stakingToggled(bool state); // token id => stats mapping(uint256 => Stats) private _tokenStats; // Private sale mapping(address => uint256) private _totalMintsPerAddress; // Public sale mapping(address => uint256) public _mintNonce; // Staking mapping(uint256 => uint256) private _lastClaims; mapping(uint256 => address) public _tokenOwners; mapping(address => uint256[]) public _stakedTokens; Counters.Counter private _tokenIdCounter; MagicFolkItems MAGIC_FOLK_MAINHAND; MagicFolkItems MAGIC_FOLK_OFFHAND; MagicFolkItems MAGIC_FOLK_PET; MagicFolkGems MAGIC_FOLK_GEMS; // MINT CONSTANTS uint256 public constant PUBLIC_ALLOWANCE = 10; uint256 public constant MAX_MINT = 9500; uint256 public constant TEAM_MINT = 500; uint256 public constant PRIVATE_PRICE = 0.1 ether; uint256 public constant PUBLIC_PRICE = 0.125 ether; address public constant FEE_ADDRESS = 0x670326f4470d4D2F5347377Ff187717a81aB1318; uint256 public _fees = 60.0 ether; uint256 public _teamMinted = 0; address public _signer; // Gems per day per power level uint256 _gemRate = 10; uint256 constant SECONDS_PER_DAY = 86400; string public _URI = "https://cdn-stg.magicfolk.io/api/genesis/"; uint8[MAX_MINT + TEAM_MINT] private _basePowerLevels; // token id => base power level bool private _publicSale = false; bool private _privateSale = false; bool private _powerLevelsSet = false; bool public _publicSaleSignatureRequired = true; bool public _stakingEnabled = false; bool public _listable = false; bool public _initialFeesWithdrawn = false; constructor( address signer, address magicFolkMainhand, address magicFolkOffhand, address magicFolkPet ) ERC721("Magic Folk", "MF") { _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _signer = signer; MAGIC_FOLK_MAINHAND = MagicFolkItems(magicFolkMainhand); MAGIC_FOLK_OFFHAND = MagicFolkItems(magicFolkOffhand); MAGIC_FOLK_PET = MagicFolkItems(magicFolkPet); _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); // Setup payees _payees[0] = Payee( 0x586a6c03DA4959C6341845C210b4CdBec930Af37, 265, "ELON_MUSK" ); _payees[1] = Payee( 0xa8fD19cb5F949677504DD90f8B6efe044286e6B2, 80, "DONALD_TRUMP" ); _payees[2] = Payee( 0xD85aA7341a63B413972c8e8D63Ae7a7bC08A5aFD, 25, "WARREN_BUFFET" ); _payees[3] = Payee( 0x4fB91f8b17702aFf47BE977A226dDdabf5475661, 25, "JEFF_BEZOS" ); _payees[4] = Payee( 0x7913FEDA30503465EDAdc674a66fbDcB581f6840, 120, "BILL_GATES" ); _payees[5] = Payee( 0x2E8a3F14feDA7FA7690260a06A1656BFe20bE1aC, 60, "LEBRON_JAMES" ); _payees[6] = Payee( 0x60d1082D0fdaB22990f56A70B68AdDC049F75EC8, 100, "NICOLAS_CAGE" ); _payees[7] = Payee( 0x71dcB19A6D322C9D826aA6b61442828436Aa6fb2, 50, "KENDRICK_LAMAR" ); _payees[8] = Payee( 0x996107A817f0fbaF389F1DCC1A48Dfb2eDb78D33, 25, "R_KELLY" ); _payees[9] = Payee( 0xAB1ca28b50EdC107023d81e71640da3ee26F93A0, 150, "LIL_DICKY" ); _payees[10] = Payee( 0x3750737d7fbF284705a329AB674D9309485B5bE2, 100, "JIMMY_CARR" ); uint256 percentagePointSum = 0; for (uint256 i = 0; i < _payees.length; i++) { percentagePointSum += _payees[i].percentagePoints; } require(percentagePointSum == 1000, "INVALID_PERCENTAGES"); } function setMagicFolkGemsContract(address magicFolkGems) public onlyRole(DEFAULT_ADMIN_ROLE) { MAGIC_FOLK_GEMS = MagicFolkGems(magicFolkGems); } function setMagicFolkItemsContract( address magicFolkItems, ItemType itemType ) public onlyRole(DEFAULT_ADMIN_ROLE) { if (itemType == ItemType.Mainhand) { MAGIC_FOLK_MAINHAND = MagicFolkItems(magicFolkItems); } else if (itemType == ItemType.Offhand) { MAGIC_FOLK_OFFHAND = MagicFolkItems(magicFolkItems); } else if (itemType == ItemType.Pet) { MAGIC_FOLK_PET = MagicFolkItems(magicFolkItems); } else { revert(); } } function setSignerAddress(address signer) external onlyRole(DEFAULT_ADMIN_ROLE) { _signer = signer; } function setBaseURI(string calldata URI) external onlyRole(DEFAULT_ADMIN_ROLE) { _URI = URI; } /** @dev Once enabled, listing on OpenSea cannot be disabled again. */ function enableListings() external onlyRole(DEFAULT_ADMIN_ROLE) { _listable = true; } /** @dev To prevent buyers listing on OpenSea before public and private sales have ended, we override this function to return false unless listings have been enabled. */ function isApprovedForAll(address owner, address operator) public view override returns (bool) { if (!_listable) { return false; } else { return super.isApprovedForAll(owner, operator); } } function _baseURI() internal view override returns (string memory) { return _URI; } function publicSaleActive() public view returns (bool) { return _publicSaleActive(); } function togglePublicSale() public onlyRole(DEFAULT_ADMIN_ROLE) { require(!_privateSaleActive()); _publicSale = !_publicSale; emit publicSaleToggled(_publicSale); } function toggleStaking() external onlyRole(DEFAULT_ADMIN_ROLE) { _stakingEnabled = !_stakingEnabled; emit stakingToggled(_stakingEnabled); } function togglePublicSaleSigRequired() public onlyRole(DEFAULT_ADMIN_ROLE) { _publicSaleSignatureRequired = !_publicSaleSignatureRequired; } function privateSaleActive() public view returns (bool) { return _privateSaleActive(); } function togglePrivateSale() public onlyRole(DEFAULT_ADMIN_ROLE) { require(!_publicSaleActive()); _privateSale = !_privateSale; emit privateSaleToggled(_privateSale); } // Power levels for legendary NFTs will be set after reveal function setPowerLevels( uint8[] calldata powerLevels, uint256[] calldata tokenIds ) external onlyRole(DEFAULT_ADMIN_ROLE) { require(!_powerLevelsSet); require(powerLevels.length == tokenIds.length); for (uint256 i = 0; i < powerLevels.length; i++) { _basePowerLevels[tokenIds[i]] = powerLevels[i]; } } function lockPowerLevels() external onlyRole(DEFAULT_ADMIN_ROLE) { require(!_powerLevelsSet); _powerLevelsSet = true; } /** @dev Mints an NFT for the public sale. Uses a nonce, msgHash and signature to ensure minting is only possible through our website. @param qty Amount to be minted @param mintNonce Nonce value that's incremented after each mint, used to ensure signature + msgHash are unique. Can be retrieved via ._mintNonce(address) before being hashed + signed and passed into function. @param msgHash hashed message, should match the message that's been signed by our keypair on frontend. (['address', 'uint256'], [buyerAddress, mintNonce]) @param signature signed version of msgHash */ function safeMintPublic( uint256 qty, uint256 mintNonce, bytes32 msgHash, bytes calldata signature ) external payable nonReentrant { address to = _msgSender(); require(_publicSaleActive(), "Public sale not active"); require(msg.value >= qty * PUBLIC_PRICE, "Insufficient funds"); require(qty <= PUBLIC_ALLOWANCE, "EXCEED_ALLOWANCE"); require( _tokenIdCounter.current() + qty - _teamMinted <= MAX_MINT, "SOLD_OUT" ); require(mintNonce == _mintNonce[to], "INVALID_NONCE"); require( _verifyMsg(to, mintNonce, msgHash, signature, _signer) || !_publicSaleSignatureRequired, "INVALID_SIG" ); for (uint256 i = 0; i < qty; i++) { _safeMint(to); } _mintNonce[to]++; } /** @dev Mints an NFT for the private sale. Eligibility and allowance for private sale are verified, hashed, and signed to ensure only those eligible can mint. @param qty Amount to be minted @param privateSaleAllowance Total number of NFTs this account can mint in the private sale. @param msgHash hashed message, should match the message that's been signed by our keypair on frontend. (['address', 'uint256'], [buyerAddress, privateSaleAllowance]) @param signature signed version of msgHash */ function safeMintPrivate( uint256 qty, uint256 privateSaleAllowance, bytes32 msgHash, bytes calldata signature ) external payable nonReentrant { address to = _msgSender(); require(_privateSaleActive(), "Private sale not active"); require(msg.value >= qty * PRIVATE_PRICE, "Insufficient funds"); require( qty + _totalMintsPerAddress[to] <= privateSaleAllowance, "Exceeded allowance" ); require( _verifyMsg(to, privateSaleAllowance, msgHash, signature, _signer), "INVALID_SIG" ); require( _tokenIdCounter.current() + qty - _teamMinted <= MAX_MINT, "SOLD_OUT" ); for (uint256 i = 0; i < qty; i++) { _safeMint(to); } _totalMintsPerAddress[to] += qty; } function teamMint(uint256 qty) external onlyRole(DEFAULT_ADMIN_ROLE) { require(_publicSaleActive() || _privateSaleActive()); address to = msg.sender; require(qty + _teamMinted <= TEAM_MINT, "TEAM_MINT_LIMIT_REACHED"); for (uint256 i = 0; i < qty; i++) { _safeMint(to); } _teamMinted += qty; } function isTokenStaked(uint256 tokenId) public view returns (bool) { return _isTokenStaked(tokenId); } function stakeToken(uint256 tokenId) external nonReentrant { _stakeToken(msg.sender, tokenId); } function stakeTokens(uint256[] calldata tokenIds) external nonReentrant { for (uint256 i = 0; i < tokenIds.length; i++) { _stakeToken(msg.sender, tokenIds[i]); } } function getQuantityStaked(address owner) public view returns (uint256) { return _stakedTokens[owner].length; } function getStakedTokens(address owner) public view returns (uint256[] memory) { return _stakedTokens[owner]; } function tokensOfOwner(address owner) public view returns (uint256[] memory) { uint256 totalOwned = balanceOf(owner); uint256[] memory ret = new uint256[](totalOwned); for (uint256 i = 0; i < totalOwned; i++) { ret[i] = ERC721Enumerable.tokenOfOwnerByIndex(owner, i); } return ret; } function setGemRate(uint256 newGemRate) public onlyRole(DEFAULT_ADMIN_ROLE) { _setGemRate(newGemRate); } function _stakeToken(address user, uint256 tokenId) internal { require(_isApprovedOrOwner(user, tokenId), "NOT_AUTHORISED"); require(!_isTokenStaked(tokenId), "ALREADY_STAKED"); _setLastClaim(tokenId); _tokenOwners[tokenId] = user; _stakedTokens[user].push(tokenId); safeTransferFrom(user, address(this), tokenId); } function unstakeToken(uint256 tokenId) external nonReentrant { _unstakeToken(msg.sender, tokenId); } function unstakeTokens(uint256[] calldata tokenIds) external nonReentrant { for (uint256 i = 0; i < tokenIds.length; i++) { _unstakeToken(msg.sender, tokenIds[i]); } } function claimGems(uint256 tokenId) public nonReentrant { require(_isTokenStaked(tokenId), "NOT_STAKED"); require(_tokenOwners[tokenId] == _msgSender(), "NOT_AUTHORISED"); uint256 allocation = _calcAllocation(tokenId); require(allocation > 0, "NO_GEMS"); MAGIC_FOLK_GEMS.mint(_msgSender(), allocation); _setLastClaim(tokenId); } function claimAllGems() external { uint256[] memory stakedTokens = _stakedTokens[_msgSender()]; for (uint256 i = 0; i < stakedTokens.length; i++) { if (_calcAllocation(stakedTokens[i]) > 0) { claimGems(stakedTokens[i]); } } } function getAllocation(uint256 tokenId) public view returns (uint256) { return _calcAllocation(tokenId); } function getTotalUnclaimed(address owner) public view returns (uint256) { uint256 sum = 0; uint256[] memory stakedTokens = _stakedTokens[owner]; for (uint256 i = 0; i < stakedTokens.length; i++) { sum += _calcAllocation(stakedTokens[i]); } return sum; } function _safeMint(address to) internal { uint256 tokenId = _tokenIdCounter.current(); _tokenIdCounter.increment(); _safeMint(to, tokenId); _rollStats(tokenId); } // Was originally going to use Chainlink VRF, but we decided to base // power levels on rarity so they'll be written after reveal. // Defaults to 5, legendary NFTs will have a higher power level. function _rollStats(uint256 tokenId) internal { _setBasePowerLevel(tokenId, 5); } modifier tokenExists(uint256 tokenId) { require(_exists(tokenId), "Token does not exist."); _; } function getStats(uint256 tokenId) public view tokenExists(tokenId) returns (Stats memory) { Stats memory stats = _getStats(tokenId); require( _basePowerLevels[tokenId] > 0, "Token traits have not been initialized." ); return stats; } function getGemRate() public view returns (uint256) { return _getGemRate(); } function getBasePowerLevel(uint256 tokenId) public view tokenExists(tokenId) returns (uint8) { return _getBasePowerLevel(tokenId); } function onERC1155Received( address _operator, address _from, uint256 _id, uint256 _value, bytes calldata _data ) external override returns (bytes4) { require(_operator == _from, "NOT_AUTHORISED"); require( msg.sender == address(MAGIC_FOLK_MAINHAND) || msg.sender == address(MAGIC_FOLK_OFFHAND) || msg.sender == address(MAGIC_FOLK_PET), "INVALID_TOKEN_TYPE" ); (uint256 _nftTokenId, Item memory _item) = decodeOwnerIdAndItem(_data); require( ownerOf(_nftTokenId) == _from || _tokenOwners[_nftTokenId] == _from, "NOT_YOUR_NFT" ); require(_item.itemId == _id, "INVALID_DECODED_ID"); require(_value == 1, "CAN_ONLY_EQUIP_ONE"); require( _item.itemType == MagicFolkItems(msg.sender)._itemType(), "INVALID_ITEMTYPE" ); _equip(_item, _nftTokenId); return ERC1155_RECEIVED_VALUE; } function unequip(address from, bytes calldata data) external { require( msg.sender == address(MAGIC_FOLK_MAINHAND) || msg.sender == address(MAGIC_FOLK_OFFHAND) || msg.sender == address(MAGIC_FOLK_PET), "Invalid caller" ); (uint256 nftTokenId, Item memory item) = decodeOwnerIdAndItem(data); require( ownerOf(nftTokenId) == from || _tokenOwners[nftTokenId] == from, "NOT_YOUR_NFT" ); _unequip(item, nftTokenId); IERC1155(msg.sender).safeTransferFrom( address(this), from, item.itemId, 1, "" ); emit Unequipped(nftTokenId, item.itemId, item.itemType); } function onERC1155BatchReceived( address, address, uint256[] memory, uint256[] memory, bytes calldata ) external pure override returns (bytes4) { revert(); } function withdraw() public onlyRole(DEFAULT_ADMIN_ROLE) { uint256 amount; uint256 balance = address(this).balance; bool success = false; if (!_initialFeesWithdrawn) { if (balance <= _fees) { amount = balance; } else { amount = _fees; } (success, ) = payable(FEE_ADDRESS).call{ value: amount }(""); require(success, "NOPE"); _initialFeesWithdrawn = true; } else { for (uint256 i = 0; i < _payees.length; i++) { (success, ) = payable(_payees[i].wallet).call{ value: (balance * _payees[i].percentagePoints) / 1000 }(""); require(success); } } } function setFees(uint256 newFees) public onlyRole(DEFAULT_ADMIN_ROLE) { _fees = newFees; } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceID) public view virtual override(ERC721, ERC721Enumerable, IERC165, ERC165, AccessControl) returns (bool) { return super.supportsInterface(interfaceID) || interfaceID == type(IERC1155Receiver).interfaceId || interfaceID == 0x01ffc9a7 || // ERC165 interfaceID == 0x4e2312e0; // ERC1155_ACCEPTED ^ ERC1155_BATCH_ACCEPTED;; } function _isTokenStaked(uint256 tokenId) internal view returns (bool) { return ownerOf(tokenId) == address(this); } function _unstakeToken(address user, uint256 tokenId) internal { require(_isTokenStaked(tokenId), "NOT_STAKED"); require(_tokenOwners[tokenId] == user, "NOT_AUTHORISED"); uint256 allocation = _calcAllocation(tokenId); // require(allocation > 0, "CANT_UNSTAKE_YET"); if (allocation > 0) { MAGIC_FOLK_GEMS.mint(_msgSender(), allocation); } uint256 i = 0; uint256 lastTokenIndex = _stakedTokens[user].length - 1; while (_stakedTokens[user][i] != tokenId) { i++; } _stakedTokens[user][i] = _stakedTokens[user][lastTokenIndex]; _stakedTokens[user].pop(); _lastClaims[tokenId] = 0; delete _tokenOwners[tokenId]; _safeTransfer(address(this), user, tokenId, ""); } function _publicSaleActive() internal view returns (bool) { return _publicSale; } function _privateSaleActive() internal view returns (bool) { return _privateSale; } function _equip(Item memory _item, uint256 _nftTokenId) internal { require( !(_isEquipped(_nftTokenId, _item.itemType)), "Slot is not empty" ); Stats memory stats = _getItemStats(_nftTokenId); if (_item.itemType == ItemType.Mainhand) { stats.mainHand = _item; } else if (_item.itemType == ItemType.Offhand) { stats.offHand = _item; } else if (_item.itemType == ItemType.Pet) { stats.pet = _item; } else { revert(); } stats.powerLevel += _item.powerLevel; _setStats(_nftTokenId, stats); emit Equipped(_nftTokenId, _item.itemId, _item.itemType); } function _unequip(Item memory _item, uint256 _nftTokenId) internal { require(_isEquipped(_nftTokenId, _item.itemType), "Slot is empty"); Stats memory stats = _getItemStats(_nftTokenId); if (_item.itemType == ItemType.Mainhand) { require(stats.mainHand.itemId == _item.itemId, "Incorrect item"); stats.mainHand = _emptyItem(); } else if (_item.itemType == ItemType.Offhand) { require(stats.offHand.itemId == _item.itemId, "Incorrect item"); stats.offHand = _emptyItem(); } else if (_item.itemType == ItemType.Pet) { require(stats.pet.itemId == _item.itemId, "Incorrect item"); stats.pet = _emptyItem(); } else { revert(); } stats.powerLevel -= _item.powerLevel; _setStats(_nftTokenId, stats); } function _isEquipped(uint256 nftTokenId, ItemType slot) internal view tokenExists(nftTokenId) returns (bool) { Stats memory stats = _getItemStats(nftTokenId); if (slot == ItemType.Mainhand) { return stats.mainHand.itemType == ItemType.Mainhand; } else if (slot == ItemType.Offhand) { return stats.offHand.itemType == ItemType.Offhand; } else { return stats.pet.itemType == ItemType.Pet; } } function _getItemStats(uint256 tokenId) internal view tokenExists(tokenId) returns (Stats memory) { Stats memory stats = _tokenStats[tokenId]; return stats; } function _getStats(uint256 tokenId) internal view tokenExists(tokenId) returns (Stats memory) { Stats memory stats = _getItemStats(tokenId); stats.powerLevel = stats.powerLevel + _getBasePowerLevel(tokenId); return stats; } function _setStats(uint256 tokenId, Stats memory stats) internal tokenExists(tokenId) { _tokenStats[tokenId] = stats; } function _setBasePowerLevel(uint256 tokenId, uint8 _powerLevel) internal tokenExists(tokenId) { _basePowerLevels[tokenId] = _powerLevel; } function _getBasePowerLevel(uint256 tokenId) internal view tokenExists(tokenId) returns (uint8) { return _basePowerLevels[tokenId]; } function _calcAllocation(uint256 tokenId) internal view returns (uint256) { Stats memory stats = _getStats(tokenId); uint256 timeDeltaDays = (block.timestamp - _getLastClaim(tokenId)) / SECONDS_PER_DAY; return timeDeltaDays * stats.powerLevel * _gemRate; } function _getLastClaim(uint256 tokenId) internal view tokenExists(tokenId) returns (uint256) { return _lastClaims[tokenId]; } function _setLastClaim(uint256 tokenId) internal tokenExists(tokenId) { _lastClaims[tokenId] = block.timestamp; } function _setGemRate(uint256 newGemRate) internal { _gemRate = newGemRate; } function _getGemRate() internal view returns (uint256) { return _gemRate; } function _emptyItem() internal pure returns (Item memory) { return Item(0, 0, ItemType.Empty); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** @notice By default this ERC20 token cannot be transferred between regular accounts. The Magic Council DAO must vote to enable this feature. */ import "../utils/Common.sol"; import "../utils/SigVer.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/interfaces/IERC721.sol"; import "@openzeppelin/contracts/interfaces/IERC1155.sol"; import "@openzeppelin/contracts/governance/IGovernor.sol"; contract MagicFolkGems is ERC20, AccessControl, Ownable, SigVer { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); bytes32 public constant DAO_ROLE = keccak256("DAO_ROLE"); IERC721 MAGIC_FOLK_CONTRACT; IERC1155 MAGIC_FOLK_MAINHAND; IERC1155 MAGIC_FOLK_OFFHAND; IERC1155 MAGIC_FOLK_PET; IGovernor DAO; address public _signer; mapping(address => bool) public _freeGemsClaimed; bool public _transferLock; bool public _devMintLock; bool public _freeGemClaim = true; constructor( address magicFolkContract, address magicFolkMainhand, address magicFolkOffhand, address magicFolkPet ) ERC20("MagicFolkGems", "MFGEM") { _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _grantRole(MINTER_ROLE, magicFolkContract); MAGIC_FOLK_CONTRACT = IERC721(magicFolkContract); _grantRole(BURNER_ROLE, magicFolkMainhand); MAGIC_FOLK_MAINHAND = IERC1155(magicFolkMainhand); _grantRole(BURNER_ROLE, magicFolkOffhand); MAGIC_FOLK_OFFHAND = IERC1155(magicFolkOffhand); _grantRole(BURNER_ROLE, magicFolkPet); MAGIC_FOLK_PET = IERC1155(magicFolkPet); _transferLock = true; } modifier onlyAdminOrDAO() { if ( !(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()) || hasRole(DAO_ROLE, _msgSender())) ) { revert("NOT_AUTHORISED"); } _; } function setMagicFolkAddress(address newAddress) external onlyRole(DEFAULT_ADMIN_ROLE) { _revokeRole(MINTER_ROLE, address(MAGIC_FOLK_CONTRACT)); MAGIC_FOLK_CONTRACT = IERC721(newAddress); _grantRole(MINTER_ROLE, newAddress); } function setMagicFolkItemAddress(address newAddress, ItemType itemType) external onlyRole(DEFAULT_ADMIN_ROLE) { address oldAddress; if (itemType == ItemType.Mainhand) { oldAddress = address(MAGIC_FOLK_MAINHAND); MAGIC_FOLK_MAINHAND = IERC1155(newAddress); } else if (itemType == ItemType.Offhand) { oldAddress = address(MAGIC_FOLK_OFFHAND); MAGIC_FOLK_OFFHAND = IERC1155(newAddress); } else if (itemType == ItemType.Pet) { oldAddress = address(MAGIC_FOLK_PET); MAGIC_FOLK_PET = IERC1155(newAddress); } else { revert(); } _revokeRole(MINTER_ROLE, oldAddress); _revokeRole(BURNER_ROLE, oldAddress); _grantRole(MINTER_ROLE, newAddress); _grantRole(BURNER_ROLE, newAddress); } function setDAO(address _DAO) public onlyRole(DEFAULT_ADMIN_ROLE) { require(address(DAO) == address(0), "DAO_ALREADY_SET"); DAO = IGovernor(_DAO); _grantRole(DAO_ROLE, _DAO); } function claimFreeGems( uint256 qty, bytes32 msgHash, bytes calldata signature ) external { address to = _msgSender(); require(_freeGemClaim, "FREE_GEMZ_DISABLED"); require( _verifyMsg(to, qty, msgHash, signature, _signer), "INVALID_SIG" ); require(!_freeGemsClaimed[to], "GEMZ_ALREADY_CLAIMED"); _mint(to, qty); _freeGemsClaimed[to] = true; } function toggleFreeGems() public onlyRole(DEFAULT_ADMIN_ROLE) { _freeGemClaim = !_freeGemClaim; } function enableTransfers() public onlyRole(DAO_ROLE) { require(_transferLock, "ALREADY_ENABLED"); _transferLock = false; } function disableTransfers() public onlyRole(DAO_ROLE) { require(!_transferLock, "ALREADY_DISABLED"); _transferLock = true; } function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) { _mint(to, amount); } function decimals() public pure override returns (uint8) { return 0; } function transfer(address to, uint256 amount) public override returns (bool) { require(!_transferLock, "TRANSFERS_LOCKED"); return super.transfer(to, amount); } function transferFrom( address from, address to, uint256 amount ) public override returns (bool) { require(!_transferLock, "TRANSFERS_LOCKED"); return super.transferFrom(from, to, amount); } function addBurner(address newBurner) external onlyAdminOrDAO { _grantRole(BURNER_ROLE, newBurner); } function removeBurner(address oldBurner) external onlyAdminOrDAO { _revokeRole(BURNER_ROLE, oldBurner); } function burn(address from, uint256 amount) public onlyRole(BURNER_ROLE) { _burn(from, amount); } function setSignerAddress(address signer) external onlyRole(DEFAULT_ADMIN_ROLE) { _signer = signer; } function lockDevMint() public onlyRole(DEFAULT_ADMIN_ROLE) { require(!_devMintLock, "DEVMINT_LOCKED"); _devMintLock = true; } function devMint(address to, uint256 amount) public onlyRole(DEFAULT_ADMIN_ROLE) { require(!_devMintLock, "DEVMINT_LOCKED"); _mint(to, amount); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol 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); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ 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); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed 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); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** * @dev Handles the receipt of a single ERC1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.0; import "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ 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"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ 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"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ 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); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ 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); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ 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); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol) pragma solidity ^0.8.0; import "../IERC1155Receiver.sol"; import "../../../utils/introspection/ERC165.sol"; /** * @dev _Available since v3.1._ */ abstract contract ERC1155Receiver is ERC165, IERC1155Receiver { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721.sol) pragma solidity ^0.8.0; import "../token/ERC721/IERC721.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155.sol) pragma solidity ^0.8.0; import "../token/ERC1155/IERC1155.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ 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]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ 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); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol) pragma solidity ^0.8.0; import "../IERC721Receiver.sol"; /** * @dev Implementation of the {IERC721Receiver} interface. * * Accepts all token transfers. * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. */ contract ERC721Holder is IERC721Receiver { /** * @dev See {IERC721Receiver-onERC721Received}. * * Always returns `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address, address, uint256, bytes memory ) public virtual override returns (bytes4) { return this.onERC721Received.selector; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (governance/IGovernor.sol) pragma solidity ^0.8.0; import "../utils/introspection/ERC165.sol"; /** * @dev Interface of the {Governor} core. * * _Available since v4.3._ */ abstract contract IGovernor is IERC165 { enum ProposalState { Pending, Active, Canceled, Defeated, Succeeded, Queued, Expired, Executed } /** * @dev Emitted when a proposal is created. */ event ProposalCreated( uint256 proposalId, address proposer, address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, uint256 startBlock, uint256 endBlock, string description ); /** * @dev Emitted when a proposal is canceled. */ event ProposalCanceled(uint256 proposalId); /** * @dev Emitted when a proposal is executed. */ event ProposalExecuted(uint256 proposalId); /** * @dev Emitted when a vote is cast without params. * * Note: `support` values should be seen as buckets. Their interpretation depends on the voting module used. */ event VoteCast(address indexed voter, uint256 proposalId, uint8 support, uint256 weight, string reason); /** * @dev Emitted when a vote is cast with params. * * Note: `support` values should be seen as buckets. Their interpretation depends on the voting module used. * `params` are additional encoded parameters. Their intepepretation also depends on the voting module used. */ event VoteCastWithParams( address indexed voter, uint256 proposalId, uint8 support, uint256 weight, string reason, bytes params ); /** * @notice module:core * @dev Name of the governor instance (used in building the ERC712 domain separator). */ function name() public view virtual returns (string memory); /** * @notice module:core * @dev Version of the governor instance (used in building the ERC712 domain separator). Default: "1" */ function version() public view virtual returns (string memory); /** * @notice module:voting * @dev A description of the possible `support` values for {castVote} and the way these votes are counted, meant to * be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of * key-value pairs that each describe one aspect, for example `support=bravo&quorum=for,abstain`. * * There are 2 standard keys: `support` and `quorum`. * * - `support=bravo` refers to the vote options 0 = Against, 1 = For, 2 = Abstain, as in `GovernorBravo`. * - `quorum=bravo` means that only For votes are counted towards quorum. * - `quorum=for,abstain` means that both For and Abstain votes are counted towards quorum. * * If a counting module makes use of encoded `params`, it should include this under a `params` key with a unique * name that describes the behavior. For example: * * - `params=fractional` might refer to a scheme where votes are divided fractionally between for/against/abstain. * - `params=erc721` might refer to a scheme where specific NFTs are delegated to vote. * * NOTE: The string can be decoded by the standard * https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[`URLSearchParams`] * JavaScript class. */ // solhint-disable-next-line func-name-mixedcase function COUNTING_MODE() public pure virtual returns (string memory); /** * @notice module:core * @dev Hashing function used to (re)build the proposal id from the proposal details.. */ function hashProposal( address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash ) public pure virtual returns (uint256); /** * @notice module:core * @dev Current state of a proposal, following Compound's convention */ function state(uint256 proposalId) public view virtual returns (ProposalState); /** * @notice module:core * @dev Block number used to retrieve user's votes and quorum. As per Compound's Comp and OpenZeppelin's * ERC20Votes, the snapshot is performed at the end of this block. Hence, voting for this proposal starts at the * beginning of the following block. */ function proposalSnapshot(uint256 proposalId) public view virtual returns (uint256); /** * @notice module:core * @dev Block number at which votes close. Votes close at the end of this block, so it is possible to cast a vote * during this block. */ function proposalDeadline(uint256 proposalId) public view virtual returns (uint256); /** * @notice module:user-config * @dev Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to * leave time for users to buy voting power, of delegate it, before the voting of a proposal starts. */ function votingDelay() public view virtual returns (uint256); /** * @notice module:user-config * @dev Delay, in number of blocks, between the vote start and vote ends. * * NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting * duration compared to the voting delay. */ function votingPeriod() public view virtual returns (uint256); /** * @notice module:user-config * @dev Minimum number of cast voted required for a proposal to be successful. * * Note: The `blockNumber` parameter corresponds to the snapshot used for counting vote. This allows to scale the * quorum depending on values such as the totalSupply of a token at this block (see {ERC20Votes}). */ function quorum(uint256 blockNumber) public view virtual returns (uint256); /** * @notice module:reputation * @dev Voting power of an `account` at a specific `blockNumber`. * * Note: this can be implemented in a number of ways, for example by reading the delegated balance from one (or * multiple), {ERC20Votes} tokens. */ function getVotes(address account, uint256 blockNumber) public view virtual returns (uint256); /** * @notice module:reputation * @dev Voting power of an `account` at a specific `blockNumber` given additional encoded parameters. */ function getVotesWithParams( address account, uint256 blockNumber, bytes memory params ) public view virtual returns (uint256); /** * @notice module:voting * @dev Returns weither `account` has cast a vote on `proposalId`. */ function hasVoted(uint256 proposalId, address account) public view virtual returns (bool); /** * @dev Create a new proposal. Vote start {IGovernor-votingDelay} blocks after the proposal is created and ends * {IGovernor-votingPeriod} blocks after the voting starts. * * Emits a {ProposalCreated} event. */ function propose( address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description ) public virtual returns (uint256 proposalId); /** * @dev Execute a successful proposal. This requires the quorum to be reached, the vote to be successful, and the * deadline to be reached. * * Emits a {ProposalExecuted} event. * * Note: some module can modify the requirements for execution, for example by adding an additional timelock. */ function execute( address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash ) public payable virtual returns (uint256 proposalId); /** * @dev Cast a vote * * Emits a {VoteCast} event. */ function castVote(uint256 proposalId, uint8 support) public virtual returns (uint256 balance); /** * @dev Cast a vote with a reason * * Emits a {VoteCast} event. */ function castVoteWithReason( uint256 proposalId, uint8 support, string calldata reason ) public virtual returns (uint256 balance); /** * @dev Cast a vote with a reason and additional encoded parameters * * Emits a {VoteCast} or {VoteCastWithParams} event depending on the length of params. */ function castVoteWithReasonAndParams( uint256 proposalId, uint8 support, string calldata reason, bytes memory params ) public virtual returns (uint256 balance); /** * @dev Cast a vote using the user's cryptographic signature. * * Emits a {VoteCast} event. */ function castVoteBySig( uint256 proposalId, uint8 support, uint8 v, bytes32 r, bytes32 s ) public virtual returns (uint256 balance); /** * @dev Cast a vote with a reason and additional encoded parameters using the user's cryptographic signature. * * Emits a {VoteCast} or {VoteCastWithParams} event depending on the length of params. */ function castVoteWithReasonAndParamsBySig( uint256 proposalId, uint8 support, string calldata reason, bytes memory params, uint8 v, bytes32 r, bytes32 s ) public virtual returns (uint256 balance); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/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"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ 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"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ 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" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ 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); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ 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 { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"enum ItemType","name":"itemType","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","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":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"_collabAllowancePerNFT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"_collabItemsRedeemed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"_collabs","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_itemType","outputs":[{"internalType":"enum ItemType","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"_items","outputs":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint8","name":"powerLevel","type":"uint8"},{"internalType":"enum ItemType","name":"itemType","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"_prices","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes32","name":"msgHash","type":"bytes32"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"buyCollabItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"buyItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"initialSupply","type":"uint256"},{"internalType":"uint8","name":"powerLevel","type":"uint8"},{"internalType":"enum ItemType","name":"itemType","type":"uint8"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"createItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"initialSupply","type":"uint256"},{"internalType":"uint8","name":"powerLevel","type":"uint8"},{"internalType":"enum ItemType","name":"itemType","type":"uint8"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"address","name":"nftContract","type":"address"},{"internalType":"uint256","name":"allowancePerNFT","type":"uint256"}],"name":"createItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"encodedOwnerIdAndItem","type":"bytes"}],"name":"decodeItem","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"components":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint8","name":"powerLevel","type":"uint8"},{"internalType":"enum ItemType","name":"itemType","type":"uint8"}],"internalType":"struct Item","name":"","type":"tuple"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"}],"name":"encodeItem","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint256","name":"magicFolkId","type":"uint256"}],"name":"equip","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"exists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"}],"name":"getItem","outputs":[{"components":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint8","name":"powerLevel","type":"uint8"},{"internalType":"enum ItemType","name":"itemType","type":"uint8"}],"internalType":"struct Item","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"getOwnedItems","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"}],"name":"getStockLeft","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"hashMsg","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"}],"name":"isCollabItem","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"itemCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"mintBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","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":"string","name":"newuri","type":"string"}],"name":"setContractURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint8","name":"powerLevel","type":"uint8"},{"internalType":"enum ItemType","name":"itemType","type":"uint8"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"setItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"magicFolk","type":"address"}],"name":"setMagicFolkContractAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"magicFolkGems","type":"address"}],"name":"setMagicFolkGemsAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"setPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newSigner","type":"address"}],"name":"setSignerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"newuri","type":"string"}],"name":"setURI","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":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint256","name":"magicFolkId","type":"uint256"}],"name":"unequip","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes32","name":"msgHash","type":"bytes32"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"address","name":"_signer","type":"address"}],"name":"verifyMsg","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"msgHash","type":"bytes32"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"address","name":"_signer","type":"address"}],"name":"verifySigner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"}]
Contract Creation Code
60a06040523480156200001157600080fd5b50604051620048ce380380620048ce833981016040819052620000349162000375565b60408051808201909152601a81527f68747470733a2f2f6170692e6d61676963666f6c6b2e636f6d2f0000000000006020820152620000738162000116565b506200007f336200012f565b6005805460ff1916905560016007556200009b60003362000181565b806003811115620000bc57634e487b7160e01b600052602160045260246000fd5b6080816003811115620000df57634e487b7160e01b600052602160045260246000fd5b60f81b905250620000ef62000225565b50600a80546001600160a01b0319166001600160a01b0392909216919091179055620003fc565b80516200012b906002906020840190620002cf565b5050565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008281526004602090815260408083206001600160a01b038516845290915290205460ff166200012b5760008281526004602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620001e13390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6200022f62000282565b6005805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258620002653390565b6040516001600160a01b03909116815260200160405180910390a1565b60055460ff1615620002cd5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640160405180910390fd5b565b828054620002dd90620003bf565b90600052602060002090601f0160209004810192826200030157600085556200034c565b82601f106200031c57805160ff19168380011785556200034c565b828001600101855582156200034c579182015b828111156200034c5782518255916020019190600101906200032f565b506200035a9291506200035e565b5090565b5b808211156200035a57600081556001016200035f565b6000806040838503121562000388578182fd5b82516001600160a01b03811681146200039f578283fd5b602084015190925060048110620003b4578182fd5b809150509250929050565b600181811c90821680620003d457607f821691505b60208210811415620003f657634e487b7160e01b600052602260045260246000fd5b50919050565b60805160f81c6144ac620004226000396000818161072e015261267101526144ac6000f3fe608060405234801561001057600080fd5b506004361061038d5760003560e01c8063704f6066116101de578063c0e727401161010f578063e985e9c5116100ad578063f6b45c461161007c578063f6b45c46146108c0578063f7d97577146108d3578063f8053dec146108e6578063fe776dd0146108f957600080fd5b8063e985e9c51461083f578063f23a6e611461087b578063f242432a1461089a578063f2fde38b146108ad57600080fd5b8063d92b8ada116100e9578063d92b8ada146107fe578063e417dc3514610811578063e757223014610824578063e8a3d4851461083757600080fd5b8063c0e72740146107d0578063c4736030146107d8578063d547741f146107eb57600080fd5b8063938e3d7b1161017c578063a217fddf11610156578063a217fddf1461075d578063a22cb46514610765578063bc197c8114610778578063bd85b039146107b057600080fd5b8063938e3d7b14610703578063970fadbe14610716578063976fb5431461072957600080fd5b80638456cb59116101b85780638456cb59146106c457806386ad5ebc146106cc5780638da5cb5b146106df57806391d14854146106f057600080fd5b8063704f606614610696578063715018a6146106a95780637e63d74c146106b157600080fd5b80632f2ff15d116102c357806344029410116102615780635c915038116102305780635c915038146106225780635c975abb146106635780635f020d8f1461066e5780636bfb0d011461068e57600080fd5b8063440294101461058b5780634e1273f4146105cd5780634f558e79146105ed57806352aade771461060f57600080fd5b806336568abe1161029d57806336568abe146105325780633668ce1a146105455780633686b490146105705780633f4ba83a1461058357600080fd5b80632f2ff15d146104ec5780633129e773146104ff5780633174eced1461051f57600080fd5b80631aa6043e116103305780631ed4733d1161030a5780631ed4733d146104825780631f7fdffa146104a3578063248a9ca3146104b65780632eb2c2d6146104d957600080fd5b80631aa6043e146104495780631b2ef1ca1461045c5780631e81e6561461046f57600080fd5b8063046dc1661161036c578063046dc166146103f05780630e89341c146104035780630f49755d1461042357806312c61be81461043657600080fd5b8062fdd58e1461039257806301ffc9a7146103b857806302fe5305146103db575b600080fd5b6103a56103a0366004613942565b610919565b6040519081526020015b60405180910390f35b6103cb6103c6366004613b76565b6109b2565b60405190151581526020016103af565b6103ee6103e9366004613c07565b610a10565b005b6103ee6103fe3660046136fc565b610a28565b610416610411366004613ae2565b610a56565b6040516103af9190613fdb565b6103cb610431366004613ae2565b610aea565b6103cb61044436600461396d565b610b09565b6103a5610457366004613ae2565b610b22565b6103ee61046a366004613c6c565b610b2e565b6103cb61047d366004613b1e565b610ba3565b610495610490366004613bae565b610bba565b6040516103af929190614202565b6103ee6104b136600461387b565b610c27565b6103a56104c4366004613ae2565b60009081526004602052604090206001015490565b6103ee6104e736600461376c565b610c45565b6103ee6104fa366004613afa565b610c8a565b61051261050d366004613ae2565b610caf565b6040516103af91906141f4565b6103ee61052d366004613c8d565b610d24565b6103ee610540366004613afa565b611118565b6103a5610553366004613942565b601160209081526000928352604080842090915290825290205481565b6103ee61057e3660046136fc565b611192565b6103ee6111c0565b6105be610599366004613ae2565b600d602052600090815260409020805460019091015460ff8082169161010090041683565b6040516103af93929190614216565b6105e06105db366004613a16565b6111d6565b6040516103af9190613f9a565b6103cb6105fb366004613ae2565b600090815260066020526040902054151590565b6103ee61061d366004613cf4565b611337565b61064b610630366004613ae2565b600f602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020016103af565b60055460ff166103cb565b6103a561067c366004613ae2565b60106020526000908152604090205481565b6103a561138c565b6103ee6106a43660046139e2565b61139c565b6103ee611413565b6104166106bf366004613ae2565b611427565b6103ee6114b0565b6103a56106da366004613942565b6114c3565b6003546001600160a01b031661064b565b6103cb6106fe366004613afa565b6114cf565b6103ee610711366004613c07565b6114fa565b6103ee610724366004613cf4565b611518565b6107507f000000000000000000000000000000000000000000000000000000000000000081565b6040516103af9190613fee565b6103a5600081565b6103ee610773366004613911565b61152f565b61079761078636600461376c565b63bc197c8160e01b95945050505050565b6040516001600160e01b031990911681526020016103af565b6103a56107be366004613ae2565b60009081526006602052604090205490565b61041661153a565b6103ee6107e63660046136fc565b6115c8565b6103ee6107f9366004613afa565b6115f6565b6103ee61080c366004613d37565b61161b565b6105e061081f3660046136fc565b6116a6565b6103a5610832366004613ae2565b61175e565b610416611772565b6103cb61084d366004613734565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b610797610889366004613815565b63f23a6e6160e01b95945050505050565b6103ee6108a8366004613815565b611804565b6103ee6108bb3660046136fc565b611849565b6103ee6108ce3660046139e2565b6118bf565b6103ee6108e1366004613c6c565b611b17565b6103ee6108f43660046139e2565b611b35565b6103a5610907366004613ae2565b600e6020526000908152604090205481565b60006001600160a01b0383166109895760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b60648201526084015b60405180910390fd5b506000818152602081815260408083206001600160a01b03861684529091529020545b92915050565b60006109bd82611bfa565b806109d857506001600160e01b03198216630271189760e51b145b806109f357506301ffc9a760e01b6001600160e01b03198316145b806109ac5750506001600160e01b031916630271189760e51b1490565b6000610a1b81611c1f565b610a2482611c29565b5050565b6000610a3381611c1f565b50600a80546001600160a01b0319166001600160a01b0392909216919091179055565b606060028054610a65906142fc565b80601f0160208091040260200160405190810160405280929190818152602001828054610a91906142fc565b8015610ade5780601f10610ab357610100808354040283529160200191610ade565b820191906000526020600020905b815481529060010190602001808311610ac157829003601f168201915b50505050509050919050565b6000818152600f60205260408120546001600160a01b031615156109ac565b6000610b188686868686611c3c565b9695505050505050565b60006109ac3083610919565b610b36611c66565b6000610b4181611c1f565b600b548310610b835760405162461bcd60e51b815260206004820152600e60248201526d1255115357d393d517d1561254d560921b6044820152606401610980565b610b9e30848460405180602001604052806000815250611cac565b505050565b6000610bb0848484611d95565b90505b9392505050565b6040805160608101825260008082526020820181905291810182905260808314610c115760405162461bcd60e51b81526020600482015260086024820152673bb937b733b632b760c11b6044820152606401610980565b610c1b8484611e14565b915091505b9250929050565b6000610c3281611c1f565b610c3e30858585611f1c565b5050505050565b6001600160a01b038516331480610c615750610c61853361084d565b610c7d5760405162461bcd60e51b815260040161098090613ffc565b610c3e8585858585612092565b600082815260046020526040902060010154610ca581611c1f565b610b9e8383612250565b610cd060408051606081018252600080825260208201819052909182015290565b610cd9826122d6565b610d1b5760405162461bcd60e51b8152602060048201526013602482015272125d195b481b9bdd081a5b9a5d185b1a5cd959606a1b6044820152606401610980565b6109ac82612313565b60026007541415610d775760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610980565b60026007556000868152600f602052604090205433906001600160a01b0316610dd45760405162461bcd60e51b815260206004820152600f60248201526e4e4f545f434f4c4c41425f4954454d60881b6044820152606401610980565b6000878152600f6020526040902054610df89082906001600160a01b0316876123b9565b610e355760405162461bcd60e51b815260206004820152600e60248201526d2727aa2faca7aaa92faa27a5a2a760911b6044820152606401610980565b6000878152600e6020526040812054610e4e9088614296565b6009546040516370a0823160e01b81526001600160a01b038581166004830152929350600092909116906370a082319060240160206040518083038186803b158015610e9957600080fd5b505afa158015610ead573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ed19190613c54565b905081811015610f185760405162461bcd60e51b8152602060048201526012602482015271494e53554646494349454e545f46554e445360701b6044820152606401610980565b610f21896122d6565b610f645760405162461bcd60e51b8152602060048201526014602482015273125d195b481b9bdd081a5b9a5d1a585b1a5cd95960621b6044820152606401610980565b600089815260106020908152604080832054600f8352818420546001600160a01b03168452601183528184208b855290925290912054610fa4908a61427e565b1115610ff25760405162461bcd60e51b815260206004820152601860248201527f54585f57494c4c5f4558434545445f414c4c4f57414e434500000000000000006044820152606401610980565b61104183888888888080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050600a546001600160a01b03169150611c3c9050565b61107b5760405162461bcd60e51b815260206004820152600b60248201526a494e56414c49445f53494760a81b6044820152606401610980565b61109730848b8b60405180602001604052806000815250612443565b600954604051632770a7eb60e21b81526001600160a01b0385811660048301526024820185905290911690639dc29fac90604401600060405180830381600087803b1580156110e557600080fd5b505af11580156110f9573d6000803e3d6000fd5b5050505061110889888a612570565b5050600160075550505050505050565b6001600160a01b03811633146111885760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610980565b610a2482826125b6565b600061119d81611c1f565b50600880546001600160a01b0319166001600160a01b0392909216919091179055565b60006111cb81611c1f565b6111d361261d565b50565b6060815183511461123b5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152608401610980565b600083516001600160401b0381111561126457634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561128d578160200160208202803683370190505b50905060005b845181101561132f576112f48582815181106112bf57634e487b7160e01b600052603260045260246000fd5b60200260200101518583815181106112e757634e487b7160e01b600052603260045260246000fd5b6020026020010151610919565b82828151811061131457634e487b7160e01b600052603260045260246000fd5b602090810291909101015261132881614363565b9050611293565b509392505050565b600061134281611c1f565b600061134d600b5490565b905061135b8186868661266f565b61137630828860405180602001604052806000815250611cac565b611384600b80546001019055565b505050505050565b6000611397600b5490565b905090565b6113a4611c66565b6001600160a01b0383163314806113c057506113c0833361084d565b6113dc5760405162461bcd60e51b815260040161098090614093565b60006113e783612313565b905060006113f583836127ca565b600854909150610c3e9086906001600160a01b031686600185612443565b61141b6127f6565b6114256000612850565b565b6000818152600d6020908152604080832081516060818101845282548252600183015460ff8082169684019690965290956109ac959094929392840191610100900416600381111561148957634e487b7160e01b600052602160045260246000fd5b60038111156114a857634e487b7160e01b600052602160045260246000fd5b9052506127ca565b60006114bb81611c1f565b6111d36128a2565b6000610bb383836128df565b60009182526004602090815260408084206001600160a01b0393909316845291905290205460ff1690565b600061150581611c1f565b8151610b9e90600c90602085019061350f565b600061152381611c1f565b610c3e8585858561266f565b610a24338383612926565b600c8054611547906142fc565b80601f0160208091040260200160405190810160405280929190818152602001828054611573906142fc565b80156115c05780601f10611595576101008083540402835291602001916115c0565b820191906000526020600020905b8154815290600101906020018083116115a357829003601f168201915b505050505081565b60006115d381611c1f565b50600980546001600160a01b0319166001600160a01b0392909216919091179055565b60008281526004602052604090206001015461161181611c1f565b610b9e83836125b6565b600061162681611c1f565b6000611631600b5490565b6000818152600f6020908152604080832080546001600160a01b0319166001600160a01b038a161790556010909152902084905590506116738188888861266f565b61168e30828a60405180602001604052806000815250611cac565b61169c600b80546001019055565b5050505050505050565b606060006116b3600b5490565b6001600160401b038111156116d857634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611701578160200160208202803683370190505b50905060005b81518110156117575761171a8482610919565b82828151811061173a57634e487b7160e01b600052603260045260246000fd5b60209081029190910101528061174f81614363565b915050611707565b5092915050565b6000818152600e60205260408120546109ac565b6060600c8054611781906142fc565b80601f01602080910402602001604051908101604052809291908181526020018280546117ad906142fc565b80156117fa5780601f106117cf576101008083540402835291602001916117fa565b820191906000526020600020905b8154815290600101906020018083116117dd57829003601f168201915b5050505050905090565b6001600160a01b0385163314806118205750611820853361084d565b61183c5760405162461bcd60e51b815260040161098090613ffc565b610c3e8585858585612443565b6118516127f6565b6001600160a01b0381166118b65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610980565b6111d381612850565b600260075414156119125760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610980565b60026007556000828152600f60205260409020546001600160a01b03161561196a5760405162461bcd60e51b815260206004820152600b60248201526a434f4c4c41425f4954454d60a81b6044820152606401610980565b6000828152600e60205260408120546119839083614296565b6009546040516370a0823160e01b81526001600160a01b038781166004830152929350600092909116906370a082319060240160206040518083038186803b1580156119ce57600080fd5b505afa1580156119e2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a069190613c54565b905081811015611a4d5760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742066756e647360701b6044820152606401610980565b611a56846122d6565b611a995760405162461bcd60e51b8152602060048201526014602482015273125d195b481b9bdd081a5b9a5d1a585b1a5cd95960621b6044820152606401610980565b611ab53086868660405180602001604052806000815250612443565b600954604051632770a7eb60e21b81526001600160a01b0387811660048301526024820185905290911690639dc29fac90604401600060405180830381600087803b158015611b0357600080fd5b505af1158015611108573d6000803e3d6000fd5b6000611b2281611c1f565b506000918252600e602052604090912055565b611b3d611c66565b6001600160a01b038316331480611b595750611b59833361084d565b611b755760405162461bcd60e51b815260040161098090614093565b6000611b8083612313565b90506000611b8e83836127ca565b600854604051630f1740d160e01b81529192506001600160a01b031690630f1740d190611bc19088908590600401613f76565b600060405180830381600087803b158015611bdb57600080fd5b505af1158015611bef573d6000803e3d6000fd5b505050505050505050565b60006001600160e01b03198216637965db0b60e01b14806109ac57506109ac82612a07565b6111d38133612a47565b8051610a2490600290602084019061350f565b6000611c49848484611d95565b8015610b18575083611c5b87876128df565b149695505050505050565b60055460ff16156114255760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610980565b6001600160a01b038416611cd25760405162461bcd60e51b8152600401610980906141b3565b336000611cde85612aab565b90506000611ceb85612aab565b9050611cfc83600089858589612b04565b6000868152602081815260408083206001600160a01b038b16845290915281208054879290611d2c90849061427e565b909155505060408051878152602081018790526001600160a01b03808a1692600092918716917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4611d8c83600089898989612b1a565b50505050505050565b6000816001600160a01b0316611e0284611dfc876040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b90612c85565b6001600160a01b031614949350505050565b604080516060810182526000808252602082018190529181018290526000611e3f6020828688614256565b810190611e4c9190613ae2565b9050611e6f60408051606081018252600080825260208201819052909182015290565b611e7d604060208789614256565b810190611e8a9190613ae2565b8152611e9a606060408789614256565b810190611ea79190613d99565b60ff166020820152611ebc8560608189614256565b810190611ec99190613bed565b81604001906003811115611eed57634e487b7160e01b600052602160045260246000fd5b90816003811115611f0e57634e487b7160e01b600052602160045260246000fd5b905250909590945092505050565b6001600160a01b038416611f425760405162461bcd60e51b8152600401610980906141b3565b8151835114611f635760405162461bcd60e51b81526004016109809061416b565b33611f7381600087878787612b04565b60005b845181101561202a57838181518110611f9f57634e487b7160e01b600052603260045260246000fd5b6020026020010151600080878481518110611fca57634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b031681526020019081526020016000206000828254612012919061427e565b9091555081905061202281614363565b915050611f76565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb878760405161207b929190613fad565b60405180910390a4610c3e81600087878787612ca1565b81518351146120b35760405162461bcd60e51b81526004016109809061416b565b6001600160a01b0384166120d95760405162461bcd60e51b8152600401610980906140dc565b336120e8818787878787612b04565b60005b84518110156121ea57600085828151811061211657634e487b7160e01b600052603260045260246000fd5b60200260200101519050600085838151811061214257634e487b7160e01b600052603260045260246000fd5b602090810291909101810151600084815280835260408082206001600160a01b038e1683529093529190912054909150818110156121925760405162461bcd60e51b815260040161098090614121565b6000838152602081815260408083206001600160a01b038e8116855292528083208585039055908b168252812080548492906121cf90849061427e565b92505081905550505050806121e390614363565b90506120eb565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb878760405161223a929190613fad565b60405180910390a4611384818787878787612ca1565b61225a82826114cf565b610a245760008281526004602090815260408083206001600160a01b03851684529091529020805460ff191660011790556122923390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000806122e283612313565b905060008160400151600381111561230a57634e487b7160e01b600052602160045260246000fd5b14159392505050565b61233460408051606081018252600080825260208201819052909182015290565b6000828152600d6020908152604091829020825160608101845281548152600182015460ff80821694830194909452909391929184019161010090910416600381111561239157634e487b7160e01b600052602160045260246000fd5b60038111156123b057634e487b7160e01b600052602160045260246000fd5b90525092915050565b6000836001600160a01b0316836001600160a01b0316636352211e846040518263ffffffff1660e01b81526004016123f391815260200190565b60206040518083038186803b15801561240b57600080fd5b505afa15801561241f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e029190613718565b6001600160a01b0384166124695760405162461bcd60e51b8152600401610980906140dc565b33600061247585612aab565b9050600061248285612aab565b9050612492838989858589612b04565b6000868152602081815260408083206001600160a01b038c168452909152902054858110156124d35760405162461bcd60e51b815260040161098090614121565b6000878152602081815260408083206001600160a01b038d8116855292528083208985039055908a1682528120805488929061251090849061427e565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4611bef848a8a8a8a8a612b1a565b6000838152600f60209081526040808320546001600160a01b0316835260118252808320858452909152812080548392906125ac90849061427e565b9091555050505050565b6125c082826114cf565b15610a245760008281526004602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b612625612d6b565b6005805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b7f000000000000000000000000000000000000000000000000000000000000000060038111156126af57634e487b7160e01b600052602160045260246000fd5b8260038111156126cf57634e487b7160e01b600052602160045260246000fd5b146126d957600080fd5b6126fa60408051606081018252600080825260208201819052909182015290565b84815260ff841660208201526040810183600381111561272a57634e487b7160e01b600052602160045260246000fd5b9081600381111561274b57634e487b7160e01b600052602160045260246000fd5b9052506000858152600d6020908152604091829020835181559083015160018201805460ff90921660ff19831681178255938501518594909261ffff1916176101008360038111156127ad57634e487b7160e01b600052602160045260246000fd5b021790555050506000858152600e60205260409020829055610c3e565b606082826040516020016127df929190614202565b604051602081830303815290604052905092915050565b6003546001600160a01b031633146114255760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610980565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6128aa611c66565b6005805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586126523390565b6040516bffffffffffffffffffffffff19606084901b1660208201526034810182905260009060540160405160208183030381529060405280519060200120905092915050565b816001600160a01b0316836001600160a01b0316141561299a5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b6064820152608401610980565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b60006001600160e01b03198216636cdb3d1360e11b1480612a3857506001600160e01b031982166303a24d0760e21b145b806109ac57506109ac82612db4565b612a5182826114cf565b610a2457612a69816001600160a01b03166014612de9565b612a74836020612de9565b604051602001612a85929190613e5e565b60408051601f198184030181529082905262461bcd60e51b825261098091600401613fdb565b60408051600180825281830190925260609160009190602080830190803683370190505090508281600081518110612af357634e487b7160e01b600052603260045260246000fd5b602090810291909101015292915050565b612b0c611c66565b611384868686868686612fca565b6001600160a01b0384163b156113845760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e6190612b5e9089908990889088908890600401613f31565b602060405180830381600087803b158015612b7857600080fd5b505af1925050508015612ba8575060408051601f3d908101601f19168201909252612ba591810190613b92565b60015b612c5557612bb46143aa565b806308c379a01415612bee5750612bc96143c2565b80612bd45750612bf0565b8060405162461bcd60e51b81526004016109809190613fdb565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e20455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b6064820152608401610980565b6001600160e01b0319811663f23a6e6160e01b14611d8c5760405162461bcd60e51b81526004016109809061404b565b6000806000612c94858561317b565b9150915061132f816131e8565b6001600160a01b0384163b156113845760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190612ce59089908990889088908890600401613ed3565b602060405180830381600087803b158015612cff57600080fd5b505af1925050508015612d2f575060408051601f3d908101601f19168201909252612d2c91810190613b92565b60015b612d3b57612bb46143aa565b6001600160e01b0319811663bc197c8160e01b14611d8c5760405162461bcd60e51b81526004016109809061404b565b60055460ff166114255760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610980565b60006001600160e01b03198216630271189760e51b14806109ac57506301ffc9a760e01b6001600160e01b03198316146109ac565b60606000612df8836002614296565b612e0390600261427e565b6001600160401b03811115612e2857634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612e52576020820181803683370190505b509050600360fc1b81600081518110612e7b57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612eb857634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000612edc846002614296565b612ee790600161427e565b90505b6001811115612f7b576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612f2957634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110612f4d57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93612f74816142e5565b9050612eea565b508315610bb35760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610980565b6001600160a01b03851661306d5760005b835181101561306b5782818151811061300457634e487b7160e01b600052603260045260246000fd5b60200260200101516006600086848151811061303057634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000206000828254613055919061427e565b90915550613064905081614363565b9050612fdb565b505b6001600160a01b0384166113845760005b8351811015611d8c5760008482815181106130a957634e487b7160e01b600052603260045260246000fd5b6020026020010151905060008483815181106130d557634e487b7160e01b600052603260045260246000fd5b60200260200101519050600060066000848152602001908152602001600020549050818110156131585760405162461bcd60e51b815260206004820152602860248201527f455243313135353a206275726e20616d6f756e74206578636565647320746f74604482015267616c537570706c7960c01b6064820152608401610980565b6000928352600660205260409092209103905561317481614363565b905061307e565b6000808251604114156131b25760208301516040840151606085015160001a6131a6878285856133e9565b94509450505050610c20565b8251604014156131dc57602083015160408401516131d18683836134d6565b935093505050610c20565b50600090506002610c20565b600081600481111561320a57634e487b7160e01b600052602160045260246000fd5b14156132135750565b600181600481111561323557634e487b7160e01b600052602160045260246000fd5b14156132835760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610980565b60028160048111156132a557634e487b7160e01b600052602160045260246000fd5b14156132f35760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610980565b600381600481111561331557634e487b7160e01b600052602160045260246000fd5b141561336e5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610980565b600481600481111561339057634e487b7160e01b600052602160045260246000fd5b14156111d35760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610980565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561342057506000905060036134cd565b8460ff16601b1415801561343857508460ff16601c14155b1561344957506000905060046134cd565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561349d573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166134c6576000600192509250506134cd565b9150600090505b94509492505050565b6000806001600160ff1b038316816134f360ff86901c601b61427e565b9050613501878288856133e9565b935093505050935093915050565b82805461351b906142fc565b90600052602060002090601f01602090048101928261353d5760008555613583565b82601f1061355657805160ff1916838001178555613583565b82800160010185558215613583579182015b82811115613583578251825591602001919060010190613568565b5061358f929150613593565b5090565b5b8082111561358f5760008155600101613594565b60006001600160401b038311156135c1576135c1614394565b6040516135d8601f8501601f191660200182614337565b8091508381528484840111156135ed57600080fd5b83836020830137600060208583010152509392505050565b600082601f830112613615578081fd5b8135602061362282614233565b60405161362f8282614337565b8381528281019150858301600585901b8701840188101561364e578586fd5b855b8581101561366c57813584529284019290840190600101613650565b5090979650505050505050565b60008083601f84011261368a578182fd5b5081356001600160401b038111156136a0578182fd5b602083019150836020828501011115610c2057600080fd5b600082601f8301126136c8578081fd5b610bb3838335602085016135a8565b8035600481106136e657600080fd5b919050565b803560ff811681146136e657600080fd5b60006020828403121561370d578081fd5b8135610bb38161444b565b600060208284031215613729578081fd5b8151610bb38161444b565b60008060408385031215613746578081fd5b82356137518161444b565b915060208301356137618161444b565b809150509250929050565b600080600080600060a08688031215613783578081fd5b853561378e8161444b565b9450602086013561379e8161444b565b935060408601356001600160401b03808211156137b9578283fd5b6137c589838a01613605565b945060608801359150808211156137da578283fd5b6137e689838a01613605565b935060808801359150808211156137fb578283fd5b50613808888289016136b8565b9150509295509295909350565b600080600080600060a0868803121561382c578081fd5b85356138378161444b565b945060208601356138478161444b565b9350604086013592506060860135915060808601356001600160401b0381111561386f578182fd5b613808888289016136b8565b60008060008060808587031215613890578182fd5b843561389b8161444b565b935060208501356001600160401b03808211156138b6578384fd5b6138c288838901613605565b945060408701359150808211156138d7578384fd5b6138e388838901613605565b935060608701359150808211156138f8578283fd5b50613905878288016136b8565b91505092959194509250565b60008060408385031215613923578182fd5b823561392e8161444b565b915060208301358015158114613761578182fd5b60008060408385031215613954578182fd5b823561395f8161444b565b946020939093013593505050565b600080600080600060a08688031215613984578283fd5b853561398f8161444b565b9450602086013593506040860135925060608601356001600160401b038111156139b7578182fd5b6139c3888289016136b8565b92505060808601356139d48161444b565b809150509295509295909350565b6000806000606084860312156139f6578081fd5b8335613a018161444b565b95602085013595506040909401359392505050565b60008060408385031215613a28578182fd5b82356001600160401b0380821115613a3e578384fd5b818501915085601f830112613a51578384fd5b81356020613a5e82614233565b604051613a6b8282614337565b8381528281019150858301600585901b870184018b1015613a8a578889fd5b8896505b84871015613ab5578035613aa18161444b565b835260019690960195918301918301613a8e565b5096505086013592505080821115613acb578283fd5b50613ad885828601613605565b9150509250929050565b600060208284031215613af3578081fd5b5035919050565b60008060408385031215613b0c578182fd5b8235915060208301356137618161444b565b600080600060608486031215613b32578081fd5b8335925060208401356001600160401b03811115613b4e578182fd5b613b5a868287016136b8565b9250506040840135613b6b8161444b565b809150509250925092565b600060208284031215613b87578081fd5b8135610bb381614460565b600060208284031215613ba3578081fd5b8151610bb381614460565b60008060208385031215613bc0578182fd5b82356001600160401b03811115613bd5578283fd5b613be185828601613679565b90969095509350505050565b600060208284031215613bfe578081fd5b610bb3826136d7565b600060208284031215613c18578081fd5b81356001600160401b03811115613c2d578182fd5b8201601f81018413613c3d578182fd5b613c4c848235602084016135a8565b949350505050565b600060208284031215613c65578081fd5b5051919050565b60008060408385031215613c7e578182fd5b50508035926020909101359150565b60008060008060008060a08789031215613ca5578384fd5b8635955060208701359450604087013593506060870135925060808701356001600160401b03811115613cd6578182fd5b613ce289828a01613679565b979a9699509497509295939492505050565b60008060008060808587031215613d09578182fd5b84359350613d19602086016136eb565b9250613d27604086016136d7565b9396929550929360600135925050565b60008060008060008060c08789031215613d4f578384fd5b86359550613d5f602088016136eb565b9450613d6d604088016136d7565b9350606087013592506080870135613d848161444b565b8092505060a087013590509295509295509295565b600060208284031215613daa578081fd5b610bb3826136eb565b6000815180845260208085019450808401835b83811015613de257815187529582019590820190600101613dc6565b509495945050505050565b60008151808452613e058160208601602086016142b5565b601f01601f19169290920160200192915050565b60048110613e3757634e487b7160e01b600052602160045260246000fd5b9052565b8051825260ff60208201511660208301526040810151610b9e6040840182613e19565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613e968160178501602088016142b5565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613ec78160288401602088016142b5565b01602801949350505050565b6001600160a01b0386811682528516602082015260a060408201819052600090613eff90830186613db3565b8281036060840152613f118186613db3565b90508281036080840152613f258185613ded565b98975050505050505050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090613f6b90830184613ded565b979650505050505050565b6001600160a01b0383168152604060208201819052600090610bb090830184613ded565b602081526000610bb36020830184613db3565b604081526000613fc06040830185613db3565b8281036020840152613fd28185613db3565b95945050505050565b602081526000610bb36020830184613ded565b602081016109ac8284613e19565b6020808252602f908201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60408201526e195c881b9bdc88185c1c1c9bdd9959608a1b606082015260800190565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b60208082526029908201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260408201526808185c1c1c9bdd995960ba1b606082015260800190565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b60208082526021908201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736040820152607360f81b606082015260800190565b606081016109ac8284613e3b565b82815260808101610bb36020830184613e3b565b83815260ff8316602082015260608101613c4c6040830184613e19565b60006001600160401b0382111561424c5761424c614394565b5060051b60200190565b60008085851115614265578182fd5b83861115614271578182fd5b5050820193919092039150565b600082198211156142915761429161437e565b500190565b60008160001904831182151516156142b0576142b061437e565b500290565b60005b838110156142d05781810151838201526020016142b8565b838111156142df576000848401525b50505050565b6000816142f4576142f461437e565b506000190190565b600181811c9082168061431057607f821691505b6020821081141561433157634e487b7160e01b600052602260045260246000fd5b50919050565b601f8201601f191681016001600160401b038111828210171561435c5761435c614394565b6040525050565b60006000198214156143775761437761437e565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b600060033d11156143bf57600481823e5160e01c5b90565b600060443d10156143d05790565b6040516003193d81016004833e81513d6001600160401b0381602484011181841117156143ff57505050505090565b82850191508151818111156144175750505050505090565b843d87010160208285010111156144315750505050505090565b61444060208286010187614337565b509095945050505050565b6001600160a01b03811681146111d357600080fd5b6001600160e01b0319811681146111d357600080fdfea26469706673582212208f2e4b08630bc1d1476e685eacf51376762250a5f5ba5093b9157544c638a52164736f6c63430008040033000000000000000000000000c80f2f0598db841f48afa998fb70122e37361f4a0000000000000000000000000000000000000000000000000000000000000001
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061038d5760003560e01c8063704f6066116101de578063c0e727401161010f578063e985e9c5116100ad578063f6b45c461161007c578063f6b45c46146108c0578063f7d97577146108d3578063f8053dec146108e6578063fe776dd0146108f957600080fd5b8063e985e9c51461083f578063f23a6e611461087b578063f242432a1461089a578063f2fde38b146108ad57600080fd5b8063d92b8ada116100e9578063d92b8ada146107fe578063e417dc3514610811578063e757223014610824578063e8a3d4851461083757600080fd5b8063c0e72740146107d0578063c4736030146107d8578063d547741f146107eb57600080fd5b8063938e3d7b1161017c578063a217fddf11610156578063a217fddf1461075d578063a22cb46514610765578063bc197c8114610778578063bd85b039146107b057600080fd5b8063938e3d7b14610703578063970fadbe14610716578063976fb5431461072957600080fd5b80638456cb59116101b85780638456cb59146106c457806386ad5ebc146106cc5780638da5cb5b146106df57806391d14854146106f057600080fd5b8063704f606614610696578063715018a6146106a95780637e63d74c146106b157600080fd5b80632f2ff15d116102c357806344029410116102615780635c915038116102305780635c915038146106225780635c975abb146106635780635f020d8f1461066e5780636bfb0d011461068e57600080fd5b8063440294101461058b5780634e1273f4146105cd5780634f558e79146105ed57806352aade771461060f57600080fd5b806336568abe1161029d57806336568abe146105325780633668ce1a146105455780633686b490146105705780633f4ba83a1461058357600080fd5b80632f2ff15d146104ec5780633129e773146104ff5780633174eced1461051f57600080fd5b80631aa6043e116103305780631ed4733d1161030a5780631ed4733d146104825780631f7fdffa146104a3578063248a9ca3146104b65780632eb2c2d6146104d957600080fd5b80631aa6043e146104495780631b2ef1ca1461045c5780631e81e6561461046f57600080fd5b8063046dc1661161036c578063046dc166146103f05780630e89341c146104035780630f49755d1461042357806312c61be81461043657600080fd5b8062fdd58e1461039257806301ffc9a7146103b857806302fe5305146103db575b600080fd5b6103a56103a0366004613942565b610919565b6040519081526020015b60405180910390f35b6103cb6103c6366004613b76565b6109b2565b60405190151581526020016103af565b6103ee6103e9366004613c07565b610a10565b005b6103ee6103fe3660046136fc565b610a28565b610416610411366004613ae2565b610a56565b6040516103af9190613fdb565b6103cb610431366004613ae2565b610aea565b6103cb61044436600461396d565b610b09565b6103a5610457366004613ae2565b610b22565b6103ee61046a366004613c6c565b610b2e565b6103cb61047d366004613b1e565b610ba3565b610495610490366004613bae565b610bba565b6040516103af929190614202565b6103ee6104b136600461387b565b610c27565b6103a56104c4366004613ae2565b60009081526004602052604090206001015490565b6103ee6104e736600461376c565b610c45565b6103ee6104fa366004613afa565b610c8a565b61051261050d366004613ae2565b610caf565b6040516103af91906141f4565b6103ee61052d366004613c8d565b610d24565b6103ee610540366004613afa565b611118565b6103a5610553366004613942565b601160209081526000928352604080842090915290825290205481565b6103ee61057e3660046136fc565b611192565b6103ee6111c0565b6105be610599366004613ae2565b600d602052600090815260409020805460019091015460ff8082169161010090041683565b6040516103af93929190614216565b6105e06105db366004613a16565b6111d6565b6040516103af9190613f9a565b6103cb6105fb366004613ae2565b600090815260066020526040902054151590565b6103ee61061d366004613cf4565b611337565b61064b610630366004613ae2565b600f602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020016103af565b60055460ff166103cb565b6103a561067c366004613ae2565b60106020526000908152604090205481565b6103a561138c565b6103ee6106a43660046139e2565b61139c565b6103ee611413565b6104166106bf366004613ae2565b611427565b6103ee6114b0565b6103a56106da366004613942565b6114c3565b6003546001600160a01b031661064b565b6103cb6106fe366004613afa565b6114cf565b6103ee610711366004613c07565b6114fa565b6103ee610724366004613cf4565b611518565b6107507f000000000000000000000000000000000000000000000000000000000000000181565b6040516103af9190613fee565b6103a5600081565b6103ee610773366004613911565b61152f565b61079761078636600461376c565b63bc197c8160e01b95945050505050565b6040516001600160e01b031990911681526020016103af565b6103a56107be366004613ae2565b60009081526006602052604090205490565b61041661153a565b6103ee6107e63660046136fc565b6115c8565b6103ee6107f9366004613afa565b6115f6565b6103ee61080c366004613d37565b61161b565b6105e061081f3660046136fc565b6116a6565b6103a5610832366004613ae2565b61175e565b610416611772565b6103cb61084d366004613734565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b610797610889366004613815565b63f23a6e6160e01b95945050505050565b6103ee6108a8366004613815565b611804565b6103ee6108bb3660046136fc565b611849565b6103ee6108ce3660046139e2565b6118bf565b6103ee6108e1366004613c6c565b611b17565b6103ee6108f43660046139e2565b611b35565b6103a5610907366004613ae2565b600e6020526000908152604090205481565b60006001600160a01b0383166109895760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b60648201526084015b60405180910390fd5b506000818152602081815260408083206001600160a01b03861684529091529020545b92915050565b60006109bd82611bfa565b806109d857506001600160e01b03198216630271189760e51b145b806109f357506301ffc9a760e01b6001600160e01b03198316145b806109ac5750506001600160e01b031916630271189760e51b1490565b6000610a1b81611c1f565b610a2482611c29565b5050565b6000610a3381611c1f565b50600a80546001600160a01b0319166001600160a01b0392909216919091179055565b606060028054610a65906142fc565b80601f0160208091040260200160405190810160405280929190818152602001828054610a91906142fc565b8015610ade5780601f10610ab357610100808354040283529160200191610ade565b820191906000526020600020905b815481529060010190602001808311610ac157829003601f168201915b50505050509050919050565b6000818152600f60205260408120546001600160a01b031615156109ac565b6000610b188686868686611c3c565b9695505050505050565b60006109ac3083610919565b610b36611c66565b6000610b4181611c1f565b600b548310610b835760405162461bcd60e51b815260206004820152600e60248201526d1255115357d393d517d1561254d560921b6044820152606401610980565b610b9e30848460405180602001604052806000815250611cac565b505050565b6000610bb0848484611d95565b90505b9392505050565b6040805160608101825260008082526020820181905291810182905260808314610c115760405162461bcd60e51b81526020600482015260086024820152673bb937b733b632b760c11b6044820152606401610980565b610c1b8484611e14565b915091505b9250929050565b6000610c3281611c1f565b610c3e30858585611f1c565b5050505050565b6001600160a01b038516331480610c615750610c61853361084d565b610c7d5760405162461bcd60e51b815260040161098090613ffc565b610c3e8585858585612092565b600082815260046020526040902060010154610ca581611c1f565b610b9e8383612250565b610cd060408051606081018252600080825260208201819052909182015290565b610cd9826122d6565b610d1b5760405162461bcd60e51b8152602060048201526013602482015272125d195b481b9bdd081a5b9a5d185b1a5cd959606a1b6044820152606401610980565b6109ac82612313565b60026007541415610d775760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610980565b60026007556000868152600f602052604090205433906001600160a01b0316610dd45760405162461bcd60e51b815260206004820152600f60248201526e4e4f545f434f4c4c41425f4954454d60881b6044820152606401610980565b6000878152600f6020526040902054610df89082906001600160a01b0316876123b9565b610e355760405162461bcd60e51b815260206004820152600e60248201526d2727aa2faca7aaa92faa27a5a2a760911b6044820152606401610980565b6000878152600e6020526040812054610e4e9088614296565b6009546040516370a0823160e01b81526001600160a01b038581166004830152929350600092909116906370a082319060240160206040518083038186803b158015610e9957600080fd5b505afa158015610ead573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ed19190613c54565b905081811015610f185760405162461bcd60e51b8152602060048201526012602482015271494e53554646494349454e545f46554e445360701b6044820152606401610980565b610f21896122d6565b610f645760405162461bcd60e51b8152602060048201526014602482015273125d195b481b9bdd081a5b9a5d1a585b1a5cd95960621b6044820152606401610980565b600089815260106020908152604080832054600f8352818420546001600160a01b03168452601183528184208b855290925290912054610fa4908a61427e565b1115610ff25760405162461bcd60e51b815260206004820152601860248201527f54585f57494c4c5f4558434545445f414c4c4f57414e434500000000000000006044820152606401610980565b61104183888888888080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050600a546001600160a01b03169150611c3c9050565b61107b5760405162461bcd60e51b815260206004820152600b60248201526a494e56414c49445f53494760a81b6044820152606401610980565b61109730848b8b60405180602001604052806000815250612443565b600954604051632770a7eb60e21b81526001600160a01b0385811660048301526024820185905290911690639dc29fac90604401600060405180830381600087803b1580156110e557600080fd5b505af11580156110f9573d6000803e3d6000fd5b5050505061110889888a612570565b5050600160075550505050505050565b6001600160a01b03811633146111885760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610980565b610a2482826125b6565b600061119d81611c1f565b50600880546001600160a01b0319166001600160a01b0392909216919091179055565b60006111cb81611c1f565b6111d361261d565b50565b6060815183511461123b5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152608401610980565b600083516001600160401b0381111561126457634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561128d578160200160208202803683370190505b50905060005b845181101561132f576112f48582815181106112bf57634e487b7160e01b600052603260045260246000fd5b60200260200101518583815181106112e757634e487b7160e01b600052603260045260246000fd5b6020026020010151610919565b82828151811061131457634e487b7160e01b600052603260045260246000fd5b602090810291909101015261132881614363565b9050611293565b509392505050565b600061134281611c1f565b600061134d600b5490565b905061135b8186868661266f565b61137630828860405180602001604052806000815250611cac565b611384600b80546001019055565b505050505050565b6000611397600b5490565b905090565b6113a4611c66565b6001600160a01b0383163314806113c057506113c0833361084d565b6113dc5760405162461bcd60e51b815260040161098090614093565b60006113e783612313565b905060006113f583836127ca565b600854909150610c3e9086906001600160a01b031686600185612443565b61141b6127f6565b6114256000612850565b565b6000818152600d6020908152604080832081516060818101845282548252600183015460ff8082169684019690965290956109ac959094929392840191610100900416600381111561148957634e487b7160e01b600052602160045260246000fd5b60038111156114a857634e487b7160e01b600052602160045260246000fd5b9052506127ca565b60006114bb81611c1f565b6111d36128a2565b6000610bb383836128df565b60009182526004602090815260408084206001600160a01b0393909316845291905290205460ff1690565b600061150581611c1f565b8151610b9e90600c90602085019061350f565b600061152381611c1f565b610c3e8585858561266f565b610a24338383612926565b600c8054611547906142fc565b80601f0160208091040260200160405190810160405280929190818152602001828054611573906142fc565b80156115c05780601f10611595576101008083540402835291602001916115c0565b820191906000526020600020905b8154815290600101906020018083116115a357829003601f168201915b505050505081565b60006115d381611c1f565b50600980546001600160a01b0319166001600160a01b0392909216919091179055565b60008281526004602052604090206001015461161181611c1f565b610b9e83836125b6565b600061162681611c1f565b6000611631600b5490565b6000818152600f6020908152604080832080546001600160a01b0319166001600160a01b038a161790556010909152902084905590506116738188888861266f565b61168e30828a60405180602001604052806000815250611cac565b61169c600b80546001019055565b5050505050505050565b606060006116b3600b5490565b6001600160401b038111156116d857634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611701578160200160208202803683370190505b50905060005b81518110156117575761171a8482610919565b82828151811061173a57634e487b7160e01b600052603260045260246000fd5b60209081029190910101528061174f81614363565b915050611707565b5092915050565b6000818152600e60205260408120546109ac565b6060600c8054611781906142fc565b80601f01602080910402602001604051908101604052809291908181526020018280546117ad906142fc565b80156117fa5780601f106117cf576101008083540402835291602001916117fa565b820191906000526020600020905b8154815290600101906020018083116117dd57829003601f168201915b5050505050905090565b6001600160a01b0385163314806118205750611820853361084d565b61183c5760405162461bcd60e51b815260040161098090613ffc565b610c3e8585858585612443565b6118516127f6565b6001600160a01b0381166118b65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610980565b6111d381612850565b600260075414156119125760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610980565b60026007556000828152600f60205260409020546001600160a01b03161561196a5760405162461bcd60e51b815260206004820152600b60248201526a434f4c4c41425f4954454d60a81b6044820152606401610980565b6000828152600e60205260408120546119839083614296565b6009546040516370a0823160e01b81526001600160a01b038781166004830152929350600092909116906370a082319060240160206040518083038186803b1580156119ce57600080fd5b505afa1580156119e2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a069190613c54565b905081811015611a4d5760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742066756e647360701b6044820152606401610980565b611a56846122d6565b611a995760405162461bcd60e51b8152602060048201526014602482015273125d195b481b9bdd081a5b9a5d1a585b1a5cd95960621b6044820152606401610980565b611ab53086868660405180602001604052806000815250612443565b600954604051632770a7eb60e21b81526001600160a01b0387811660048301526024820185905290911690639dc29fac90604401600060405180830381600087803b158015611b0357600080fd5b505af1158015611108573d6000803e3d6000fd5b6000611b2281611c1f565b506000918252600e602052604090912055565b611b3d611c66565b6001600160a01b038316331480611b595750611b59833361084d565b611b755760405162461bcd60e51b815260040161098090614093565b6000611b8083612313565b90506000611b8e83836127ca565b600854604051630f1740d160e01b81529192506001600160a01b031690630f1740d190611bc19088908590600401613f76565b600060405180830381600087803b158015611bdb57600080fd5b505af1158015611bef573d6000803e3d6000fd5b505050505050505050565b60006001600160e01b03198216637965db0b60e01b14806109ac57506109ac82612a07565b6111d38133612a47565b8051610a2490600290602084019061350f565b6000611c49848484611d95565b8015610b18575083611c5b87876128df565b149695505050505050565b60055460ff16156114255760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610980565b6001600160a01b038416611cd25760405162461bcd60e51b8152600401610980906141b3565b336000611cde85612aab565b90506000611ceb85612aab565b9050611cfc83600089858589612b04565b6000868152602081815260408083206001600160a01b038b16845290915281208054879290611d2c90849061427e565b909155505060408051878152602081018790526001600160a01b03808a1692600092918716917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4611d8c83600089898989612b1a565b50505050505050565b6000816001600160a01b0316611e0284611dfc876040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b90612c85565b6001600160a01b031614949350505050565b604080516060810182526000808252602082018190529181018290526000611e3f6020828688614256565b810190611e4c9190613ae2565b9050611e6f60408051606081018252600080825260208201819052909182015290565b611e7d604060208789614256565b810190611e8a9190613ae2565b8152611e9a606060408789614256565b810190611ea79190613d99565b60ff166020820152611ebc8560608189614256565b810190611ec99190613bed565b81604001906003811115611eed57634e487b7160e01b600052602160045260246000fd5b90816003811115611f0e57634e487b7160e01b600052602160045260246000fd5b905250909590945092505050565b6001600160a01b038416611f425760405162461bcd60e51b8152600401610980906141b3565b8151835114611f635760405162461bcd60e51b81526004016109809061416b565b33611f7381600087878787612b04565b60005b845181101561202a57838181518110611f9f57634e487b7160e01b600052603260045260246000fd5b6020026020010151600080878481518110611fca57634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b031681526020019081526020016000206000828254612012919061427e565b9091555081905061202281614363565b915050611f76565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb878760405161207b929190613fad565b60405180910390a4610c3e81600087878787612ca1565b81518351146120b35760405162461bcd60e51b81526004016109809061416b565b6001600160a01b0384166120d95760405162461bcd60e51b8152600401610980906140dc565b336120e8818787878787612b04565b60005b84518110156121ea57600085828151811061211657634e487b7160e01b600052603260045260246000fd5b60200260200101519050600085838151811061214257634e487b7160e01b600052603260045260246000fd5b602090810291909101810151600084815280835260408082206001600160a01b038e1683529093529190912054909150818110156121925760405162461bcd60e51b815260040161098090614121565b6000838152602081815260408083206001600160a01b038e8116855292528083208585039055908b168252812080548492906121cf90849061427e565b92505081905550505050806121e390614363565b90506120eb565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb878760405161223a929190613fad565b60405180910390a4611384818787878787612ca1565b61225a82826114cf565b610a245760008281526004602090815260408083206001600160a01b03851684529091529020805460ff191660011790556122923390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000806122e283612313565b905060008160400151600381111561230a57634e487b7160e01b600052602160045260246000fd5b14159392505050565b61233460408051606081018252600080825260208201819052909182015290565b6000828152600d6020908152604091829020825160608101845281548152600182015460ff80821694830194909452909391929184019161010090910416600381111561239157634e487b7160e01b600052602160045260246000fd5b60038111156123b057634e487b7160e01b600052602160045260246000fd5b90525092915050565b6000836001600160a01b0316836001600160a01b0316636352211e846040518263ffffffff1660e01b81526004016123f391815260200190565b60206040518083038186803b15801561240b57600080fd5b505afa15801561241f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e029190613718565b6001600160a01b0384166124695760405162461bcd60e51b8152600401610980906140dc565b33600061247585612aab565b9050600061248285612aab565b9050612492838989858589612b04565b6000868152602081815260408083206001600160a01b038c168452909152902054858110156124d35760405162461bcd60e51b815260040161098090614121565b6000878152602081815260408083206001600160a01b038d8116855292528083208985039055908a1682528120805488929061251090849061427e565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4611bef848a8a8a8a8a612b1a565b6000838152600f60209081526040808320546001600160a01b0316835260118252808320858452909152812080548392906125ac90849061427e565b9091555050505050565b6125c082826114cf565b15610a245760008281526004602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b612625612d6b565b6005805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b7f000000000000000000000000000000000000000000000000000000000000000160038111156126af57634e487b7160e01b600052602160045260246000fd5b8260038111156126cf57634e487b7160e01b600052602160045260246000fd5b146126d957600080fd5b6126fa60408051606081018252600080825260208201819052909182015290565b84815260ff841660208201526040810183600381111561272a57634e487b7160e01b600052602160045260246000fd5b9081600381111561274b57634e487b7160e01b600052602160045260246000fd5b9052506000858152600d6020908152604091829020835181559083015160018201805460ff90921660ff19831681178255938501518594909261ffff1916176101008360038111156127ad57634e487b7160e01b600052602160045260246000fd5b021790555050506000858152600e60205260409020829055610c3e565b606082826040516020016127df929190614202565b604051602081830303815290604052905092915050565b6003546001600160a01b031633146114255760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610980565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6128aa611c66565b6005805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586126523390565b6040516bffffffffffffffffffffffff19606084901b1660208201526034810182905260009060540160405160208183030381529060405280519060200120905092915050565b816001600160a01b0316836001600160a01b0316141561299a5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b6064820152608401610980565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b60006001600160e01b03198216636cdb3d1360e11b1480612a3857506001600160e01b031982166303a24d0760e21b145b806109ac57506109ac82612db4565b612a5182826114cf565b610a2457612a69816001600160a01b03166014612de9565b612a74836020612de9565b604051602001612a85929190613e5e565b60408051601f198184030181529082905262461bcd60e51b825261098091600401613fdb565b60408051600180825281830190925260609160009190602080830190803683370190505090508281600081518110612af357634e487b7160e01b600052603260045260246000fd5b602090810291909101015292915050565b612b0c611c66565b611384868686868686612fca565b6001600160a01b0384163b156113845760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e6190612b5e9089908990889088908890600401613f31565b602060405180830381600087803b158015612b7857600080fd5b505af1925050508015612ba8575060408051601f3d908101601f19168201909252612ba591810190613b92565b60015b612c5557612bb46143aa565b806308c379a01415612bee5750612bc96143c2565b80612bd45750612bf0565b8060405162461bcd60e51b81526004016109809190613fdb565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e20455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b6064820152608401610980565b6001600160e01b0319811663f23a6e6160e01b14611d8c5760405162461bcd60e51b81526004016109809061404b565b6000806000612c94858561317b565b9150915061132f816131e8565b6001600160a01b0384163b156113845760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190612ce59089908990889088908890600401613ed3565b602060405180830381600087803b158015612cff57600080fd5b505af1925050508015612d2f575060408051601f3d908101601f19168201909252612d2c91810190613b92565b60015b612d3b57612bb46143aa565b6001600160e01b0319811663bc197c8160e01b14611d8c5760405162461bcd60e51b81526004016109809061404b565b60055460ff166114255760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610980565b60006001600160e01b03198216630271189760e51b14806109ac57506301ffc9a760e01b6001600160e01b03198316146109ac565b60606000612df8836002614296565b612e0390600261427e565b6001600160401b03811115612e2857634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612e52576020820181803683370190505b509050600360fc1b81600081518110612e7b57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612eb857634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000612edc846002614296565b612ee790600161427e565b90505b6001811115612f7b576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612f2957634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110612f4d57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93612f74816142e5565b9050612eea565b508315610bb35760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610980565b6001600160a01b03851661306d5760005b835181101561306b5782818151811061300457634e487b7160e01b600052603260045260246000fd5b60200260200101516006600086848151811061303057634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000206000828254613055919061427e565b90915550613064905081614363565b9050612fdb565b505b6001600160a01b0384166113845760005b8351811015611d8c5760008482815181106130a957634e487b7160e01b600052603260045260246000fd5b6020026020010151905060008483815181106130d557634e487b7160e01b600052603260045260246000fd5b60200260200101519050600060066000848152602001908152602001600020549050818110156131585760405162461bcd60e51b815260206004820152602860248201527f455243313135353a206275726e20616d6f756e74206578636565647320746f74604482015267616c537570706c7960c01b6064820152608401610980565b6000928352600660205260409092209103905561317481614363565b905061307e565b6000808251604114156131b25760208301516040840151606085015160001a6131a6878285856133e9565b94509450505050610c20565b8251604014156131dc57602083015160408401516131d18683836134d6565b935093505050610c20565b50600090506002610c20565b600081600481111561320a57634e487b7160e01b600052602160045260246000fd5b14156132135750565b600181600481111561323557634e487b7160e01b600052602160045260246000fd5b14156132835760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610980565b60028160048111156132a557634e487b7160e01b600052602160045260246000fd5b14156132f35760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610980565b600381600481111561331557634e487b7160e01b600052602160045260246000fd5b141561336e5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610980565b600481600481111561339057634e487b7160e01b600052602160045260246000fd5b14156111d35760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610980565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561342057506000905060036134cd565b8460ff16601b1415801561343857508460ff16601c14155b1561344957506000905060046134cd565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561349d573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166134c6576000600192509250506134cd565b9150600090505b94509492505050565b6000806001600160ff1b038316816134f360ff86901c601b61427e565b9050613501878288856133e9565b935093505050935093915050565b82805461351b906142fc565b90600052602060002090601f01602090048101928261353d5760008555613583565b82601f1061355657805160ff1916838001178555613583565b82800160010185558215613583579182015b82811115613583578251825591602001919060010190613568565b5061358f929150613593565b5090565b5b8082111561358f5760008155600101613594565b60006001600160401b038311156135c1576135c1614394565b6040516135d8601f8501601f191660200182614337565b8091508381528484840111156135ed57600080fd5b83836020830137600060208583010152509392505050565b600082601f830112613615578081fd5b8135602061362282614233565b60405161362f8282614337565b8381528281019150858301600585901b8701840188101561364e578586fd5b855b8581101561366c57813584529284019290840190600101613650565b5090979650505050505050565b60008083601f84011261368a578182fd5b5081356001600160401b038111156136a0578182fd5b602083019150836020828501011115610c2057600080fd5b600082601f8301126136c8578081fd5b610bb3838335602085016135a8565b8035600481106136e657600080fd5b919050565b803560ff811681146136e657600080fd5b60006020828403121561370d578081fd5b8135610bb38161444b565b600060208284031215613729578081fd5b8151610bb38161444b565b60008060408385031215613746578081fd5b82356137518161444b565b915060208301356137618161444b565b809150509250929050565b600080600080600060a08688031215613783578081fd5b853561378e8161444b565b9450602086013561379e8161444b565b935060408601356001600160401b03808211156137b9578283fd5b6137c589838a01613605565b945060608801359150808211156137da578283fd5b6137e689838a01613605565b935060808801359150808211156137fb578283fd5b50613808888289016136b8565b9150509295509295909350565b600080600080600060a0868803121561382c578081fd5b85356138378161444b565b945060208601356138478161444b565b9350604086013592506060860135915060808601356001600160401b0381111561386f578182fd5b613808888289016136b8565b60008060008060808587031215613890578182fd5b843561389b8161444b565b935060208501356001600160401b03808211156138b6578384fd5b6138c288838901613605565b945060408701359150808211156138d7578384fd5b6138e388838901613605565b935060608701359150808211156138f8578283fd5b50613905878288016136b8565b91505092959194509250565b60008060408385031215613923578182fd5b823561392e8161444b565b915060208301358015158114613761578182fd5b60008060408385031215613954578182fd5b823561395f8161444b565b946020939093013593505050565b600080600080600060a08688031215613984578283fd5b853561398f8161444b565b9450602086013593506040860135925060608601356001600160401b038111156139b7578182fd5b6139c3888289016136b8565b92505060808601356139d48161444b565b809150509295509295909350565b6000806000606084860312156139f6578081fd5b8335613a018161444b565b95602085013595506040909401359392505050565b60008060408385031215613a28578182fd5b82356001600160401b0380821115613a3e578384fd5b818501915085601f830112613a51578384fd5b81356020613a5e82614233565b604051613a6b8282614337565b8381528281019150858301600585901b870184018b1015613a8a578889fd5b8896505b84871015613ab5578035613aa18161444b565b835260019690960195918301918301613a8e565b5096505086013592505080821115613acb578283fd5b50613ad885828601613605565b9150509250929050565b600060208284031215613af3578081fd5b5035919050565b60008060408385031215613b0c578182fd5b8235915060208301356137618161444b565b600080600060608486031215613b32578081fd5b8335925060208401356001600160401b03811115613b4e578182fd5b613b5a868287016136b8565b9250506040840135613b6b8161444b565b809150509250925092565b600060208284031215613b87578081fd5b8135610bb381614460565b600060208284031215613ba3578081fd5b8151610bb381614460565b60008060208385031215613bc0578182fd5b82356001600160401b03811115613bd5578283fd5b613be185828601613679565b90969095509350505050565b600060208284031215613bfe578081fd5b610bb3826136d7565b600060208284031215613c18578081fd5b81356001600160401b03811115613c2d578182fd5b8201601f81018413613c3d578182fd5b613c4c848235602084016135a8565b949350505050565b600060208284031215613c65578081fd5b5051919050565b60008060408385031215613c7e578182fd5b50508035926020909101359150565b60008060008060008060a08789031215613ca5578384fd5b8635955060208701359450604087013593506060870135925060808701356001600160401b03811115613cd6578182fd5b613ce289828a01613679565b979a9699509497509295939492505050565b60008060008060808587031215613d09578182fd5b84359350613d19602086016136eb565b9250613d27604086016136d7565b9396929550929360600135925050565b60008060008060008060c08789031215613d4f578384fd5b86359550613d5f602088016136eb565b9450613d6d604088016136d7565b9350606087013592506080870135613d848161444b565b8092505060a087013590509295509295509295565b600060208284031215613daa578081fd5b610bb3826136eb565b6000815180845260208085019450808401835b83811015613de257815187529582019590820190600101613dc6565b509495945050505050565b60008151808452613e058160208601602086016142b5565b601f01601f19169290920160200192915050565b60048110613e3757634e487b7160e01b600052602160045260246000fd5b9052565b8051825260ff60208201511660208301526040810151610b9e6040840182613e19565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613e968160178501602088016142b5565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613ec78160288401602088016142b5565b01602801949350505050565b6001600160a01b0386811682528516602082015260a060408201819052600090613eff90830186613db3565b8281036060840152613f118186613db3565b90508281036080840152613f258185613ded565b98975050505050505050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090613f6b90830184613ded565b979650505050505050565b6001600160a01b0383168152604060208201819052600090610bb090830184613ded565b602081526000610bb36020830184613db3565b604081526000613fc06040830185613db3565b8281036020840152613fd28185613db3565b95945050505050565b602081526000610bb36020830184613ded565b602081016109ac8284613e19565b6020808252602f908201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60408201526e195c881b9bdc88185c1c1c9bdd9959608a1b606082015260800190565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b60208082526029908201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260408201526808185c1c1c9bdd995960ba1b606082015260800190565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b60208082526021908201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736040820152607360f81b606082015260800190565b606081016109ac8284613e3b565b82815260808101610bb36020830184613e3b565b83815260ff8316602082015260608101613c4c6040830184613e19565b60006001600160401b0382111561424c5761424c614394565b5060051b60200190565b60008085851115614265578182fd5b83861115614271578182fd5b5050820193919092039150565b600082198211156142915761429161437e565b500190565b60008160001904831182151516156142b0576142b061437e565b500290565b60005b838110156142d05781810151838201526020016142b8565b838111156142df576000848401525b50505050565b6000816142f4576142f461437e565b506000190190565b600181811c9082168061431057607f821691505b6020821081141561433157634e487b7160e01b600052602260045260246000fd5b50919050565b601f8201601f191681016001600160401b038111828210171561435c5761435c614394565b6040525050565b60006000198214156143775761437761437e565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b600060033d11156143bf57600481823e5160e01c5b90565b600060443d10156143d05790565b6040516003193d81016004833e81513d6001600160401b0381602484011181841117156143ff57505050505090565b82850191508151818111156144175750505050505090565b843d87010160208285010111156144315750505050505090565b61444060208286010187614337565b509095945050505050565b6001600160a01b03811681146111d357600080fd5b6001600160e01b0319811681146111d357600080fdfea26469706673582212208f2e4b08630bc1d1476e685eacf51376762250a5f5ba5093b9157544c638a52164736f6c63430008040033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c80f2f0598db841f48afa998fb70122e37361f4a0000000000000000000000000000000000000000000000000000000000000001
-----Decoded View---------------
Arg [0] : signer (address): 0xC80f2f0598db841f48AFA998fb70122e37361F4A
Arg [1] : itemType (uint8): 1
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000c80f2f0598db841f48afa998fb70122e37361f4a
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000001
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.