|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 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);
|
|
|
|
IOperatorFilterRegistry constant operatorFilterRegistry =
|
|
IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);
|
|
|
|
constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {
|
|
|
|
|
|
|
|
if (address(operatorFilterRegistry).code.length > 0) {
|
|
if (subscribe) {
|
|
operatorFilterRegistry.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);
|
|
} else {
|
|
if (subscriptionOrRegistrantToCopy != address(0)) {
|
|
operatorFilterRegistry.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);
|
|
} else {
|
|
operatorFilterRegistry.register(address(this));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
modifier onlyAllowedOperator(address from) virtual {
|
|
|
|
if (address(operatorFilterRegistry).code.length > 0) {
|
|
|
|
|
|
|
|
if (from == msg.sender) {
|
|
_;
|
|
return;
|
|
}
|
|
if (
|
|
!(
|
|
operatorFilterRegistry.isOperatorAllowed(address(this), msg.sender)
|
|
&& operatorFilterRegistry.isOperatorAllowed(address(this), from)
|
|
)
|
|
) {
|
|
revert OperatorNotAllowed(msg.sender);
|
|
}
|
|
}
|
|
_;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
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.4;
|
|
|
|
|
|
|
|
|
|
interface IERC721A {
|
|
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function totalSupply() external view returns (uint256);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function supportsInterface(bytes4 interfaceId) external view returns (bool);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 ERC721A__IERC721Receiver {
|
|
function onERC721Received(
|
|
address operator,
|
|
address from,
|
|
uint256 tokenId,
|
|
bytes calldata data
|
|
) external returns (bytes4);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contract ERC721A is IERC721A {
|
|
|
|
uint256 private constant BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1;
|
|
|
|
|
|
uint256 private constant BITPOS_NUMBER_MINTED = 64;
|
|
|
|
|
|
uint256 private constant BITPOS_NUMBER_BURNED = 128;
|
|
|
|
|
|
uint256 private constant BITPOS_AUX = 192;
|
|
|
|
|
|
uint256 private constant BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;
|
|
|
|
|
|
uint256 private constant BITPOS_START_TIMESTAMP = 160;
|
|
|
|
|
|
uint256 private constant BITMASK_BURNED = 1 << 224;
|
|
|
|
|
|
uint256 private constant BITPOS_NEXT_INITIALIZED = 225;
|
|
|
|
|
|
uint256 private constant BITMASK_NEXT_INITIALIZED = 1 << 225;
|
|
|
|
|
|
uint256 private _currentIndex;
|
|
|
|
|
|
uint256 private _burnCounter;
|
|
|
|
|
|
string private _name;
|
|
|
|
|
|
string private _symbol;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mapping(uint256 => uint256) private _packedOwnerships;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mapping(address => uint256) private _packedAddressData;
|
|
|
|
|
|
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 _nextTokenId() internal view returns (uint256) {
|
|
return _currentIndex;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function totalSupply() public view override returns (uint256) {
|
|
|
|
|
|
unchecked {
|
|
return _currentIndex - _burnCounter - _startTokenId();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
function _totalMinted() internal view returns (uint256) {
|
|
|
|
|
|
unchecked {
|
|
return _currentIndex - _startTokenId();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
function _totalBurned() internal view returns (uint256) {
|
|
return _burnCounter;
|
|
}
|
|
|
|
|
|
|
|
|
|
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
|
|
|
|
|
|
|
|
return
|
|
interfaceId == 0x01ffc9a7 ||
|
|
interfaceId == 0x80ac58cd ||
|
|
interfaceId == 0x5b5e139f;
|
|
}
|
|
|
|
|
|
|
|
|
|
function balanceOf(address owner) public view override returns (uint256) {
|
|
if (_addressToUint256(owner) == 0) revert BalanceQueryForZeroAddress();
|
|
return _packedAddressData[owner] & BITMASK_ADDRESS_DATA_ENTRY;
|
|
}
|
|
|
|
|
|
|
|
|
|
function _numberMinted(address owner) internal view returns (uint256) {
|
|
return (_packedAddressData[owner] >> BITPOS_NUMBER_MINTED) & BITMASK_ADDRESS_DATA_ENTRY;
|
|
}
|
|
|
|
|
|
|
|
|
|
function _numberBurned(address owner) internal view returns (uint256) {
|
|
return (_packedAddressData[owner] >> BITPOS_NUMBER_BURNED) & BITMASK_ADDRESS_DATA_ENTRY;
|
|
}
|
|
|
|
|
|
|
|
|
|
function _getAux(address owner) internal view returns (uint64) {
|
|
return uint64(_packedAddressData[owner] >> BITPOS_AUX);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function _setAux(address owner, uint64 aux) internal {
|
|
uint256 packed = _packedAddressData[owner];
|
|
uint256 auxCasted;
|
|
assembly {
|
|
auxCasted := aux
|
|
}
|
|
packed = (packed & BITMASK_AUX_COMPLEMENT) | (auxCasted << BITPOS_AUX);
|
|
_packedAddressData[owner] = packed;
|
|
}
|
|
|
|
/**
|
|
* Returns the packed ownership data of `tokenId`.
|
|
*/
|
|
function _packedOwnershipOf(uint256 tokenId) private view returns (uint256) {
|
|
uint256 curr = tokenId;
|
|
|
|
unchecked {
|
|
if (_startTokenId() <= curr)
|
|
if (curr < _currentIndex) {
|
|
uint256 packed = _packedOwnerships[curr];
|
|
// If not burned.
|
|
if (packed & BITMASK_BURNED == 0) {
|
|
// Invariant:
|
|
// There will always be an ownership that has an address and is not burned
|
|
// before an ownership that does not have an address and is not burned.
|
|
// Hence, curr will not underflow.
|
|
//
|
|
// We can directly compare the packed value.
|
|
// If the address is zero, packed is zero.
|
|
while (packed == 0) {
|
|
packed = _packedOwnerships[--curr];
|
|
}
|
|
return packed;
|
|
}
|
|
}
|
|
}
|
|
revert OwnerQueryForNonexistentToken();
|
|
}
|
|
|
|
/**
|
|
* Returns the unpacked `TokenOwnership` struct from `packed`.
|
|
*/
|
|
function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) {
|
|
ownership.addr = address(uint160(packed));
|
|
ownership.startTimestamp = uint64(packed >> BITPOS_START_TIMESTAMP);
|
|
ownership.burned = packed & BITMASK_BURNED != 0;
|
|
}
|
|
|
|
/**
|
|
* Returns the unpacked `TokenOwnership` struct at `index`.
|
|
*/
|
|
function _ownershipAt(uint256 index) internal view returns (TokenOwnership memory) {
|
|
return _unpackedOwnership(_packedOwnerships[index]);
|
|
}
|
|
|
|
/**
|
|
* @dev Initializes the ownership slot minted at `index` for efficiency purposes.
|
|
*/
|
|
function _initializeOwnershipAt(uint256 index) internal {
|
|
if (_packedOwnerships[index] == 0) {
|
|
_packedOwnerships[index] = _packedOwnershipOf(index);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Gas spent here starts off proportional to the maximum mint batch size.
|
|
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
|
|
*/
|
|
function _ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
|
|
return _unpackedOwnership(_packedOwnershipOf(tokenId));
|
|
}
|
|
|
|
/**
|
|
* @dev See {IERC721-ownerOf}.
|
|
*/
|
|
function ownerOf(uint256 tokenId) public view override returns (address) {
|
|
return address(uint160(_packedOwnershipOf(tokenId)));
|
|
}
|
|
|
|
/**
|
|
* @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) {
|
|
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
|
|
|
|
string memory baseURI = _baseURI();
|
|
return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : '';
|
|
}
|
|
|
|
/**
|
|
* @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 overriden in child contracts.
|
|
*/
|
|
function _baseURI() internal view virtual returns (string memory) {
|
|
return '';
|
|
}
|
|
|
|
/**
|
|
* @dev Casts the address to uint256 without masking.
|
|
*/
|
|
function _addressToUint256(address value) private pure returns (uint256 result) {
|
|
assembly {
|
|
result := value
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @dev Casts the boolean to uint256 without branching.
|
|
*/
|
|
function _boolToUint256(bool value) private pure returns (uint256 result) {
|
|
assembly {
|
|
result := value
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @dev See {IERC721-approve}.
|
|
*/
|
|
function approve(address to, uint256 tokenId) public override {
|
|
address owner = address(uint160(_packedOwnershipOf(tokenId)));
|
|
if (to == owner) revert ApprovalToCurrentOwner();
|
|
|
|
if (_msgSenderERC721A() != owner)
|
|
if (!isApprovedForAll(owner, _msgSenderERC721A())) {
|
|
revert ApprovalCallerNotOwnerNorApproved();
|
|
}
|
|
|
|
_tokenApprovals[tokenId] = to;
|
|
emit Approval(owner, to, tokenId);
|
|
}
|
|
|
|
/**
|
|
* @dev See {IERC721-getApproved}.
|
|
*/
|
|
function getApproved(uint256 tokenId) public view override returns (address) {
|
|
if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();
|
|
|
|
return _tokenApprovals[tokenId];
|
|
}
|
|
|
|
/**
|
|
* @dev See {IERC721-setApprovalForAll}.
|
|
*/
|
|
function setApprovalForAll(address operator, bool approved) public virtual override {
|
|
if (operator == _msgSenderERC721A()) revert ApproveToCaller();
|
|
|
|
_operatorApprovals[_msgSenderERC721A()][operator] = approved;
|
|
emit ApprovalForAll(_msgSenderERC721A(), 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 {
|
|
_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 {
|
|
_transfer(from, to, tokenId);
|
|
if (to.code.length != 0)
|
|
if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {
|
|
revert TransferToNonERC721ReceiverImplementer();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @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`),
|
|
*/
|
|
function _exists(uint256 tokenId) internal view returns (bool) {
|
|
return
|
|
_startTokenId() <= tokenId &&
|
|
tokenId < _currentIndex && // If within bounds,
|
|
_packedOwnerships[tokenId] & BITMASK_BURNED == 0; // and not burned.
|
|
}
|
|
|
|
/**
|
|
* @dev Equivalent to `_safeMint(to, quantity, '')`.
|
|
*/
|
|
function _safeMint(address to, uint256 quantity) internal {
|
|
_safeMint(to, quantity, '');
|
|
}
|
|
|
|
/**
|
|
* @dev Safely mints `quantity` tokens and transfers them to `to`.
|
|
*
|
|
* Requirements:
|
|
*
|
|
* - If `to` refers to a smart contract, it must implement
|
|
* {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
|
|
* - `quantity` must be greater than 0.
|
|
*
|
|
* Emits a {Transfer} event.
|
|
*/
|
|
function _safeMint(
|
|
address to,
|
|
uint256 quantity,
|
|
bytes memory _data
|
|
) internal {
|
|
uint256 startTokenId = _currentIndex;
|
|
if (_addressToUint256(to) == 0) revert MintToZeroAddress();
|
|
if (quantity == 0) revert MintZeroQuantity();
|
|
|
|
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
|
|
|
|
// Overflows are incredibly unrealistic.
|
|
// balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1
|
|
// updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1
|
|
unchecked {
|
|
// Updates:
|
|
// - `balance += quantity`.
|
|
// - `numberMinted += quantity`.
|
|
//
|
|
// We can directly add to the balance and number minted.
|
|
_packedAddressData[to] += quantity * ((1 << BITPOS_NUMBER_MINTED) | 1);
|
|
|
|
// Updates:
|
|
// - `address` to the owner.
|
|
// - `startTimestamp` to the timestamp of minting.
|
|
// - `burned` to `false`.
|
|
// - `nextInitialized` to `quantity == 1`.
|
|
_packedOwnerships[startTokenId] =
|
|
_addressToUint256(to) |
|
|
(block.timestamp << BITPOS_START_TIMESTAMP) |
|
|
(_boolToUint256(quantity == 1) << BITPOS_NEXT_INITIALIZED);
|
|
|
|
uint256 updatedIndex = startTokenId;
|
|
uint256 end = updatedIndex + quantity;
|
|
|
|
if (to.code.length != 0) {
|
|
do {
|
|
emit Transfer(address(0), to, updatedIndex);
|
|
if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) {
|
|
revert TransferToNonERC721ReceiverImplementer();
|
|
}
|
|
} while (updatedIndex < end);
|
|
// Reentrancy protection
|
|
if (_currentIndex != startTokenId) revert();
|
|
} else {
|
|
do {
|
|
emit Transfer(address(0), to, updatedIndex++);
|
|
} while (updatedIndex < end);
|
|
}
|
|
_currentIndex = updatedIndex;
|
|
}
|
|
_afterTokenTransfers(address(0), to, startTokenId, quantity);
|
|
}
|
|
|
|
/**
|
|
* @dev Mints `quantity` tokens and transfers them to `to`.
|
|
*
|
|
* Requirements:
|
|
*
|
|
* - `to` cannot be the zero address.
|
|
* - `quantity` must be greater than 0.
|
|
*
|
|
* Emits a {Transfer} event.
|
|
*/
|
|
function _mint(address to, uint256 quantity) internal {
|
|
uint256 startTokenId = _currentIndex;
|
|
if (_addressToUint256(to) == 0) revert MintToZeroAddress();
|
|
if (quantity == 0) revert MintZeroQuantity();
|
|
|
|
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
|
|
|
|
// Overflows are incredibly unrealistic.
|
|
// balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1
|
|
// updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1
|
|
unchecked {
|
|
// Updates:
|
|
// - `balance += quantity`.
|
|
// - `numberMinted += quantity`.
|
|
//
|
|
// We can directly add to the balance and number minted.
|
|
_packedAddressData[to] += quantity * ((1 << BITPOS_NUMBER_MINTED) | 1);
|
|
|
|
// Updates:
|
|
// - `address` to the owner.
|
|
// - `startTimestamp` to the timestamp of minting.
|
|
// - `burned` to `false`.
|
|
// - `nextInitialized` to `quantity == 1`.
|
|
_packedOwnerships[startTokenId] =
|
|
_addressToUint256(to) |
|
|
(block.timestamp << BITPOS_START_TIMESTAMP) |
|
|
(_boolToUint256(quantity == 1) << BITPOS_NEXT_INITIALIZED);
|
|
|
|
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);
|
|
}
|
|
|
|
/**
|
|
* @dev Transfers `tokenId` from `from` to `to`.
|
|
*
|
|
* 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
|
|
) private {
|
|
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
|
|
|
|
if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner();
|
|
|
|
address approvedAddress = _tokenApprovals[tokenId];
|
|
|
|
bool isApprovedOrOwner = (_msgSenderERC721A() == from ||
|
|
isApprovedForAll(from, _msgSenderERC721A()) ||
|
|
approvedAddress == _msgSenderERC721A());
|
|
|
|
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
|
|
if (_addressToUint256(to) == 0) revert TransferToZeroAddress();
|
|
|
|
_beforeTokenTransfers(from, to, tokenId, 1);
|
|
|
|
// Clear approvals from the previous owner.
|
|
if (_addressToUint256(approvedAddress) != 0) {
|
|
delete _tokenApprovals[tokenId];
|
|
}
|
|
|
|
// Underflow of the sender's balance is impossible because we check for
|
|
// ownership above and the recipient's balance can't realistically overflow.
|
|
// Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.
|
|
unchecked {
|
|
// We can directly increment and decrement the balances.
|
|
--_packedAddressData[from]; // Updates: `balance -= 1`.
|
|
++_packedAddressData[to]; // Updates: `balance += 1`.
|
|
|
|
// Updates:
|
|
// - `address` to the next owner.
|
|
// - `startTimestamp` to the timestamp of transfering.
|
|
// - `burned` to `false`.
|
|
// - `nextInitialized` to `true`.
|
|
_packedOwnerships[tokenId] =
|
|
_addressToUint256(to) |
|
|
(block.timestamp << BITPOS_START_TIMESTAMP) |
|
|
BITMASK_NEXT_INITIALIZED;
|
|
|
|
// If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
|
|
if (prevOwnershipPacked & BITMASK_NEXT_INITIALIZED == 0) {
|
|
uint256 nextTokenId = tokenId + 1;
|
|
// If the next slot's address is zero and not burned (i.e. packed value is zero).
|
|
if (_packedOwnerships[nextTokenId] == 0) {
|
|
// If the next slot is within bounds.
|
|
if (nextTokenId != _currentIndex) {
|
|
// Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
|
|
_packedOwnerships[nextTokenId] = prevOwnershipPacked;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
emit Transfer(from, to, tokenId);
|
|
_afterTokenTransfers(from, to, tokenId, 1);
|
|
}
|
|
|
|
/**
|
|
* @dev Equivalent to `_burn(tokenId, false)`.
|
|
*/
|
|
function _burn(uint256 tokenId) internal virtual {
|
|
_burn(tokenId, false);
|
|
}
|
|
|
|
/**
|
|
* @dev Destroys `tokenId`.
|
|
* The approval is cleared when the token is burned.
|
|
*
|
|
* Requirements:
|
|
*
|
|
* - `tokenId` must exist.
|
|
*
|
|
* Emits a {Transfer} event.
|
|
*/
|
|
function _burn(uint256 tokenId, bool approvalCheck) internal virtual {
|
|
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
|
|
|
|
address from = address(uint160(prevOwnershipPacked));
|
|
address approvedAddress = _tokenApprovals[tokenId];
|
|
|
|
if (approvalCheck) {
|
|
bool isApprovedOrOwner = (_msgSenderERC721A() == from ||
|
|
isApprovedForAll(from, _msgSenderERC721A()) ||
|
|
approvedAddress == _msgSenderERC721A());
|
|
|
|
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
|
|
}
|
|
|
|
_beforeTokenTransfers(from, address(0), tokenId, 1);
|
|
|
|
// Clear approvals from the previous owner.
|
|
if (_addressToUint256(approvedAddress) != 0) {
|
|
delete _tokenApprovals[tokenId];
|
|
}
|
|
|
|
// Underflow of the sender's balance is impossible because we check for
|
|
// ownership above and the recipient's balance can't realistically overflow.
|
|
// Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.
|
|
unchecked {
|
|
// Updates:
|
|
// - `balance -= 1`.
|
|
// - `numberBurned += 1`.
|
|
//
|
|
// We can directly decrement the balance, and increment the number burned.
|
|
// This is equivalent to `packed -= 1; packed += 1 << BITPOS_NUMBER_BURNED;`.
|
|
_packedAddressData[from] += (1 << BITPOS_NUMBER_BURNED) - 1;
|
|
|
|
// Updates:
|
|
// - `address` to the last owner.
|
|
// - `startTimestamp` to the timestamp of burning.
|
|
// - `burned` to `true`.
|
|
// - `nextInitialized` to `true`.
|
|
_packedOwnerships[tokenId] =
|
|
_addressToUint256(from) |
|
|
(block.timestamp << BITPOS_START_TIMESTAMP) |
|
|
BITMASK_BURNED |
|
|
BITMASK_NEXT_INITIALIZED;
|
|
|
|
// If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
|
|
if (prevOwnershipPacked & BITMASK_NEXT_INITIALIZED == 0) {
|
|
uint256 nextTokenId = tokenId + 1;
|
|
// If the next slot's address is zero and not burned (i.e. packed value is zero).
|
|
if (_packedOwnerships[nextTokenId] == 0) {
|
|
// If the next slot is within bounds.
|
|
if (nextTokenId != _currentIndex) {
|
|
// Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
|
|
_packedOwnerships[nextTokenId] = prevOwnershipPacked;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
emit Transfer(from, address(0), tokenId);
|
|
_afterTokenTransfers(from, address(0), tokenId, 1);
|
|
|
|
// Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
|
|
unchecked {
|
|
_burnCounter++;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target 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 _checkContractOnERC721Received(
|
|
address from,
|
|
address to,
|
|
uint256 tokenId,
|
|
bytes memory _data
|
|
) private returns (bool) {
|
|
try ERC721A__IERC721Receiver(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (
|
|
bytes4 retval
|
|
) {
|
|
return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector;
|
|
} catch (bytes memory reason) {
|
|
if (reason.length == 0) {
|
|
revert TransferToNonERC721ReceiverImplementer();
|
|
} else {
|
|
assembly {
|
|
revert(add(32, reason), mload(reason))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
|
|
* And also called before burning one token.
|
|
*
|
|
* startTokenId - the first token id to be transferred
|
|
* quantity - the amount to be transferred
|
|
*
|
|
* 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, `tokenId` will be burned by `from`.
|
|
* - `from` and `to` are never both zero.
|
|
*/
|
|
function _beforeTokenTransfers(
|
|
address from,
|
|
address to,
|
|
uint256 startTokenId,
|
|
uint256 quantity
|
|
) internal virtual {}
|
|
|
|
/**
|
|
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
|
|
* minting.
|
|
* And also called after one token has been burned.
|
|
*
|
|
* startTokenId - the first token id to be transferred
|
|
* quantity - the amount to be transferred
|
|
*
|
|
* Calling conditions:
|
|
*
|
|
* - When `from` and `to` are both non-zero, `from`'s `tokenId` has been
|
|
* transferred to `to`.
|
|
* - When `from` is zero, `tokenId` has been minted for `to`.
|
|
* - When `to` is zero, `tokenId` has been burned by `from`.
|
|
* - `from` and `to` are never both zero.
|
|
*/
|
|
function _afterTokenTransfers(
|
|
address from,
|
|
address to,
|
|
uint256 startTokenId,
|
|
uint256 quantity
|
|
) internal virtual {}
|
|
|
|
/**
|
|
* @dev Returns the message sender (defaults to `msg.sender`).
|
|
*
|
|
* If you are writing GSN compatible contracts, you need to override this function.
|
|
*/
|
|
function _msgSenderERC721A() internal view virtual returns (address) {
|
|
return msg.sender;
|
|
}
|
|
|
|
/**
|
|
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
|
|
*/
|
|
function _toString(uint256 value) internal pure returns (string memory ptr) {
|
|
assembly {
|
|
// The maximum value of a uint256 contains 78 digits (1 byte per digit),
|
|
// but we allocate 128 bytes to keep the free memory pointer 32-byte word aliged.
|
|
// We will need 1 32-byte word to store the length,
|
|
// and 3 32-byte words to store a maximum of 78 digits. Total: 32 + 3 * 32 = 128.
|
|
ptr := add(mload(0x40), 128)
|
|
// Update the free memory pointer to allocate.
|
|
mstore(0x40, ptr)
|
|
|
|
// Cache the end of the memory to calculate the length later.
|
|
let end := ptr
|
|
|
|
// We write the string from the rightmost digit to the leftmost digit.
|
|
// The following is essentially a do-while loop that also handles the zero case.
|
|
// Costs a bit more than early returning for the zero case,
|
|
// but cheaper in terms of deployment and overall runtime costs.
|
|
for {
|
|
// Initialize and perform the first pass without check.
|
|
let temp := value
|
|
// Move the pointer 1 byte leftwards to point to an empty character slot.
|
|
ptr := sub(ptr, 1)
|
|
// Write the character to the pointer. 48 is the ASCII index of '0'.
|
|
mstore8(ptr, add(48, mod(temp, 10)))
|
|
temp := div(temp, 10)
|
|
} temp {
|
|
// Keep dividing `temp` until zero.
|
|
temp := div(temp, 10)
|
|
} { // Body of the for loop.
|
|
ptr := sub(ptr, 1)
|
|
mstore8(ptr, add(48, mod(temp, 10)))
|
|
}
|
|
|
|
let length := sub(end, ptr)
|
|
// Move the pointer 32 bytes leftwards to make room for the length.
|
|
ptr := sub(ptr, 32)
|
|
// Store the length.
|
|
mstore(ptr, length)
|
|
}
|
|
}
|
|
}
|
|
// File: @openzeppelin/contracts/utils/Strings.sol
|
|
|
|
|
|
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
/**
|
|
* @dev String operations.
|
|
*/
|
|
library Strings {
|
|
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
|
|
|
|
/**
|
|
* @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);
|
|
}
|
|
}
|
|
|
|
// File: @openzeppelin/contracts/utils/Context.sol
|
|
|
|
|
|
// 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;
|
|
}
|
|
}
|
|
|
|
// File: @openzeppelin/contracts/access/Ownable.sol
|
|
|
|
|
|
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
|
|
/**
|
|
* @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 Returns the address of the current owner.
|
|
*/
|
|
function owner() public view virtual returns (address) {
|
|
return _owner;
|
|
}
|
|
|
|
/**
|
|
* @dev Throws if called by any account other than the owner.
|
|
*/
|
|
modifier onlyOwner() {
|
|
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);
|
|
}
|
|
}
|
|
|
|
// File: @openzeppelin/contracts/utils/cryptography/MerkleProof.sol
|
|
|
|
|
|
// OpenZeppelin Contracts (last updated v4.6.0) (utils/cryptography/MerkleProof.sol)
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
/**
|
|
* @dev These functions deal with verification of Merkle Trees proofs.
|
|
*
|
|
* The proofs can be generated using the JavaScript library
|
|
* https://github.com/miguelmota/merkletreejs[merkletreejs].
|
|
* Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
|
|
*
|
|
* See `test/utils/cryptography/MerkleProof.test.js` for some examples.
|
|
*
|
|
* WARNING: You should avoid using leaf values that are 64 bytes long prior to
|
|
* hashing, or use a hash function other than keccak256 for hashing leaves.
|
|
* This is because the concatenation of a sorted pair of internal nodes in
|
|
* the merkle tree could be reinterpreted as a leaf value.
|
|
*/
|
|
library MerkleProof {
|
|
/**
|
|
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
|
|
* defined by `root`. For this, a `proof` must be provided, containing
|
|
* sibling hashes on the branch from the leaf to the root of the tree. Each
|
|
* pair of leaves and each pair of pre-images are assumed to be sorted.
|
|
*/
|
|
function verify(
|
|
bytes32[] memory proof,
|
|
bytes32 root,
|
|
bytes32 leaf
|
|
) internal pure returns (bool) {
|
|
return processProof(proof, leaf) == root;
|
|
}
|
|
|
|
/**
|
|
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
|
|
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
|
|
* hash matches the root of the tree. When processing the proof, the pairs
|
|
* of leafs & pre-images are assumed to be sorted.
|
|
*
|
|
* _Available since v4.4._
|
|
*/
|
|
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
|
|
bytes32 computedHash = leaf;
|
|
for (uint256 i = 0; i < proof.length; i++) {
|
|
bytes32 proofElement = proof[i];
|
|
if (computedHash <= proofElement) {
|
|
// Hash(current computed hash + current element of the proof)
|
|
computedHash = _efficientHash(computedHash, proofElement);
|
|
} else {
|
|
// Hash(current element of the proof + current computed hash)
|
|
computedHash = _efficientHash(proofElement, computedHash);
|
|
}
|
|
}
|
|
return computedHash;
|
|
}
|
|
|
|
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
|
|
assembly {
|
|
mstore(0x00, a)
|
|
mstore(0x20, b)
|
|
value := keccak256(0x00, 0x40)
|
|
}
|
|
}
|
|
}
|
|
|
|
// File: contracts/ReMyth.sol
|
|
|
|
|
|
pragma solidity ^0.8.13;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contract MOCAVERSE is ERC721A, Ownable, DefaultOperatorFilterer {
|
|
|
|
using Strings for uint;
|
|
|
|
enum Step {
|
|
StandBy,
|
|
WhitelistSale,
|
|
PublicSale,
|
|
SoldOut,
|
|
Reveal
|
|
}
|
|
|
|
Step public step;
|
|
|
|
string public baseURI;
|
|
string public notRevealedURI;
|
|
|
|
uint public MAX_SUPPLY = 111;
|
|
uint public MAX_TEAM = 2222;
|
|
uint public MAX_TX = 30;
|
|
|
|
bool private isRevealed = false;
|
|
|
|
uint public wl_price = 0 ether;
|
|
uint public public_price = 0.002 ether;
|
|
|
|
uint public saleStartTime = 1649298400;
|
|
|
|
bytes32 public merkleRoot;
|
|
|
|
constructor(string memory _baseURI, bytes32 _merkleRoot) ERC721A("Mocaverse", "MOCAVERSE")
|
|
{
|
|
baseURI = _baseURI;
|
|
merkleRoot = _merkleRoot;
|
|
}
|
|
|
|
modifier isNotContract() {
|
|
require(tx.origin == msg.sender, "Reentrancy Guard is watching");
|
|
_;
|
|
}
|
|
|
|
function getStep() public view returns(Step actualStep) {
|
|
if(block.timestamp < saleStartTime) {
|
|
return Step.StandBy;
|
|
}
|
|
if(block.timestamp >= saleStartTime
|
|
&&block.timestamp < saleStartTime + 30 minutes) {
|
|
return Step.WhitelistSale;
|
|
}
|
|
if(block.timestamp >= saleStartTime + 30 minutes) {
|
|
return Step.PublicSale;
|
|
}
|
|
}
|
|
|
|
function TeamMint(address _to, uint _quantity) external payable onlyOwner {
|
|
require(totalSupply() + _quantity <= MAX_TEAM, "NFT can't be minted anymore");
|
|
require(totalSupply() + _quantity <= MAX_SUPPLY, "NFT can't be minted anymore");
|
|
_safeMint(_to, _quantity);
|
|
}
|
|
|
|
function whitelistMint(address _account, uint _quantity, bytes32[] calldata _proof) external payable isNotContract {
|
|
require(getStep() == Step.WhitelistSale, "Whitelist Mint is not activated");
|
|
require(isWhiteListed(msg.sender, _proof), "Not whitelisted");
|
|
require(totalSupply() + _quantity <= MAX_SUPPLY, "NFT can't be minted anymore");
|
|
require(_quantity <= MAX_TX, "Exceeded Max per TX");
|
|
require(msg.value >= wl_price * _quantity, "Not enought funds");
|
|
_safeMint(_account, _quantity);
|
|
}
|
|
|
|
function PublicMint(address _account, uint _quantity) external payable isNotContract {
|
|
require(getStep() == Step.PublicSale, "Public Mint is not activated");
|
|
require(totalSupply() + _quantity <= MAX_SUPPLY, "NFT can't be mint anymore");
|
|
require(_quantity <= MAX_TX, "Exceeded Max per TX");
|
|
require(msg.value >= public_price * _quantity, "Not enought funds");
|
|
_safeMint(_account, _quantity);
|
|
}
|
|
|
|
function setBaseUri(string memory _newBaseURI) external onlyOwner {
|
|
baseURI = _newBaseURI;
|
|
}
|
|
|
|
function setSaleStartTime(uint _newSaleStartTime) external onlyOwner {
|
|
saleStartTime = _newSaleStartTime;
|
|
}
|
|
|
|
function setMaxSupply(uint _newMAX_SUPPLY) external onlyOwner {
|
|
MAX_SUPPLY = _newMAX_SUPPLY;
|
|
}
|
|
|
|
function revealCollection() external onlyOwner {
|
|
isRevealed = true;
|
|
}
|
|
|
|
function tokenURI(uint _tokenId) public view virtual override returns (string memory) {
|
|
require(_exists(_tokenId), "URI query for nonexistent token");
|
|
if(isRevealed == true) {
|
|
return string(abi.encodePacked(baseURI, _tokenId.toString(), ".json"));
|
|
}
|
|
else {
|
|
return string(abi.encodePacked(baseURI, notRevealedURI));
|
|
}
|
|
}
|
|
|
|
function setMerkleRoot(bytes32 _merkleRoot) external onlyOwner {
|
|
merkleRoot = _merkleRoot;
|
|
}
|
|
|
|
function isWhiteListed(address _account, bytes32[] calldata _proof) internal view returns(bool) {
|
|
return _verify(leaf(_account), _proof);
|
|
}
|
|
|
|
function leaf(address _account) internal pure returns(bytes32) {
|
|
return keccak256(abi.encodePacked(_account));
|
|
}
|
|
|
|
function _verify(bytes32 _leaf, bytes32[] memory _proof) internal view returns(bool) {
|
|
return MerkleProof.verify(_proof, merkleRoot, _leaf);
|
|
}
|
|
|
|
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 Refund(uint amount) public onlyOwner {
|
|
payable(msg.sender).transfer(amount);
|
|
}
|
|
} |