文件 1 的 22:Address.sol
pragma solidity ^0.8.1;
library Address {
function isContract(address account) internal view returns (bool) {
return account.code.length > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
文件 2 的 22:BaseControl.sol
pragma solidity ^0.8.9;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
abstract contract BaseControl is Ownable {
bool public presaleActive;
bool public saleActive;
bool public tokenPaused;
address public tearContract;
address public signerAccount = 0x046c2c915d899D550471d0a7b4d0FaCF79Cde290;
string public hashKey = "vhils-drp";
string public backupURI;
string public defaultURI;
function togglePresale(bool _status) external onlyOwner {
presaleActive = _status;
}
function toggleSale(bool _status) external onlyOwner {
saleActive = _status;
}
function setTokenPaused(bool _status) external onlyOwner {
tokenPaused = _status;
}
function setSignerInfo(address _signer) external onlyOwner {
signerAccount = _signer;
}
function setHashKey(string calldata _hashKey) external onlyOwner {
hashKey = _hashKey;
}
function setTearContract(address _contract) external onlyOwner {
tearContract = _contract;
}
function setBackupURI(string calldata _uri) external onlyOwner {
backupURI = _uri;
}
function setDefaultURI(string calldata _uri) external onlyOwner {
defaultURI = _uri;
}
function isBlank(string memory _string) internal pure returns (bool) {
return bytes(_string).length == 0;
}
function splitSignature(bytes memory _sig)
internal
pure
returns (
uint8,
bytes32,
bytes32
)
{
require(_sig.length == 65, "Invalid signature length");
uint8 v;
bytes32 r;
bytes32 s;
assembly {
r := mload(add(_sig, 32))
s := mload(add(_sig, 64))
v := byte(0, mload(add(_sig, 96)))
}
return (v, r, s);
}
function validSignature(bytes32 _message, bytes memory _signature) internal view returns (bool) {
bytes32 ethSignedMessageHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", _message));
(uint8 v, bytes32 r, bytes32 s) = splitSignature(_signature);
return ecrecover(ethSignedMessageHash, v, r, s) == signerAccount;
}
}
文件 3 的 22:BitMaps.sol
pragma solidity ^0.8.0;
library BitMaps {
struct BitMap {
mapping(uint256 => uint256) _data;
}
function get(BitMap storage bitmap, uint256 index) internal view returns (bool) {
uint256 bucket = index >> 8;
uint256 mask = 1 << (index & 0xff);
return bitmap._data[bucket] & mask != 0;
}
function setTo(
BitMap storage bitmap,
uint256 index,
bool value
) internal {
if (value) {
set(bitmap, index);
} else {
unset(bitmap, index);
}
}
function set(BitMap storage bitmap, uint256 index) internal {
uint256 bucket = index >> 8;
uint256 mask = 1 << (index & 0xff);
bitmap._data[bucket] |= mask;
}
function unset(BitMap storage bitmap, uint256 index) internal {
uint256 bucket = index >> 8;
uint256 mask = 1 << (index & 0xff);
bitmap._data[bucket] &= ~mask;
}
}
文件 4 的 22:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 5 的 22:ERC1155Holder.sol
pragma solidity ^0.8.0;
import "./ERC1155Receiver.sol";
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;
}
}
文件 6 的 22:ERC1155Receiver.sol
pragma solidity ^0.8.0;
import "../IERC1155Receiver.sol";
import "../../../utils/introspection/ERC165.sol";
abstract contract ERC1155Receiver is ERC165, IERC1155Receiver {
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
}
}
文件 7 的 22:ERC165.sol
pragma solidity ^0.8.0;
import "./IERC165.sol";
abstract contract ERC165 is IERC165 {
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
文件 8 的 22:ERC2981.sol
pragma solidity ^0.8.0;
import "../../interfaces/IERC2981.sol";
import "../../utils/introspection/ERC165.sol";
abstract contract ERC2981 is IERC2981, ERC165 {
struct RoyaltyInfo {
address receiver;
uint96 royaltyFraction;
}
RoyaltyInfo private _defaultRoyaltyInfo;
mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo;
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) {
return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId);
}
function royaltyInfo(uint256 _tokenId, uint256 _salePrice)
external
view
virtual
override
returns (address, uint256)
{
RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId];
if (royalty.receiver == address(0)) {
royalty = _defaultRoyaltyInfo;
}
uint256 royaltyAmount = (_salePrice * royalty.royaltyFraction) / _feeDenominator();
return (royalty.receiver, royaltyAmount);
}
function _feeDenominator() internal pure virtual returns (uint96) {
return 10000;
}
function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: invalid receiver");
_defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);
}
function _deleteDefaultRoyalty() internal virtual {
delete _defaultRoyaltyInfo;
}
function _setTokenRoyalty(
uint256 tokenId,
address receiver,
uint96 feeNumerator
) internal virtual {
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: Invalid parameters");
_tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);
}
function _resetTokenRoyalty(uint256 tokenId) internal virtual {
delete _tokenRoyaltyInfo[tokenId];
}
}
文件 9 的 22:ERC721.sol
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
string private _name;
string private _symbol;
mapping(uint256 => address) private _owners;
mapping(address => uint256) private _balances;
mapping(uint256 => address) private _tokenApprovals;
mapping(address => mapping(address => bool)) private _operatorApprovals;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
function _baseURI() internal view virtual returns (string memory) {
return "";
}
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId);
}
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId);
}
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);
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId);
}
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
文件 10 的 22:ERC721Burnable.sol
pragma solidity ^0.8.0;
import "../ERC721.sol";
import "../../../utils/Context.sol";
abstract contract ERC721Burnable is Context, ERC721 {
function burn(uint256 tokenId) public virtual {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved");
_burn(tokenId);
}
}
文件 11 的 22:ERC721Royalty.sol
pragma solidity ^0.8.0;
import "../ERC721.sol";
import "../../common/ERC2981.sol";
import "../../../utils/introspection/ERC165.sol";
abstract contract ERC721Royalty is ERC2981, ERC721 {
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC2981) returns (bool) {
return super.supportsInterface(interfaceId);
}
function _burn(uint256 tokenId) internal virtual override {
super._burn(tokenId);
_resetTokenRoyalty(tokenId);
}
}
文件 12 的 22:IERC1155Receiver.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC1155Receiver is IERC165 {
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}
文件 13 的 22:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 14 的 22:IERC2981.sol
pragma solidity ^0.8.0;
import "./IERC165.sol";
interface IERC2981 is IERC165 {
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
}
文件 15 的 22:IERC721.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC721 is IERC165 {
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
function balanceOf(address owner) external view returns (uint256 balance);
function ownerOf(uint256 tokenId) external view returns (address owner);
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
function approve(address to, uint256 tokenId) external;
function getApproved(uint256 tokenId) external view returns (address operator);
function setApprovalForAll(address operator, bool _approved) external;
function isApprovedForAll(address owner, address operator) external view returns (bool);
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
文件 16 的 22:IERC721Enumerable.sol
pragma solidity ^0.8.0;
import "../IERC721.sol";
interface IERC721Enumerable is IERC721 {
function totalSupply() external view returns (uint256);
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
function tokenByIndex(uint256 index) external view returns (uint256);
}
文件 17 的 22:IERC721Metadata.sol
pragma solidity ^0.8.0;
import "../IERC721.sol";
interface IERC721Metadata is IERC721 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function tokenURI(uint256 tokenId) external view returns (string memory);
}
文件 18 的 22:IERC721Receiver.sol
pragma solidity ^0.8.0;
interface IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
文件 19 的 22:NFTEnumerable.sol
pragma solidity ^0.8.9;
import { BaseControl } from "./BaseControl.sol";
import { ERC721Royalty, ERC721, IERC721, IERC165 } from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Royalty.sol";
import { IERC721Enumerable } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import { ERC721Burnable } from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import { BitMaps } from "@openzeppelin/contracts/utils/structs/BitMaps.sol";
abstract contract NFTEnumerable is BaseControl, IERC721Enumerable, ERC721Royalty, ERC721Burnable {
using BitMaps for BitMaps.BitMap;
mapping(address => BitMaps.BitMap) internal _ownedTokens;
BitMaps.BitMap internal _allTokens;
uint256 internal totalCount;
constructor() ERC721("Layers", "LAYERS") {
_setDefaultRoyalty(msg.sender, 500);
}
function _burn(uint256 tokenId) internal virtual override(ERC721, ERC721Royalty) {
super._burn(tokenId);
}
function setDefaultRoyalty(address _receiver, uint96 _feeNumerator) external onlyOwner {
_setDefaultRoyalty(_receiver, _feeNumerator);
}
function setTokenRoyalty(
uint16 _tokenId,
address _receiver,
uint96 _feeNumerator
) external onlyOwner {
_setTokenRoyalty(_tokenId, _receiver, _feeNumerator);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721, ERC721Royalty) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || ERC721Royalty.supportsInterface(interfaceId);
}
function tokenByIndex(uint256 _index) public view virtual override returns (uint256) {
require(_index < NFTEnumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
uint16 tokenId;
uint16 currentIdx;
for (uint16 i = 0; i < 10000; i++) {
if (!_allTokens.get(i)) continue;
if (currentIdx == _index) {
tokenId = i;
break;
}
currentIdx++;
}
return tokenId;
}
function tokenOfOwnerByIndex(address _owner, uint256 _index) public view virtual override returns (uint256) {
require(_index < ERC721.balanceOf(_owner), "ERC721Enumerable: owner index out of bounds");
uint16 tokenId;
uint16 currentIdx;
for (uint16 i = 0; i < 10000; i++) {
if (!_ownedTokens[_owner].get(i)) continue;
if (currentIdx == _index) {
tokenId = i;
break;
}
currentIdx++;
}
return tokenId;
}
function totalSupply() public view virtual override returns (uint256) {
return totalCount;
}
function _beforeTokenTransfer(
address _from,
address _to,
uint256 _tokenId
) internal virtual override {
super._beforeTokenTransfer(_from, _to, _tokenId);
require(_from == address(0) || !tokenPaused, "Token paused");
if (_from == address(0)) {
_addTokenToAllTokensEnumeration(_tokenId);
} else if (_from != _to) {
_removeTokenFromOwnerEnumeration(_from, _tokenId);
}
if (_to == address(0)) {
_removeTokenFromAllTokensEnumeration(_tokenId);
} else if (_to != _from) {
_addTokenToOwnerEnumeration(_to, _tokenId);
}
}
function _addTokenToOwnerEnumeration(address _to, uint256 _tokenId) private {
_ownedTokens[_to].set(_tokenId);
}
function _addTokenToAllTokensEnumeration(uint256 _tokenId) private {
_allTokens.set(_tokenId);
totalCount++;
}
function _removeTokenFromOwnerEnumeration(address _from, uint256 _tokenId) private {
_ownedTokens[_from].unset(_tokenId);
}
function _removeTokenFromAllTokensEnumeration(uint256 _tokenId) private {
_allTokens.unset(_tokenId);
if (totalCount > 0) totalCount--;
}
}
文件 20 的 22:Ownable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
function owner() public view virtual returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 21 的 22:Strings.sol
pragma solidity ^0.8.0;
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
function toString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
文件 22 的 22:VhilsNFT.sol
pragma solidity ^0.8.9;
import { NFTEnumerable, IERC721 } from "./base/NFTEnumerable.sol";
import { ERC1155Holder, ERC1155Receiver } from "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
contract VhilsNFT is NFTEnumerable, ERC1155Holder {
using Strings for uint256;
enum LEVEL {
BASE,
TEAR_1,
TEAR_2,
TEAR_3
}
struct TokenInfo {
LEVEL state;
bool locked;
uint8[4] tearIdUsed;
uint64 name;
string uri;
}
uint256 public constant PRICE = 0.2 ether;
uint8 public constant MAX_PER_WALLET = 5;
uint8 public constant MAX_PER_TXN = 5;
uint16 public constant MAX_SUPPLY = 10000;
uint16 public constant PRESALE_SUPPLY = 9000;
uint16 public constant TEAM_SUPPLY = 978;
uint16 public teamClaimed;
uint16 public presaleClaimed;
uint16 public saleClaimed;
mapping(uint8 => mapping(uint8 => string)) public baseStateURI;
mapping(uint8 => bool) public tearActive;
mapping(address => uint16) public tokenClaimed;
mapping(uint16 => TokenInfo) public tokens;
event TEAR(address indexed from, uint16 indexed tokenId, uint8 tearId, uint256 blockNumber, uint256 timestamp);
event LOCK(address indexed from, uint16 indexed tokenId, bool status, uint256 blockNumber, uint256 timestamp);
constructor() NFTEnumerable() {
defaultURI = 'ipfs://QmeUuVjpM9zrYiz2nMKo41T3wjRRnr4qp4Shn7ngHgfSVX/';
}
function supportsInterface(bytes4 interfaceId) public view virtual override(NFTEnumerable, ERC1155Receiver) returns (bool) {
return super.supportsInterface(interfaceId);
}
function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) {
require(_exists(_tokenId), "Non exists token");
if (!isBlank(backupURI)) {
return string(abi.encodePacked(backupURI, _tokenId.toString()));
}
if (!isBlank(tokens[uint16(_tokenId)].uri)) {
return tokens[uint16(_tokenId)].uri;
}
if (tokens[uint16(_tokenId)].name > 0) {
uint8 state = uint8(tokens[uint16(_tokenId)].state);
uint8 tearId = tokens[uint16(_tokenId)].tearIdUsed[state];
return string(abi.encodePacked(baseStateURI[state][tearId], Strings.toString(tokens[uint16(_tokenId)].name)));
}
return string(abi.encodePacked(defaultURI, _tokenId.toString()));
}
function getTokenInfo(uint16 _tokenId) public view returns (TokenInfo memory) {
return tokens[_tokenId];
}
function presaleMint(uint16 _maxAmount, bytes calldata _signature, uint16 _amount) external payable {
require(tx.origin == msg.sender, "Not allowed");
require(presaleActive, "Not active");
require(_amount <= MAX_PER_TXN, "Exceed txn");
require(eligibleByWhitelist(_maxAmount, msg.sender, _signature, _amount), "Not eligible");
require(presaleClaimed + saleClaimed + _amount + TEAM_SUPPLY <= MAX_SUPPLY, "Exceed supply");
require(presaleClaimed + _amount <= PRESALE_SUPPLY, "Exceed supply");
require(msg.value >= PRICE * _amount, "Insufficient ether");
uint16 claimed = presaleClaimed + saleClaimed;
uint16 tearReward = _amount;
for (uint16 i = 0; i < _amount; i++) {
uint16 tokenId = claimed + i;
_mint(msg.sender, tokenId);
if ((tokenId * 10 % 75) == 0) {
tearReward += 2;
} else if (tokenId % 10 == 0) {
tearReward += 1;
}
}
ITEAR(tearContract).safeTransferFrom(address(this), msg.sender, 1, tearReward, "");
presaleClaimed += _amount;
tokenClaimed[msg.sender] += _amount;
}
function mint(uint16 _amount) external payable {
require(tx.origin == msg.sender, "Not allowed");
require(saleActive, "Not active");
require(_amount <= MAX_PER_TXN, "Exceed txn");
require(tokenClaimed[msg.sender] + _amount <= MAX_PER_WALLET, "Exceed wallet");
require(presaleClaimed + saleClaimed + _amount + TEAM_SUPPLY <= MAX_SUPPLY, "Exceed supply");
require(msg.value >= PRICE * _amount, "Insufficient ether");
uint16 claimed = presaleClaimed + saleClaimed;
uint16 tearReward = _amount;
for (uint16 i = 0; i < _amount; i++) {
uint16 tokenId = claimed + i;
_mint(msg.sender, tokenId);
if ((tokenId * 10 % 75) == 0) {
tearReward += 2;
} else if (tokenId % 10 == 0) {
tearReward += 1;
}
}
ITEAR(tearContract).safeTransferFrom(address(this), msg.sender, 1, tearReward, "");
saleClaimed += _amount;
tokenClaimed[msg.sender] += _amount;
}
function tear(uint16 _tokenId, uint8 _tearId, uint64 _name, bytes calldata _signature) external {
uint8 tearUnit = 1;
uint8 newLevel = uint8(tokens[_tokenId].state) + tearUnit;
require(ownerOf(_tokenId) == msg.sender, "Not allowed");
require(eligibleTear(_tokenId), "Not eligible");
bytes32 message = keccak256(abi.encodePacked(hashKey, newLevel, _tokenId, _name, msg.sender));
require(validSignature(message, _signature), "Signature eligible");
ITEAR(tearContract).safeTransferFrom(msg.sender, address(this), _tearId, tearUnit, "");
tokens[_tokenId].name = _name;
tokens[_tokenId].state = LEVEL(newLevel);
tokens[_tokenId].tearIdUsed[newLevel] = _tearId;
emit TEAR(msg.sender, _tokenId, _tearId, block.number, block.timestamp);
}
function lockToken(uint16 _tokenId, bool _status) external {
require(msg.sender == ownerOf(_tokenId), "Not allowed");
tokens[_tokenId].locked = _status;
emit LOCK(msg.sender, _tokenId, _status, block.number, block.timestamp);
}
function _beforeTokenTransfer(
address _from,
address _to,
uint256 _tokenId
) internal virtual override {
super._beforeTokenTransfer(_from, _to, _tokenId);
require(!tokens[uint16(_tokenId)].locked, "Token locked");
}
function eligibleTear(uint16 _tokenId) public view returns (bool) {
uint8 newLevel = uint8(tokens[_tokenId].state) + 1;
if (newLevel > uint8(LEVEL.TEAR_3)) {
return false;
}
return tearActive[newLevel];
}
function eligibleByWhitelist(uint16 _maxAmount, address _account, bytes memory _signature, uint16 _amount) internal view returns (bool) {
bytes32 message = keccak256(abi.encodePacked(hashKey, _maxAmount, _account));
return validSignature(message, _signature) && tokenClaimed[_account] + _amount <= MAX_PER_WALLET && tokenClaimed[_account] + _amount <= _maxAmount;
}
function setTokenURI(uint16 _tokenId, string calldata _uri) external onlyOwner {
tokens[_tokenId].uri = _uri;
}
function setTokenURIName(uint16 _tokenId, uint64 _name) external onlyOwner {
tokens[_tokenId].name = _name;
}
function setBaseStateURI(LEVEL _stage, uint8 _tearId, string calldata _uri) external onlyOwner {
baseStateURI[uint8(_stage)][_tearId] = _uri;
}
function toggleTear(LEVEL _tear, bool _status) external onlyOwner {
tearActive[uint8(_tear)] = _status;
}
function withdrawTEAR(uint8 _tearId) external onlyOwner {
uint256 balance = ITEAR(tearContract).balanceOf(address(this), _tearId);
ITEAR(tearContract).safeTransferFrom(address(this), msg.sender, _tearId, balance, "");
}
function withdraw() external onlyOwner {
uint256 balance = address(this).balance;
uint256 balanceA;
uint256 balanceB;
uint256 balanceC;
if (balance > 2 ether) {
balance = balance - 2 ether;
balanceA = balance * 25 / 100;
balanceB = balance * 60 / 100;
balanceC = balance - balanceA - balanceB + 2 ether;
} else {
balanceA = balance * 25 / 100;
balanceB = balance * 60 / 100;
balanceC = balance - balanceA - balanceB;
}
(bool successA, ) = 0xDAEcAcCBA76EcCaAD1ca3398dC324e04da72De77.call{value: balanceA}("");
if (!successA) {
payable(msg.sender).transfer(balanceA);
}
(bool successB, ) = 0x7b5e2f53bdbbbFb7fcd1f0792d671040081D4342.call{value: balanceB}("");
if (!successB) {
payable(msg.sender).transfer(balanceB);
}
(bool successC, ) = 0x58F58f15A0D080932218D65beb8bBd83978677d7.call{value: balanceC}("");
if (!successC) {
payable(msg.sender).transfer(balanceC);
}
}
function forceWithdraw() external onlyOwner {
uint256 balance = address(this).balance;
payable(msg.sender).transfer(balance);
}
function teamClaim(address _receiver, uint16 _amount) external onlyOwner {
require(teamClaimed < TEAM_SUPPLY, "Exceed max");
uint16 start = MAX_SUPPLY - TEAM_SUPPLY + teamClaimed;
uint16 max = start + _amount;
for (uint16 i = start; i < max; i ++) {
_mint(_receiver, i);
}
teamClaimed += _amount;
}
}
interface ITEAR {
function balanceOf(address, uint256) external view returns (uint256);
function safeTransferFrom(
address,
address,
uint256,
uint256,
bytes calldata
) external;
}
{
"compilationTarget": {
"contracts/vhils/VhilsNFT.sol": "VhilsNFT"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"uint16","name":"tokenId","type":"uint16"},{"indexed":false,"internalType":"bool","name":"status","type":"bool"},{"indexed":false,"internalType":"uint256","name":"blockNumber","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"LOCK","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"uint16","name":"tokenId","type":"uint16"},{"indexed":false,"internalType":"uint8","name":"tearId","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"blockNumber","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"TEAR","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"MAX_PER_TXN","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_PER_WALLET","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_SUPPLY","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRESALE_SUPPLY","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRICE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TEAM_SUPPLY","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"backupURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"","type":"uint8"},{"internalType":"uint8","name":"","type":"uint8"}],"name":"baseStateURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_tokenId","type":"uint16"}],"name":"eligibleTear","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"forceWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_tokenId","type":"uint16"}],"name":"getTokenInfo","outputs":[{"components":[{"internalType":"enum VhilsNFT.LEVEL","name":"state","type":"uint8"},{"internalType":"bool","name":"locked","type":"bool"},{"internalType":"uint8[4]","name":"tearIdUsed","type":"uint8[4]"},{"internalType":"uint64","name":"name","type":"uint64"},{"internalType":"string","name":"uri","type":"string"}],"internalType":"struct VhilsNFT.TokenInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hashKey","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_tokenId","type":"uint16"},{"internalType":"bool","name":"_status","type":"bool"}],"name":"lockToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_amount","type":"uint16"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"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":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"presaleActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"presaleClaimed","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_maxAmount","type":"uint16"},{"internalType":"bytes","name":"_signature","type":"bytes"},{"internalType":"uint16","name":"_amount","type":"uint16"}],"name":"presaleMint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"saleActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"saleClaimed","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_uri","type":"string"}],"name":"setBackupURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum VhilsNFT.LEVEL","name":"_stage","type":"uint8"},{"internalType":"uint8","name":"_tearId","type":"uint8"},{"internalType":"string","name":"_uri","type":"string"}],"name":"setBaseStateURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint96","name":"_feeNumerator","type":"uint96"}],"name":"setDefaultRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_uri","type":"string"}],"name":"setDefaultURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_hashKey","type":"string"}],"name":"setHashKey","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_signer","type":"address"}],"name":"setSignerInfo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"}],"name":"setTearContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_status","type":"bool"}],"name":"setTokenPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_tokenId","type":"uint16"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint96","name":"_feeNumerator","type":"uint96"}],"name":"setTokenRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_tokenId","type":"uint16"},{"internalType":"string","name":"_uri","type":"string"}],"name":"setTokenURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_tokenId","type":"uint16"},{"internalType":"uint64","name":"_name","type":"uint64"}],"name":"setTokenURIName","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"signerAccount","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint16","name":"_amount","type":"uint16"}],"name":"teamClaim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"teamClaimed","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_tokenId","type":"uint16"},{"internalType":"uint8","name":"_tearId","type":"uint8"},{"internalType":"uint64","name":"_name","type":"uint64"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"tear","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"","type":"uint8"}],"name":"tearActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tearContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_status","type":"bool"}],"name":"togglePresale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_status","type":"bool"}],"name":"toggleSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum VhilsNFT.LEVEL","name":"_tear","type":"uint8"},{"internalType":"bool","name":"_status","type":"bool"}],"name":"toggleTear","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenClaimed","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"tokens","outputs":[{"internalType":"enum VhilsNFT.LEVEL","name":"state","type":"uint8"},{"internalType":"bool","name":"locked","type":"bool"},{"internalType":"uint64","name":"name","type":"uint64"},{"internalType":"string","name":"uri","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_tearId","type":"uint8"}],"name":"withdrawTEAR","outputs":[],"stateMutability":"nonpayable","type":"function"}]