文件 1 的 15:Address.sol
pragma solidity ^0.8.1;
library Address {
function isContract(address account) internal view returns (bool) {
return account.code.length > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
文件 2 的 15:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 3 的 15:Counters.sol
pragma solidity ^0.8.0;
library Counters {
struct Counter {
uint256 _value;
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}
文件 4 的 15:ERC165.sol
pragma solidity ^0.8.0;
import "./IERC165.sol";
abstract contract ERC165 is IERC165 {
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
文件 5 的 15:ERC721.sol
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
string private _name;
string private _symbol;
mapping(uint256 => address) private _owners;
mapping(address => uint256) private _balances;
mapping(uint256 => address) private _tokenApprovals;
mapping(address => mapping(address => bool)) private _operatorApprovals;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
function _baseURI() internal view virtual returns (string memory) {
return "";
}
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId);
}
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId);
}
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId);
}
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
文件 6 的 15:HyperLoot.sol
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/interfaces/IERC2981.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
interface LootInterface {
function ownerOf(uint256 tokenId) external view returns (address owner);
}
interface MLootInterface {
function ownerOf(uint256 tokenId) external view returns (address owner);
}
interface GAInterface {
function ownerOf(uint256 tokenId) external view returns (address owner);
function getWeapon(uint256 tokenId) external view returns (string memory);
function getChest(uint256 tokenId) external view returns (string memory);
function getHead(uint256 tokenId) external view returns (string memory);
function getWaist(uint256 tokenId) external view returns (string memory);
function getFoot(uint256 tokenId) external view returns (string memory);
function getHand(uint256 tokenId) external view returns (string memory);
function getNeck(uint256 tokenId) external view returns (string memory);
function getRing(uint256 tokenId) external view returns (string memory);
}
contract HyperLoot is ERC721, IERC2981, ReentrancyGuard, Ownable{
using Counters for Counters.Counter;
uint256 public constant TOTAL_SUPPLY = 20000;
uint256 public constant MINT_PRICE = 0.05 ether;
uint256 public royaltyPercentage;
address public royaltyAddress;
bool public isPresaleActive = false;
bool public isPublicSaleActive = false;
bool public isLootPublicSaleActive = false;
bool private _isSpecialSetMinted = false;
string private _baseTokenURI;
bytes32 public hyperlistMerkleRoot;
uint16 private constant _lootType = 0;
uint16 private constant _mlootType = 1;
uint16 private constant _gaType = 2;
uint16 private constant _supplyLoot = 7776;
uint16 private constant _supplyGiveaway = 224;
uint16 private constant _supplyGA = 400;
uint16 private constant _supplySpecialSet = 7;
uint16 private constant _supplyMLoot = 11593;
uint16 private _tokenIdStartMLoot = 8001;
uint16 private _tokenIdStartGA = 19594;
uint16 private _tokenIdStartSpecialSet = 19994;
Counters.Counter private _countTokenLoot;
Counters.Counter private _countTokenMLoot;
Counters.Counter private _countTokenGA;
mapping(address => bool) private _hyperlist;
mapping(address => uint256) private _giveawayList;
mapping(address => bool) private _claimedHyperlist;
mapping(uint256 => bool) private _claimedMLoot;
mapping(uint256 => bool) private _claimedGA;
address private lootAddress = 0xFF9C1b15B16263C61d017ee9F65C50e4AE0113D7;
LootInterface lootContract = LootInterface(lootAddress);
address private mlootAddress = 0x1dfe7Ca09e99d10835Bf73044a23B73Fc20623DF;
MLootInterface mlootContract = MLootInterface(mlootAddress);
address private gaAddress = 0x8dB687aCEb92c66f013e1D614137238Cc698fEdb;
GAInterface gaContract = GAInterface(gaAddress);
event HyperLootMinted(address indexed to, uint256 indexed id, uint256 fromTokenType, uint256 fromTokenId, uint8[4] traits);
constructor() ERC721("HyperLoot", "HLOOT") {}
modifier presaleActive() {
require(isPresaleActive, "PRESALE_NOT_ACTIVE");
_;
}
modifier publicSaleActive() {
require(isPublicSaleActive, "PUBLIC_SALE_NOT_ACTIVE");
_;
}
modifier lootPublicSaleActive() {
require(isLootPublicSaleActive, "LOOT_PUBLIC_SALE_NOT_ACTIVE");
_;
}
modifier isPaymentValid(uint256 amount) {
require(amount <= 20, "OVER_20_MAX_LIMIT");
require((MINT_PRICE * amount) <= msg.value, "WRONG_ETHER_VALUE");
_;
}
modifier isGiveawaySupplyAvailable(uint256 lootId) {
require(lootId > 7777 && lootId < 8001, "TOKEN_ID_OUT_OF_RANGE");
require(_giveawayList[msg.sender] == lootId, "ADDRESS_NOT_ELIGIBLE");
_;
}
function mintPresale(uint256[] calldata bagIds, uint16[] calldata bagType, uint8[] calldata traits, bytes32[] calldata merkleProof) external payable
nonReentrant
presaleActive
isPaymentValid(bagIds.length) {
_checkTraitsCount(bagIds.length, bagType.length, traits.length);
for (uint8 index = 0; index < bagIds.length; index++) {
uint8 face = traits[index * 4];
uint8 eyes = traits[index * 4 + 1];
uint8 bg = traits[index * 4 + 2];
uint8 left = traits[index * 4 + 3];
_checkTraitsValid(face, eyes, bg, left);
uint bagId = bagIds[index];
if (bagType[index] == _lootType) {
_checkLootOwner(bagId);
_mintHyperLootEvent(msg.sender, bagId, _lootType, bagId, face, eyes, bg, left);
_countTokenLoot.increment();
} else if (bagType[index] == _mlootType) {
_checkMerkleProof(merkleProof, hyperlistMerkleRoot, msg.sender);
_checkHyperlistClaimed(msg.sender);
_checkMLootOwner(bagId);
_mintHyperLootEvent(msg.sender, _tokenIdStartMLoot + _countTokenMLoot.current(), _mlootType, bagId, face, eyes, bg, left);
_claimMLoot(bagId);
_claimedHyperlist[msg.sender] = true;
} else if (bagType[index] == _gaType) {
_checkGASupply();
_checkGAOwner(bagId);
_mintHyperLootEvent(msg.sender, _tokenIdStartGA + _countTokenGA.current(), _gaType, bagId, face, eyes, bg, left);
_claimGA(bagId);
}
}
}
function mintPublic(uint256[] calldata bagIds, uint16[] calldata bagType, uint8[] calldata traits) external payable
nonReentrant
publicSaleActive
isPaymentValid(bagIds.length) {
_checkTraitsCount(bagIds.length, bagType.length, traits.length);
for (uint8 index = 0; index < bagIds.length; index++) {
uint8 face = traits[index * 4];
uint8 eyes = traits[index * 4 + 1];
uint8 bg = traits[index * 4 + 2];
uint8 left = traits[index * 4 + 3];
_checkTraitsValid(face, eyes, bg, left);
uint bagId = bagIds[index];
if (bagType[index] == _lootType) {
_checkLootOwner(bagId);
_mintHyperLootEvent(msg.sender, bagId, _lootType, bagId, face, eyes, bg, left);
_countTokenLoot.increment();
} else if (bagType[index] == _mlootType) {
_checkMLootSupply();
_checkMLootOwner(bagId);
_mintHyperLootEvent(msg.sender, _tokenIdStartMLoot + _countTokenMLoot.current(), _mlootType, bagId, face, eyes, bg, left);
_claimMLoot(bagId);
} else if (bagType[index] == _gaType) {
_checkGASupply();
_checkGAOwner(bagId);
_mintHyperLootEvent(msg.sender, _tokenIdStartGA + _countTokenGA.current(), _gaType, bagId, face, eyes, bg, left);
_claimGA(bagId);
}
}
}
function mintLootPublic(uint256[] calldata bagIds, uint16[] calldata bagType, uint8[] calldata traits) external payable
nonReentrant
lootPublicSaleActive
isPaymentValid(bagIds.length) {
_checkTraitsCount(bagIds.length, bagType.length, traits.length);
for (uint8 index = 0; index < bagIds.length; index++) {
uint8 face = traits[index * 4];
uint8 eyes = traits[index * 4 + 1];
uint8 bg = traits[index * 4 + 2];
uint8 left = traits[index * 4 + 3];
_checkTraitsValid(face, eyes, bg, left);
uint bagId = bagIds[index];
if (bagType[index] == _lootType) {
_checkLoot(bagId);
_mintHyperLootEvent(msg.sender, bagId, _lootType, bagId, face, eyes, bg, left);
_countTokenLoot.increment();
} else if (bagType[index] == _mlootType) {
_checkMLootSupply();
_checkMLootOwner(bagId);
_mintHyperLootEvent(msg.sender, _tokenIdStartMLoot + _countTokenMLoot.current(), _mlootType, bagId, face, eyes, bg, left);
_claimMLoot(bagId);
} else if (bagType[index] == _gaType) {
_checkGASupply();
_checkGAOwner(bagId);
_mintHyperLootEvent(msg.sender, _tokenIdStartGA + _countTokenGA.current(), _gaType, bagId, face, eyes, bg, left);
_claimGA(bagId);
}
}
}
function mintGiveaway(uint256 lootId, uint8 faceId, uint8 eyesId, uint8 backgroundId, uint8 leftHandId) external
nonReentrant
isGiveawaySupplyAvailable(lootId) {
_checkTraitsValid(faceId, eyesId, backgroundId, leftHandId);
_mintHyperLootEvent(msg.sender, lootId, _lootType, lootId, faceId, eyesId, backgroundId, leftHandId);
_countTokenLoot.increment();
}
function mintSpecialSet() external nonReentrant onlyOwner {
require(!_isSpecialSetMinted, "SPECIAL_SET_ALREADY_CLAIMED");
for (uint256 index = 0; index < _supplySpecialSet; index++) {
_mintToken(msg.sender, _tokenIdStartSpecialSet + index);
}
_isSpecialSetMinted = true;
}
function _checkMerkleProof(bytes32[] calldata merkleProof, bytes32 root, address from) private pure {
require(MerkleProof.verify(merkleProof, root, keccak256(abi.encodePacked(from))),"ADDRESS_NOT_ELIGIBLE");
}
function _checkHyperlistClaimed(address from) private view {
require(!_claimedHyperlist[from], "ADDRESS_HYPERLIST_QUOTA_EXCEED");
}
function _checkTraitsCount(uint256 bagIds, uint256 bagType, uint256 traits) private pure {
require(bagIds == bagType, "BAG_TYPE_LENGTH_MISMATCH");
require(bagIds == traits / 4, "TRAIT_LENGTH_MISMATCH");
}
function _checkLootOwner(uint256 lootId) private view {
_checkLoot(lootId);
require(lootContract.ownerOf(lootId) == msg.sender, "MUST_OWN_TOKEN_ID");
}
function _checkLoot(uint256 lootId) private pure {
require(lootId < 7776 && lootId != 7836 && lootId != 7881, "LOOT_TOKEN_ID_OUT_OF_RANGE");
}
function _checkMLootOwner(uint256 mlootId) private view {
require(mlootId > 8000, "MLOOT_TOKEN_ID_OUT_OF_RANGE");
require(mlootContract.ownerOf(mlootId) == msg.sender, "MUST_OWN_TOKEN_ID");
require(!_claimedMLoot[mlootId], "MLOOT_ALREADY_CLAIMED");
}
function _checkGAOwner(uint256 gaId) private view {
require(gaContract.ownerOf(gaId) == msg.sender, "MUST_OWN_TOKEN_ID");
require(!_claimedGA[gaId], "GA_ALREADY_CLAIMED");
_checkLostMana(gaId);
}
function _checkMLootSupply() private view {
require(_countTokenMLoot.current() < _supplyMLoot, "MLOOT_SOLD_OUT");
}
function _checkGASupply() private view {
require(_countTokenGA.current() < _supplyGA, "GA_SOLD_OUT");
}
function _checkTraitsValid(uint8 faceId, uint8 eyesId, uint8 backgroundId, uint8 leftHandId) private pure {
_checkFaceTrait(faceId);
_checkEyesTrait(eyesId);
_checkBackgroundTrait(backgroundId);
_checkLeftHandTrait(leftHandId);
}
function _checkBackgroundTrait(uint8 backgroundId) private pure {
require(backgroundId >= 0 && backgroundId < 18, "BACKGROUND_TRAIT_OUT_OF_RANGE");
}
function _checkFaceTrait(uint8 faceId) private pure {
require(faceId >= 0 && faceId < 26, "FACE_TRAIT_OUT_OF_RANGE");
}
function _checkEyesTrait(uint8 eyesId) private pure {
require(eyesId >= 0 && eyesId < 14, "EYES_TRAIT_OUT_OF_RANGE");
}
function _checkLeftHandTrait(uint8 leftHandId) private pure {
require(leftHandId >= 0 && leftHandId < 14, "LEFT_HAND_TRAIT_OUT_OF_RANGE");
}
function _claimMLoot(uint256 mlootId) private {
_countTokenMLoot.increment();
_claimedMLoot[mlootId] = true;
}
function _claimGA(uint256 gaId) private {
_countTokenGA.increment();
_claimedGA[gaId] = true;
}
function _mintHyperLootEvent(address _to, uint256 _tokenId, uint256 _tokenType, uint256 _fromTokenId, uint8 faceIds, uint8 eyesIds, uint8 backgroundIds, uint8 leftHandIds) private {
_mintToken(_to, _tokenId);
emit HyperLootMinted(_to, _tokenId, _tokenType, _fromTokenId, [faceIds, eyesIds, backgroundIds, leftHandIds]);
}
function _mintToken(address _to, uint256 _tokenId) private {
_safeMint(_to, _tokenId);
}
function _checkLostMana(uint256 bagId) private view {
_checkLostManaItem(gaContract.getWeapon(bagId));
_checkLostManaItem(gaContract.getChest(bagId));
_checkLostManaItem(gaContract.getHead(bagId));
_checkLostManaItem(gaContract.getWaist(bagId));
_checkLostManaItem(gaContract.getFoot(bagId));
_checkLostManaItem(gaContract.getHand(bagId));
_checkLostManaItem(gaContract.getNeck(bagId));
_checkLostManaItem(gaContract.getRing(bagId));
}
function _checkLostManaItem(string memory itemName) private pure {
bytes memory lostBytes = bytes ("Lost");
bytes memory itemNameBytes = bytes (itemName);
bool found = false;
if (itemNameBytes[0] == lostBytes[0]
&& itemNameBytes[1] == lostBytes[1]
&& itemNameBytes[2] == lostBytes[2]
&& itemNameBytes[3] == lostBytes[3]) {
found = true;
}
require (!found, "BAG_CONTAINS_LOST_MANA");
}
function totalLootMinted() public view returns (uint256) {
return _countTokenLoot.current();
}
function totalMLootMinted() public view returns (uint256) {
return _countTokenMLoot.current();
}
function totalGAMinted() public view returns (uint256) {
return _countTokenGA.current();
}
function totalSupply() public view returns (uint256) {
return _countTokenLoot.current() + _countTokenMLoot.current() + _countTokenGA.current() + _supplySpecialSet;
}
function isLootClaimed(uint256 lootId) public view returns (bool) {
return _exists(lootId);
}
function isMLootClaimed(uint256 mlootId) public view returns (bool) {
return _claimedMLoot[mlootId];
}
function isGAClaimed(uint256 gaId) public view returns (bool) {
return _claimedGA[gaId];
}
function setPresale(bool saleState) external onlyOwner {
isPresaleActive = saleState;
}
function setPublicSale(bool saleState) external onlyOwner {
isPublicSaleActive = saleState;
isPresaleActive = false;
}
function setMerkleRoot(bytes32 root) external onlyOwner {
hyperlistMerkleRoot = root;
}
function setGiveaway(address[] calldata addresses, uint256[] calldata lootIds) external onlyOwner {
for (uint256 i = 0; i < addresses.length; i++) {
_giveawayList[addresses[i]] = lootIds[i];
}
}
function setLootPublicSale() external onlyOwner {
isLootPublicSaleActive = true;
}
function setBaseURI(string memory baseURI) public onlyOwner {
_baseTokenURI = baseURI;
}
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, IERC165) returns (bool) {
return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId);
}
function setRoyalty(uint256 percentage, address receiver) external onlyOwner {
royaltyPercentage = percentage;
royaltyAddress = receiver;
}
function royaltyInfo(uint256 tokenId, uint256 salePrice) external view override returns (address receiver, uint256 royalty) {
uint256 royaltyAmount = (salePrice * royaltyPercentage) / 10000;
return (royaltyAddress, royaltyAmount);
}
function withdraw() public onlyOwner {
uint balance = address(this).balance;
payable(msg.sender).transfer(balance);
}
}
文件 7 的 15:IERC165.sol
pragma solidity ^0.8.0;
import "../utils/introspection/IERC165.sol";
文件 8 的 15:IERC2981.sol
pragma solidity ^0.8.0;
import "./IERC165.sol";
interface IERC2981 is IERC165 {
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
}
文件 9 的 15:IERC721.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC721 is IERC165 {
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
function balanceOf(address owner) external view returns (uint256 balance);
function ownerOf(uint256 tokenId) external view returns (address owner);
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
function approve(address to, uint256 tokenId) external;
function getApproved(uint256 tokenId) external view returns (address operator);
function setApprovalForAll(address operator, bool _approved) external;
function isApprovedForAll(address owner, address operator) external view returns (bool);
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
文件 10 的 15:IERC721Metadata.sol
pragma solidity ^0.8.0;
import "../IERC721.sol";
interface IERC721Metadata is IERC721 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function tokenURI(uint256 tokenId) external view returns (string memory);
}
文件 11 的 15:IERC721Receiver.sol
pragma solidity ^0.8.0;
interface IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
文件 12 的 15:MerkleProof.sol
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 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) {
computedHash = _efficientHash(computedHash, proofElement);
} else {
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)
}
}
}
文件 13 的 15:Ownable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
function owner() public view virtual returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 14 的 15:ReentrancyGuard.sol
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;
}
}
文件 15 的 15:Strings.sol
pragma solidity ^0.8.0;
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
function toString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
{
"compilationTarget": {
"contracts/HyperLoot.sol": "HyperLoot"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fromTokenType","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint8[4]","name":"traits","type":"uint8[4]"}],"name":"HyperLootMinted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"MINT_PRICE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOTAL_SUPPLY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hyperlistMerkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gaId","type":"uint256"}],"name":"isGAClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"lootId","type":"uint256"}],"name":"isLootClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isLootPublicSaleActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"mlootId","type":"uint256"}],"name":"isMLootClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPresaleActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPublicSaleActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"lootId","type":"uint256"},{"internalType":"uint8","name":"faceId","type":"uint8"},{"internalType":"uint8","name":"eyesId","type":"uint8"},{"internalType":"uint8","name":"backgroundId","type":"uint8"},{"internalType":"uint8","name":"leftHandId","type":"uint8"}],"name":"mintGiveaway","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"bagIds","type":"uint256[]"},{"internalType":"uint16[]","name":"bagType","type":"uint16[]"},{"internalType":"uint8[]","name":"traits","type":"uint8[]"}],"name":"mintLootPublic","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"bagIds","type":"uint256[]"},{"internalType":"uint16[]","name":"bagType","type":"uint16[]"},{"internalType":"uint8[]","name":"traits","type":"uint8[]"},{"internalType":"bytes32[]","name":"merkleProof","type":"bytes32[]"}],"name":"mintPresale","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"bagIds","type":"uint256[]"},{"internalType":"uint16[]","name":"bagType","type":"uint16[]"},{"internalType":"uint8[]","name":"traits","type":"uint8[]"}],"name":"mintPublic","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"mintSpecialSet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"royaltyAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"royalty","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"royaltyPercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"baseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint256[]","name":"lootIds","type":"uint256[]"}],"name":"setGiveaway","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setLootPublicSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"root","type":"bytes32"}],"name":"setMerkleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"saleState","type":"bool"}],"name":"setPresale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"saleState","type":"bool"}],"name":"setPublicSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"percentage","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"setRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalGAMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalLootMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalMLootMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]