|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface IERC721Receiver {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onERC721Received(
|
|
address operator,
|
|
address from,
|
|
uint256 tokenId,
|
|
bytes calldata data
|
|
) external returns (bytes4);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
|
|
|
|
|
|
library Strings {
|
|
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
|
|
uint8 private constant _ADDRESS_LENGTH = 20;
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
|
|
|
|
|
|
function toHexString(address addr) internal pure returns (string memory) {
|
|
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
pragma solidity ^0.8.7;
|
|
|
|
|
|
abstract contract MerkleProof {
|
|
bytes32 internal _wlMerkleRoot;
|
|
|
|
|
|
function _setwlMerkleRoot(bytes32 merkleRoot_) internal virtual {
|
|
_wlMerkleRoot = merkleRoot_;
|
|
}
|
|
|
|
function isWhitelisted(address address_, uint256 wlCount, bytes32[] memory proof_) public view returns (bool) {
|
|
bytes32 _leaf = keccak256(abi.encodePacked(address_, wlCount));
|
|
for (uint256 i = 0; i < proof_.length; i++) {
|
|
_leaf = _leaf < proof_[i] ? keccak256(abi.encodePacked(_leaf, proof_[i])) : keccak256(abi.encodePacked(proof_[i], _leaf));
|
|
}
|
|
return _leaf == _wlMerkleRoot;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
library Base64 {
|
|
|
|
|
|
|
|
string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
|
|
|
|
|
|
|
|
function encode(bytes memory data) internal pure returns (string memory) {
|
|
|
|
|
|
|
|
|
|
if (data.length == 0) return "";
|
|
|
|
|
|
string memory table = _TABLE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string memory result = new string(4 * ((data.length + 2) / 3));
|
|
|
|
|
|
assembly {
|
|
|
|
let tablePtr := add(table, 1)
|
|
|
|
|
|
let resultPtr := add(result, 32)
|
|
|
|
|
|
for {
|
|
let dataPtr := data
|
|
let endPtr := add(data, mload(data))
|
|
} lt(dataPtr, endPtr) {
|
|
|
|
} {
|
|
|
|
dataPtr := add(dataPtr, 3)
|
|
let input := mload(dataPtr)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))
|
|
resultPtr := add(resultPtr, 1)
|
|
|
|
mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))
|
|
resultPtr := add(resultPtr, 1)
|
|
|
|
mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))
|
|
resultPtr := add(resultPtr, 1)
|
|
|
|
mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))
|
|
resultPtr := add(resultPtr, 1)
|
|
}
|
|
|
|
|
|
|
|
switch mod(mload(data), 3)
|
|
case 1 {
|
|
mstore8(sub(resultPtr, 1), 0x3d)
|
|
mstore8(sub(resultPtr, 2), 0x3d)
|
|
}
|
|
case 2 {
|
|
mstore8(sub(resultPtr, 1), 0x3d)
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface IERC165 {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function supportsInterface(bytes4 interfaceId) external view returns (bool);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
|
|
|
|
|
|
|
|
interface IERC721 is IERC165 {
|
|
|
|
|
|
|
|
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
|
|
|
|
|
|
|
|
|
|
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
|
|
|
|
|
|
|
|
|
|
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
|
|
|
|
|
|
|
|
|
|
function balanceOf(address owner) external view returns (uint256 balance);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function ownerOf(uint256 tokenId) external view returns (address owner);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function safeTransferFrom(
|
|
address from,
|
|
address to,
|
|
uint256 tokenId,
|
|
bytes calldata data
|
|
) external;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function safeTransferFrom(
|
|
address from,
|
|
address to,
|
|
uint256 tokenId
|
|
) external;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function transferFrom(
|
|
address from,
|
|
address to,
|
|
uint256 tokenId
|
|
) external;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function approve(address to, uint256 tokenId) external;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setApprovalForAll(address operator, bool _approved) external;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getApproved(uint256 tokenId) external view returns (address operator);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isApprovedForAll(address owner, address operator) external view returns (bool);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.4;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface IERC721A is IERC721, IERC721Metadata {
|
|
|
|
|
|
|
|
error ApprovalCallerNotOwnerNorApproved();
|
|
|
|
|
|
|
|
|
|
error ApprovalQueryForNonexistentToken();
|
|
|
|
|
|
|
|
|
|
error ApproveToCaller();
|
|
|
|
|
|
|
|
|
|
error ApprovalToCurrentOwner();
|
|
|
|
|
|
|
|
|
|
error BalanceQueryForZeroAddress();
|
|
|
|
|
|
|
|
|
|
error MintToZeroAddress();
|
|
|
|
|
|
|
|
|
|
error MintZeroQuantity();
|
|
|
|
|
|
|
|
|
|
error OwnerQueryForNonexistentToken();
|
|
|
|
|
|
|
|
|
|
error TransferCallerNotOwnerNorApproved();
|
|
|
|
|
|
|
|
|
|
error TransferFromIncorrectOwner();
|
|
|
|
|
|
|
|
|
|
error TransferToNonERC721ReceiverImplementer();
|
|
|
|
|
|
|
|
|
|
error TransferToZeroAddress();
|
|
|
|
|
|
|
|
|
|
error URIQueryForNonexistentToken();
|
|
|
|
|
|
struct TokenOwnership {
|
|
|
|
address addr;
|
|
|
|
uint64 startTimestamp;
|
|
|
|
bool burned;
|
|
}
|
|
|
|
|
|
struct AddressData {
|
|
|
|
uint64 balance;
|
|
|
|
uint64 numberMinted;
|
|
|
|
uint64 numberBurned;
|
|
|
|
|
|
|
|
uint64 aux;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function totalSupply() external view returns (uint256);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract contract ERC165 is IERC165 {
|
|
|
|
|
|
|
|
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
|
|
return interfaceId == type(IERC165).interfaceId;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface IERC2981 is IERC165 {
|
|
|
|
|
|
|
|
|
|
function royaltyInfo(uint256 tokenId, uint256 salePrice)
|
|
external
|
|
view
|
|
returns (address receiver, uint256 royaltyAmount);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) public 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];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract contract ReentrancyGuard {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint256 private constant _NOT_ENTERED = 1;
|
|
uint256 private constant _ENTERED = 2;
|
|
|
|
uint256 private _status;
|
|
|
|
constructor() {
|
|
_status = _NOT_ENTERED;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modifier nonReentrant() {
|
|
|
|
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
|
|
|
|
|
|
_status = _ENTERED;
|
|
|
|
_;
|
|
|
|
|
|
|
|
_status = _NOT_ENTERED;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.4;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contract ERC721A is Context, ERC165, IERC721A {
|
|
using Address for address;
|
|
using Strings for uint256;
|
|
|
|
|
|
uint256 internal _currentIndex;
|
|
|
|
|
|
uint256 internal _burnCounter;
|
|
|
|
|
|
string private _name;
|
|
|
|
|
|
string private _symbol;
|
|
|
|
|
|
|
|
mapping(uint256 => TokenOwnership) internal _ownerships;
|
|
|
|
|
|
mapping(address => AddressData) private _addressData;
|
|
|
|
|
|
mapping(uint256 => address) private _tokenApprovals;
|
|
|
|
|
|
mapping(address => mapping(address => bool)) private _operatorApprovals;
|
|
|
|
constructor(string memory name_, string memory symbol_) {
|
|
_name = name_;
|
|
_symbol = symbol_;
|
|
_currentIndex = _startTokenId();
|
|
}
|
|
|
|
|
|
|
|
|
|
function _startTokenId() internal view virtual returns (uint256) {
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
function totalSupply() public view override returns (uint256) {
|
|
|
|
|
|
unchecked {
|
|
return _currentIndex - _burnCounter - _startTokenId();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
function _totalMinted() internal view returns (uint256) {
|
|
|
|
|
|
unchecked {
|
|
return _currentIndex - _startTokenId();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
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 override returns (uint256) {
|
|
if (owner == address(0)) revert BalanceQueryForZeroAddress();
|
|
return uint256(_addressData[owner].balance);
|
|
}
|
|
|
|
|
|
|
|
|
|
function _numberMinted(address owner) internal view returns (uint256) {
|
|
return uint256(_addressData[owner].numberMinted);
|
|
}
|
|
|
|
|
|
|
|
|
|
function _numberBurned(address owner) internal view returns (uint256) {
|
|
return uint256(_addressData[owner].numberBurned);
|
|
}
|
|
|
|
|
|
|
|
|
|
function _getAux(address owner) internal view returns (uint64) {
|
|
return _addressData[owner].aux;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function _setAux(address owner, uint64 aux) internal {
|
|
_addressData[owner].aux = aux;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function _ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
|
|
uint256 curr = tokenId;
|
|
|
|
unchecked {
|
|
if (_startTokenId() <= curr) if (curr < _currentIndex) {
|
|
TokenOwnership memory ownership = _ownerships[curr];
|
|
if (!ownership.burned) {
|
|
if (ownership.addr != address(0)) {
|
|
return ownership;
|
|
}
|
|
|
|
|
|
|
|
|
|
while (true) {
|
|
curr--;
|
|
ownership = _ownerships[curr];
|
|
if (ownership.addr != address(0)) {
|
|
return ownership;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
revert OwnerQueryForNonexistentToken();
|
|
}
|
|
|
|
|
|
|
|
|
|
function ownerOf(uint256 tokenId) public view override returns (address) {
|
|
return _ownershipOf(tokenId).addr;
|
|
}
|
|
|
|
|
|
|
|
|
|
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) {
|
|
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
|
|
|
|
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 = ERC721A.ownerOf(tokenId);
|
|
if (to == owner) revert ApprovalToCurrentOwner();
|
|
|
|
if (_msgSender() != owner) if(!isApprovedForAll(owner, _msgSender())) {
|
|
revert ApprovalCallerNotOwnerNorApproved();
|
|
}
|
|
|
|
_approve(to, tokenId, owner);
|
|
}
|
|
|
|
|
|
|
|
|
|
function getApproved(uint256 tokenId) public view override returns (address) {
|
|
if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();
|
|
|
|
return _tokenApprovals[tokenId];
|
|
}
|
|
|
|
|
|
|
|
|
|
function setApprovalForAll(address operator, bool approved) public virtual override {
|
|
if (operator == _msgSender()) revert ApproveToCaller();
|
|
|
|
_operatorApprovals[_msgSender()][operator] = approved;
|
|
emit ApprovalForAll(_msgSender(), operator, approved);
|
|
}
|
|
|
|
|
|
|
|
|
|
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
|
|
return _operatorApprovals[owner][operator];
|
|
}
|
|
|
|
|
|
|
|
|
|
function transferFrom(
|
|
address from,
|
|
address to,
|
|
uint256 tokenId
|
|
) public virtual override {
|
|
_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 {
|
|
_transfer(from, to, tokenId);
|
|
if (to.isContract()) if(!_checkContractOnERC721Received(from, to, tokenId, _data)) {
|
|
revert TransferToNonERC721ReceiverImplementer();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _exists(uint256 tokenId) internal view returns (bool) {
|
|
return _startTokenId() <= tokenId && tokenId < _currentIndex && !_ownerships[tokenId].burned;
|
|
}
|
|
|
|
|
|
|
|
|
|
function _safeMint(address to, uint256 quantity) internal {
|
|
_safeMint(to, quantity, '');
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _safeMint(
|
|
address to,
|
|
uint256 quantity,
|
|
bytes memory _data
|
|
) internal {
|
|
uint256 startTokenId = _currentIndex;
|
|
if (to == address(0)) revert MintToZeroAddress();
|
|
if (quantity == 0) revert MintZeroQuantity();
|
|
|
|
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
|
|
|
|
|
|
|
|
|
|
unchecked {
|
|
_addressData[to].balance += uint64(quantity);
|
|
_addressData[to].numberMinted += uint64(quantity);
|
|
|
|
_ownerships[startTokenId].addr = to;
|
|
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
|
|
|
|
uint256 updatedIndex = startTokenId;
|
|
uint256 end = updatedIndex + quantity;
|
|
|
|
if (to.isContract()) {
|
|
do {
|
|
emit Transfer(address(0), to, updatedIndex);
|
|
if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) {
|
|
revert TransferToNonERC721ReceiverImplementer();
|
|
}
|
|
} while (updatedIndex < end);
|
|
|
|
if (_currentIndex != startTokenId) revert();
|
|
} else {
|
|
do {
|
|
emit Transfer(address(0), to, updatedIndex++);
|
|
} while (updatedIndex < end);
|
|
}
|
|
_currentIndex = updatedIndex;
|
|
}
|
|
_afterTokenTransfers(address(0), to, startTokenId, quantity);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _mint(address to, uint256 quantity) internal {
|
|
uint256 startTokenId = _currentIndex;
|
|
if (to == address(0)) revert MintToZeroAddress();
|
|
if (quantity == 0) revert MintZeroQuantity();
|
|
|
|
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
|
|
|
|
|
|
|
|
|
|
unchecked {
|
|
_addressData[to].balance += uint64(quantity);
|
|
_addressData[to].numberMinted += uint64(quantity);
|
|
|
|
_ownerships[startTokenId].addr = to;
|
|
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
|
|
|
|
uint256 updatedIndex = startTokenId;
|
|
uint256 end = updatedIndex + quantity;
|
|
|
|
do {
|
|
emit Transfer(address(0), to, updatedIndex++);
|
|
} while (updatedIndex < end);
|
|
|
|
_currentIndex = updatedIndex;
|
|
}
|
|
_afterTokenTransfers(address(0), to, startTokenId, quantity);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _transfer(
|
|
address from,
|
|
address to,
|
|
uint256 tokenId
|
|
) private {
|
|
TokenOwnership memory prevOwnership = _ownershipOf(tokenId);
|
|
|
|
if (prevOwnership.addr != from) revert TransferFromIncorrectOwner();
|
|
|
|
bool isApprovedOrOwner = (_msgSender() == from ||
|
|
isApprovedForAll(from, _msgSender()) ||
|
|
getApproved(tokenId) == _msgSender());
|
|
|
|
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
|
|
if (to == address(0)) revert TransferToZeroAddress();
|
|
|
|
_beforeTokenTransfers(from, to, tokenId, 1);
|
|
|
|
|
|
_approve(address(0), tokenId, from);
|
|
|
|
|
|
|
|
|
|
unchecked {
|
|
_addressData[from].balance -= 1;
|
|
_addressData[to].balance += 1;
|
|
|
|
TokenOwnership storage currSlot = _ownerships[tokenId];
|
|
currSlot.addr = to;
|
|
currSlot.startTimestamp = uint64(block.timestamp);
|
|
|
|
|
|
|
|
uint256 nextTokenId = tokenId + 1;
|
|
TokenOwnership storage nextSlot = _ownerships[nextTokenId];
|
|
if (nextSlot.addr == address(0)) {
|
|
|
|
|
|
if (nextTokenId != _currentIndex) {
|
|
nextSlot.addr = from;
|
|
nextSlot.startTimestamp = prevOwnership.startTimestamp;
|
|
}
|
|
}
|
|
}
|
|
|
|
emit Transfer(from, to, tokenId);
|
|
_afterTokenTransfers(from, to, tokenId, 1);
|
|
}
|
|
|
|
|
|
|
|
|
|
function _burn(uint256 tokenId) internal virtual {
|
|
_burn(tokenId, false);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _burn(uint256 tokenId, bool approvalCheck) internal virtual {
|
|
TokenOwnership memory prevOwnership = _ownershipOf(tokenId);
|
|
|
|
address from = prevOwnership.addr;
|
|
|
|
if (approvalCheck) {
|
|
bool isApprovedOrOwner = (_msgSender() == from ||
|
|
isApprovedForAll(from, _msgSender()) ||
|
|
getApproved(tokenId) == _msgSender());
|
|
|
|
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
|
|
}
|
|
|
|
_beforeTokenTransfers(from, address(0), tokenId, 1);
|
|
|
|
|
|
_approve(address(0), tokenId, from);
|
|
|
|
|
|
|
|
|
|
unchecked {
|
|
AddressData storage addressData = _addressData[from];
|
|
addressData.balance -= 1;
|
|
addressData.numberBurned += 1;
|
|
|
|
|
|
TokenOwnership storage currSlot = _ownerships[tokenId];
|
|
currSlot.addr = from;
|
|
currSlot.startTimestamp = uint64(block.timestamp);
|
|
currSlot.burned = true;
|
|
|
|
|
|
|
|
uint256 nextTokenId = tokenId + 1;
|
|
TokenOwnership storage nextSlot = _ownerships[nextTokenId];
|
|
if (nextSlot.addr == address(0)) {
|
|
|
|
|
|
if (nextTokenId != _currentIndex) {
|
|
nextSlot.addr = from;
|
|
nextSlot.startTimestamp = prevOwnership.startTimestamp;
|
|
}
|
|
}
|
|
}
|
|
|
|
emit Transfer(from, address(0), tokenId);
|
|
_afterTokenTransfers(from, address(0), tokenId, 1);
|
|
|
|
|
|
unchecked {
|
|
_burnCounter++;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _approve(
|
|
address to,
|
|
uint256 tokenId,
|
|
address owner
|
|
) private {
|
|
_tokenApprovals[tokenId] = to;
|
|
emit Approval(owner, to, tokenId);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _checkContractOnERC721Received(
|
|
address from,
|
|
address to,
|
|
uint256 tokenId,
|
|
bytes memory _data
|
|
) private returns (bool) {
|
|
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
|
|
return retval == IERC721Receiver(to).onERC721Received.selector;
|
|
} catch (bytes memory reason) {
|
|
if (reason.length == 0) {
|
|
revert TransferToNonERC721ReceiverImplementer();
|
|
} else {
|
|
assembly {
|
|
revert(add(32, reason), mload(reason))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _beforeTokenTransfers(
|
|
address from,
|
|
address to,
|
|
uint256 startTokenId,
|
|
uint256 quantity
|
|
) internal virtual {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _afterTokenTransfers(
|
|
address from,
|
|
address to,
|
|
uint256 startTokenId,
|
|
uint256 quantity
|
|
) internal virtual {}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract contract Ownable is Context {
|
|
address private _owner;
|
|
|
|
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
_transferOwnership(_msgSender());
|
|
}
|
|
|
|
|
|
|
|
|
|
modifier onlyOwner() {
|
|
_checkOwner();
|
|
_;
|
|
}
|
|
|
|
|
|
|
|
|
|
function owner() public view virtual returns (address) {
|
|
return _owner;
|
|
}
|
|
|
|
|
|
|
|
|
|
function _checkOwner() internal view virtual {
|
|
require(owner() == _msgSender(), "Ownable: caller is not the owner");
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function renounceOwnership() public virtual onlyOwner {
|
|
_transferOwnership(address(0));
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function transferOwnership(address newOwner) public virtual onlyOwner {
|
|
require(newOwner != address(0), "Ownable: new owner is the zero address");
|
|
_transferOwnership(newOwner);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function _transferOwnership(address newOwner) internal virtual {
|
|
address oldOwner = _owner;
|
|
_owner = newOwner;
|
|
emit OwnershipTransferred(oldOwner, newOwner);
|
|
}
|
|
}
|
|
|
|
|
|
pragma solidity ^0.8.9;
|
|
|
|
abstract contract Operable is Context {
|
|
mapping(address => bool) _operators;
|
|
|
|
modifier onlyOperator() {
|
|
_checkOperatorRole(_msgSender());
|
|
_;
|
|
}
|
|
|
|
function isOperator(address _operator) public view returns (bool) {
|
|
return _operators[_operator];
|
|
}
|
|
|
|
function _grantOperatorRole(address _candidate) internal {
|
|
require(
|
|
!_operators[_candidate],
|
|
string(
|
|
abi.encodePacked(
|
|
"account ",
|
|
Strings.toHexString(uint160(_msgSender()), 20),
|
|
" is already has an operator role"
|
|
)
|
|
)
|
|
);
|
|
_operators[_candidate] = true;
|
|
}
|
|
|
|
function _revokeOperatorRole(address _candidate) internal {
|
|
_checkOperatorRole(_candidate);
|
|
delete _operators[_candidate];
|
|
}
|
|
|
|
function _checkOperatorRole(address _operator) internal view {
|
|
require(
|
|
_operators[_operator],
|
|
string(
|
|
abi.encodePacked(
|
|
"account ",
|
|
Strings.toHexString(uint160(_msgSender()), 20),
|
|
" is not an operator"
|
|
)
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
pragma solidity ^0.8.13;
|
|
|
|
interface IOperatorFilterRegistry {
|
|
function isOperatorAllowed(address registrant, address operator) external view returns (bool);
|
|
function register(address registrant) external;
|
|
function registerAndSubscribe(address registrant, address subscription) external;
|
|
function registerAndCopyEntries(address registrant, address registrantToCopy) external;
|
|
function unregister(address addr) external;
|
|
function updateOperator(address registrant, address operator, bool filtered) external;
|
|
function updateOperators(address registrant, address[] calldata operators, bool filtered) external;
|
|
function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;
|
|
function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;
|
|
function subscribe(address registrant, address registrantToSubscribe) external;
|
|
function unsubscribe(address registrant, bool copyExistingEntries) external;
|
|
function subscriptionOf(address addr) external returns (address registrant);
|
|
function subscribers(address registrant) external returns (address[] memory);
|
|
function subscriberAt(address registrant, uint256 index) external returns (address);
|
|
function copyEntriesOf(address registrant, address registrantToCopy) external;
|
|
function isOperatorFiltered(address registrant, address operator) external returns (bool);
|
|
function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);
|
|
function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);
|
|
function filteredOperators(address addr) external returns (address[] memory);
|
|
function filteredCodeHashes(address addr) external returns (bytes32[] memory);
|
|
function filteredOperatorAt(address registrant, uint256 index) external returns (address);
|
|
function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);
|
|
function isRegistered(address addr) external returns (bool);
|
|
function codeHashOf(address addr) external returns (bytes32);
|
|
}
|
|
|
|
pragma solidity ^0.8.13;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract contract OperatorFilterer {
|
|
error OperatorNotAllowed(address operator);
|
|
bool public operatorFilteringEnabled = true;
|
|
|
|
IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY =
|
|
IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);
|
|
|
|
constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {
|
|
|
|
|
|
|
|
if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {
|
|
if (subscribe) {
|
|
OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);
|
|
} else {
|
|
if (subscriptionOrRegistrantToCopy != address(0)) {
|
|
OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);
|
|
} else {
|
|
OPERATOR_FILTER_REGISTRY.register(address(this));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
modifier onlyAllowedOperator(address from) virtual {
|
|
|
|
if (address(OPERATOR_FILTER_REGISTRY).code.length > 0 && operatorFilteringEnabled) {
|
|
|
|
|
|
|
|
if (from == msg.sender) {
|
|
_;
|
|
return;
|
|
}
|
|
if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), msg.sender)) {
|
|
revert OperatorNotAllowed(msg.sender);
|
|
}
|
|
}
|
|
_;
|
|
}
|
|
|
|
modifier onlyAllowedOperatorApproval(address operator) virtual {
|
|
|
|
if (address(OPERATOR_FILTER_REGISTRY).code.length > 0 && operatorFilteringEnabled) {
|
|
if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {
|
|
revert OperatorNotAllowed(operator);
|
|
}
|
|
}
|
|
_;
|
|
}
|
|
}
|
|
|
|
|
|
pragma solidity ^0.8.13;
|
|
|
|
|
|
|
|
|
|
abstract contract DefaultOperatorFilterer is OperatorFilterer {
|
|
address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);
|
|
|
|
constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}
|
|
}
|
|
|
|
|
|
|
|
pragma solidity ^0.8.7;
|
|
|
|
|
|
|
|
contract NFTCOLORXMAS is Ownable, ERC721A, ReentrancyGuard, MerkleProof, ERC2981, DefaultOperatorFilterer, Operable {
|
|
|
|
uint256 public psMintPrice = 0.0111 ether;
|
|
uint256 public maxMintsPerPS = 5000;
|
|
uint256 public maxSupply = 5000;
|
|
address payable internal _withdrawWallet;
|
|
uint256 public maxMintsPerPsMint = 100;
|
|
|
|
|
|
string internal hiddenURI;
|
|
string internal _baseTokenURI;
|
|
string public _baseExtension = ".json";
|
|
|
|
|
|
bool public isWlSaleEnabled;
|
|
bool public isPublicSaleEnabled;
|
|
bool public revealed = false;
|
|
address public deployer;
|
|
|
|
|
|
mapping(address => uint256) internal _wlMinted;
|
|
mapping(address => uint256) internal _psMinted;
|
|
|
|
constructor (
|
|
address _royaltyReceiver,
|
|
uint96 _royaltyFraction
|
|
) ERC721A ("NFTCOLOR Xmas","NCX") {
|
|
deployer = msg.sender;
|
|
_withdrawWallet = payable(deployer);
|
|
_grantOperatorRole(msg.sender);
|
|
_setDefaultRoyalty(_royaltyReceiver,_royaltyFraction);
|
|
}
|
|
|
|
function _startTokenId() internal view virtual override returns (uint256) {
|
|
return 1;
|
|
}
|
|
|
|
function setDefaultRoyalty(address _receiver, uint96 _feeNumerator) external virtual onlyOperator {
|
|
_setDefaultRoyalty(_receiver, _feeNumerator);
|
|
}
|
|
|
|
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721A, ERC2981) returns (bool) {
|
|
return super.supportsInterface(interfaceId);
|
|
}
|
|
|
|
function contractURI() external view virtual returns (string memory) {
|
|
return _formatContractURI();
|
|
}
|
|
|
|
function _formatContractURI() internal view returns (string memory) {
|
|
(address receiver, uint256 royaltyFraction) = royaltyInfo(0,_feeDenominator());
|
|
return string(
|
|
abi.encodePacked(
|
|
"data:application/json;base64,",
|
|
Base64.encode(
|
|
bytes(
|
|
abi.encodePacked(
|
|
'{"seller_fee_basis_points":', Strings.toString(royaltyFraction),
|
|
', "fee_recipient":"', Strings.toHexString(uint256(uint160(receiver)), 20), '"}'
|
|
)
|
|
)
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
|
|
function setWithdrawWallet(address _owner) external virtual onlyOperator {
|
|
_withdrawWallet = payable(_owner);
|
|
}
|
|
|
|
function setDeployer(address _deployer) external virtual onlyOperator {
|
|
deployer = _deployer;
|
|
}
|
|
|
|
|
|
function setMaxSupply(uint256 _maxSupply) external virtual onlyOperator {
|
|
require(totalSupply() <= _maxSupply, "Lower than _currentIndex.");
|
|
maxSupply = _maxSupply;
|
|
}
|
|
|
|
function setPsPrice(uint256 newPrice) external virtual onlyOperator {
|
|
psMintPrice = newPrice;
|
|
}
|
|
|
|
|
|
function setReveal(bool newRevealStatus) external virtual onlyOperator {
|
|
revealed = newRevealStatus;
|
|
}
|
|
|
|
function _isRevealed() internal view virtual returns (bool){
|
|
return revealed;
|
|
}
|
|
|
|
|
|
function wlMinted(address _address) external view virtual returns (uint256){
|
|
return _wlMinted[_address];
|
|
}
|
|
function psMinted(address _address) external view virtual returns (uint256){
|
|
return _psMinted[_address];
|
|
}
|
|
|
|
function setPsMaxMints(uint256 _max) external virtual onlyOperator {
|
|
maxMintsPerPS = _max;
|
|
}
|
|
|
|
function setMaxMintsPerPsMint(uint256 _max) external virtual onlyOperator {
|
|
maxMintsPerPsMint = _max;
|
|
}
|
|
|
|
|
|
function setWhitelistSaleEnable(bool bool_) external virtual onlyOperator {
|
|
isWlSaleEnabled = bool_;
|
|
}
|
|
function setPublicSaleEnable(bool bool_) external virtual onlyOperator {
|
|
isPublicSaleEnabled = bool_;
|
|
}
|
|
|
|
|
|
function setWlMerkleRoot(bytes32 merkleRoot_) external virtual onlyOperator {
|
|
_setwlMerkleRoot(merkleRoot_);
|
|
}
|
|
|
|
|
|
function setHiddenURI(string memory uri_) external virtual onlyOperator {
|
|
hiddenURI = uri_;
|
|
}
|
|
|
|
|
|
function getCurrentIndex() external view virtual returns (uint256){
|
|
return _currentIndex;
|
|
}
|
|
|
|
|
|
function setBaseURI(string memory uri_) external virtual onlyOperator {
|
|
_baseTokenURI = uri_;
|
|
}
|
|
|
|
|
|
function setBaseExtension(string memory _newBaseExtension) external onlyOperator
|
|
{
|
|
_baseExtension = _newBaseExtension;
|
|
}
|
|
|
|
|
|
function _currentBaseURI() internal view returns (string memory){
|
|
return _baseTokenURI;
|
|
}
|
|
|
|
|
|
function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) {
|
|
require(_exists(_tokenId), "URI query for nonexistent token");
|
|
if(_isRevealed()){
|
|
return string(abi.encodePacked(_currentBaseURI(), Strings.toString(_tokenId), _baseExtension));
|
|
}
|
|
return hiddenURI;
|
|
}
|
|
|
|
|
|
function ownerMint(uint256 _amount, address _address) external virtual onlyOperator {
|
|
require((_amount + totalSupply()) <= (maxSupply), "No more NFTs");
|
|
_safeMint(_address, _amount);
|
|
}
|
|
|
|
|
|
|
|
function whitelistMint(uint256 _amount, uint256 wlcount, bytes32[] memory proof_) external payable virtual nonReentrant {
|
|
require(isWlSaleEnabled, "whitelistMint is Paused");
|
|
require(isWhitelisted(msg.sender, wlcount, proof_), "You are not whitelisted!");
|
|
require(wlcount > 0, "You have no WL!");
|
|
require(wlcount >= _amount, "whitelistMint: Over max mints per wallet");
|
|
require(wlcount >= _wlMinted[msg.sender] + _amount, "You have no whitelistMint left");
|
|
require((_amount + totalSupply()) <= (maxSupply), "No more NFTs");
|
|
_wlMinted[msg.sender] += _amount;
|
|
_safeMint(msg.sender, _amount);
|
|
}
|
|
|
|
|
|
function publicMint(uint256 _amount) external payable virtual nonReentrant {
|
|
require(isPublicSaleEnabled, "publicMint is Paused");
|
|
require(maxMintsPerPsMint >= _amount, "publicMint: Over max mints per one time.");
|
|
require(maxMintsPerPS >= _amount, "publicMint: Over max mints per wallet");
|
|
require(maxMintsPerPS >= _psMinted[msg.sender] + _amount, "You have no publicMint left");
|
|
require(msg.value == psMintPrice * _amount, "ETH value is not correct");
|
|
require((_amount + totalSupply()) <= (maxSupply), "No more NFTs");
|
|
_psMinted[msg.sender] += _amount;
|
|
_safeMint(msg.sender, _amount);
|
|
}
|
|
|
|
|
|
function burn(uint256 tokenId) external virtual {
|
|
_burn(tokenId, true);
|
|
}
|
|
|
|
|
|
function withdraw() external payable virtual onlyOperator nonReentrant{
|
|
|
|
|
|
|
|
bool os;
|
|
if(_withdrawWallet != address(0)){
|
|
(os, ) = payable(_withdrawWallet).call{value: address(this).balance}("");
|
|
}else{
|
|
(os, ) = payable(owner()).call{value: address(this).balance}("");
|
|
}
|
|
require(os);
|
|
|
|
}
|
|
|
|
|
|
|
|
function walletOfOwner(address _address) external view virtual returns (uint256[] memory) {
|
|
uint256 ownerTokenCount = balanceOf(_address);
|
|
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
|
|
|
|
uint256 tokenindex = 0;
|
|
for (uint256 i = _startTokenId(); i < _currentIndex; i++) {
|
|
if(_address == this.tryOwnerOf(i)) tokenIds[tokenindex++] = i;
|
|
}
|
|
return tokenIds;
|
|
}
|
|
|
|
|
|
function tryOwnerOf(uint256 tokenId) external view virtual returns (address) {
|
|
try this.ownerOf(tokenId) returns (address _address) {
|
|
return(_address);
|
|
} catch {
|
|
return (address(0));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function setOperatorFilteringEnabled(bool value) external onlyOperator {
|
|
operatorFilteringEnabled = value;
|
|
}
|
|
|
|
function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) {
|
|
super.setApprovalForAll(operator, approved);
|
|
}
|
|
|
|
function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {
|
|
super.approve(operator, tokenId);
|
|
}
|
|
|
|
function transferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) {
|
|
super.transferFrom(from, to, tokenId);
|
|
}
|
|
|
|
function safeTransferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) {
|
|
super.safeTransferFrom(from, to, tokenId);
|
|
}
|
|
|
|
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data)
|
|
public
|
|
override
|
|
onlyAllowedOperator(from)
|
|
{
|
|
super.safeTransferFrom(from, to, tokenId, data);
|
|
}
|
|
|
|
|
|
|
|
|
|
function grantOperatorRole(address _candidate) external onlyOwner {
|
|
_grantOperatorRole(_candidate);
|
|
}
|
|
|
|
function revokeOperatorRole(address _candidate) external onlyOwner {
|
|
_revokeOperatorRole(_candidate);
|
|
}
|
|
}
|
|
|