编译器
0.8.12+commit.f00d7308
文件 1 的 7: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;
}
}
文件 2 的 7:ERC721A.sol
pragma solidity ^0.8.4;
import './IERC721A.sol';
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 (owner == address(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;
}
function _packedOwnershipOf(uint256 tokenId) private view returns (uint256) {
uint256 curr = tokenId;
unchecked {
if (_startTokenId() <= curr)
if (curr < _currentIndex) {
uint256 packed = _packedOwnerships[curr];
if (packed & BITMASK_BURNED == 0) {
while (packed == 0) {
packed = _packedOwnerships[--curr];
}
return packed;
}
}
}
revert OwnerQueryForNonexistentToken();
}
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;
}
function _ownershipAt(uint256 index) internal view returns (TokenOwnership memory) {
return _unpackedOwnership(_packedOwnerships[index]);
}
function _initializeOwnershipAt(uint256 index) internal {
if (_packedOwnerships[index] == 0) {
_packedOwnerships[index] = _packedOwnershipOf(index);
}
}
function _ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
return _unpackedOwnership(_packedOwnershipOf(tokenId));
}
function ownerOf(uint256 tokenId) public view override returns (address) {
return address(uint160(_packedOwnershipOf(tokenId)));
}
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, _toString(tokenId))) : '';
}
function _baseURI() internal view virtual returns (string memory) {
return '';
}
function _addressToUint256(address value) private pure returns (uint256 result) {
assembly {
result := value
}
}
function _boolToUint256(bool value) private pure returns (uint256 result) {
assembly {
result := value
}
}
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);
}
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 == _msgSenderERC721A()) revert ApproveToCaller();
_operatorApprovals[_msgSenderERC721A()][operator] = approved;
emit ApprovalForAll(_msgSenderERC721A(), 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.code.length != 0)
if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
}
function _exists(uint256 tokenId) internal view returns (bool) {
return
_startTokenId() <= tokenId &&
tokenId < _currentIndex &&
_packedOwnerships[tokenId] & BITMASK_BURNED == 0;
}
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 {
_packedAddressData[to] += quantity * ((1 << BITPOS_NUMBER_MINTED) | 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);
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 {
_packedAddressData[to] += quantity * ((1 << BITPOS_NUMBER_MINTED) | 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);
}
function _transfer(
address from,
address to,
uint256 tokenId
) private {
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner();
bool isApprovedOrOwner = (_msgSenderERC721A() == from ||
isApprovedForAll(from, _msgSenderERC721A()) ||
getApproved(tokenId) == _msgSenderERC721A());
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
if (to == address(0)) revert TransferToZeroAddress();
_beforeTokenTransfers(from, to, tokenId, 1);
delete _tokenApprovals[tokenId];
unchecked {
--_packedAddressData[from];
++_packedAddressData[to];
_packedOwnerships[tokenId] =
_addressToUint256(to) |
(block.timestamp << BITPOS_START_TIMESTAMP) |
BITMASK_NEXT_INITIALIZED;
if (prevOwnershipPacked & BITMASK_NEXT_INITIALIZED == 0) {
uint256 nextTokenId = tokenId + 1;
if (_packedOwnerships[nextTokenId] == 0) {
if (nextTokenId != _currentIndex) {
_packedOwnerships[nextTokenId] = prevOwnershipPacked;
}
}
}
}
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 {
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
address from = address(uint160(prevOwnershipPacked));
if (approvalCheck) {
bool isApprovedOrOwner = (_msgSenderERC721A() == from ||
isApprovedForAll(from, _msgSenderERC721A()) ||
getApproved(tokenId) == _msgSenderERC721A());
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
}
_beforeTokenTransfers(from, address(0), tokenId, 1);
delete _tokenApprovals[tokenId];
unchecked {
_packedAddressData[from] += (1 << BITPOS_NUMBER_BURNED) - 1;
_packedOwnerships[tokenId] =
_addressToUint256(from) |
(block.timestamp << BITPOS_START_TIMESTAMP) |
BITMASK_BURNED |
BITMASK_NEXT_INITIALIZED;
if (prevOwnershipPacked & BITMASK_NEXT_INITIALIZED == 0) {
uint256 nextTokenId = tokenId + 1;
if (_packedOwnerships[nextTokenId] == 0) {
if (nextTokenId != _currentIndex) {
_packedOwnerships[nextTokenId] = prevOwnershipPacked;
}
}
}
}
emit Transfer(from, address(0), tokenId);
_afterTokenTransfers(from, address(0), tokenId, 1);
unchecked {
_burnCounter++;
}
}
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))
}
}
}
}
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
function _msgSenderERC721A() internal view virtual returns (address) {
return msg.sender;
}
function _toString(uint256 value) internal pure returns (string memory ptr) {
assembly {
ptr := add(mload(0x40), 128)
mstore(0x40, ptr)
let end := ptr
for {
let temp := value
ptr := sub(ptr, 1)
mstore8(ptr, add(48, mod(temp, 10)))
temp := div(temp, 10)
} temp {
temp := div(temp, 10)
} {
ptr := sub(ptr, 1)
mstore8(ptr, add(48, mod(temp, 10)))
}
let length := sub(end, ptr)
ptr := sub(ptr, 32)
mstore(ptr, length)
}
}
}
文件 3 的 7:IERC721A.sol
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);
}
文件 4 的 7: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);
}
}
文件 5 的 7: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;
}
}
文件 6 的 7: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);
}
}
文件 7 的 7:arena.sol
pragma solidity ^0.8.12;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "./ERC721A.sol";
contract Hackers is Ownable, ERC721A, ReentrancyGuard {
constructor(uint256 _collectionSize) ERC721A("Hackers", "HACKERS") {
collectionSize = _collectionSize;
stage = Stage.INITIAL;
metadataIsLocked = false;
allowTransferWhileJackedIn = false;
treasuryAddress = msg.sender;
allowlistSignerAddress = msg.sender;
}
uint256 public immutable collectionSize;
string private _baseTokenURI;
address public treasuryAddress;
uint8 private treasuryMaxBatch = 20;
address public allowlistSignerAddress;
bool public metadataIsLocked;
bool public mintingIsPaused;
bool private allowTransferWhileJackedIn;
struct JackInState {
uint64 started;
uint64 cumulative;
}
mapping(uint256 => JackInState) public jackerTracker;
enum Stage {
INITIAL,
ALLOWLIST_SALE,
PUBLIC_SALE
}
Stage public stage;
struct AllowlistSaleConfig {
uint32 key;
uint32 maxBatch;
uint32 maxPerAddress;
uint32 mintingCap;
uint64 price;
}
AllowlistSaleConfig public allowlistSaleConfig;
struct PublicSaleConfig {
uint32 key;
uint32 maxBatch;
uint32 maxPerAddress;
uint32 mintingCap;
uint64 price;
}
PublicSaleConfig public publicSaleConfig;
error FunctionInvalidAtThisStage();
error SaleKeyNotSet();
error SaleMaxBatchNotSet();
error SaleMaxPerAddressNotSet();
error SaleTotalAllotmentNotSet();
error SalePriceNotSet();
modifier onlyStage(Stage _stage) {
if (stage != _stage) {
revert FunctionInvalidAtThisStage();
}
_;
}
function advanceStage() external onlyOwner {
if (stage == Stage.INITIAL) {
if (allowlistSaleConfig.key == 0) revert SaleKeyNotSet();
if (allowlistSaleConfig.maxBatch == 0) revert SaleMaxBatchNotSet();
if (allowlistSaleConfig.maxPerAddress == 0) revert SaleMaxPerAddressNotSet();
if (allowlistSaleConfig.price == 0) revert SalePriceNotSet();
stage = Stage.ALLOWLIST_SALE;
} else if (stage == Stage.ALLOWLIST_SALE) {
if (publicSaleConfig.key == 0) revert SaleKeyNotSet();
if (publicSaleConfig.maxBatch == 0) revert SaleMaxBatchNotSet();
if (publicSaleConfig.maxPerAddress == 0) revert SaleMaxPerAddressNotSet();
if (publicSaleConfig.price == 0) revert SalePriceNotSet();
stage = Stage.PUBLIC_SALE;
}
}
error CallerIsContract();
error WithdrawFailed();
error CallerNotApprovedOrTokenOwner();
error ExceededTreasuryMaxBatch();
function withdrawMoney() external onlyOwner nonReentrant {
(bool success, ) = msg.sender.call{value: address(this).balance}("");
if (!success) revert WithdrawFailed();
}
function setMintingIsPaused(bool _paused) external onlyOwner {
mintingIsPaused = _paused;
}
function setTreasuryAddress(address _addr) external onlyOwner {
treasuryAddress = _addr;
}
function setAllowlistSignerAddress(address _addr) external onlyOwner {
allowlistSignerAddress = _addr;
}
function treasuryMint(uint8 quantity) external onlyOwner {
if (quantity > treasuryMaxBatch) revert ExceededTreasuryMaxBatch();
if (_totalMinted() + quantity > collectionSize) revert ExceededMaxSupply();
_safeMint(treasuryAddress, quantity);
}
modifier callerIsUser() {
if (tx.origin != msg.sender) revert CallerIsContract();
_;
}
modifier onlyApprovedOrTokenOwner(uint256 tokenID) {
TokenOwnership memory ownership = _ownershipOf(tokenID);
bool isApprovedOrOwner = (_msgSender() == ownership.addr ||
isApprovedForAll(ownership.addr, _msgSender()) ||
getApproved(tokenID) == _msgSender());
if (!isApprovedOrOwner) revert CallerNotApprovedOrTokenOwner();
_;
}
error MintingPaused();
error InvalidAllowlistSignature();
error IncorrectAllowlistSaleKey();
error ExceededAllowlistMaxBatch();
error ExceededAllowlistMaxPerAddress();
error ExceededAllowlistMintingCap();
error ExceededAllowlistPersonalAllotment();
function allowlistMint(uint8 quantity, uint8 userAllotment, uint32 callerSaleKey, bytes memory signature)
external
payable
callerIsUser
onlyStage(Stage.ALLOWLIST_SALE)
{
AllowlistSaleConfig memory config = allowlistSaleConfig;
uint256 saleKey = uint256(config.key);
uint256 maxBatch = uint256(config.maxBatch);
uint256 maxPerAddress = uint256(config.maxPerAddress);
uint256 mintingCap = uint256(config.mintingCap);
uint256 price = uint256(config.price);
bytes32 message = prefixed(keccak256(abi.encodePacked(msg.sender, ":", userAllotment)));
if (mintingIsPaused) revert MintingPaused();
if (quantity > maxBatch) revert ExceededAllowlistMaxBatch();
if (saleKey != callerSaleKey) revert IncorrectAllowlistSaleKey();
if (numberMinted(msg.sender) + quantity > userAllotment) revert ExceededAllowlistPersonalAllotment();
if (numberMinted(msg.sender) + quantity > maxPerAddress) revert ExceededAllowlistMaxPerAddress();
if (_totalMinted() + quantity > mintingCap) revert ExceededAllowlistMintingCap();
if (_totalMinted() + quantity > collectionSize) revert ExceededMaxSupply();
if (recoverSigner(message, signature) != allowlistSignerAddress) revert InvalidAllowlistSignature();
_safeMint(msg.sender, quantity);
refundIfOver(price * quantity);
}
function splitSignature(bytes memory sig)
internal
pure
returns (uint8 v, bytes32 r, bytes32 s)
{
require(sig.length == 65);
assembly {
r := mload(add(sig, 32))
s := mload(add(sig, 64))
v := byte(0, mload(add(sig, 96)))
}
return (v, r, s);
}
function recoverSigner(bytes32 message, bytes memory sig)
internal
pure
returns (address)
{
(uint8 v, bytes32 r, bytes32 s) = splitSignature(sig);
return ecrecover(message, v, r, s);
}
function prefixed(bytes32 hash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
error IncorrectPublicSaleKey();
error ExceededPublicSaleMaxBatch();
error ExceededPublicSaleMaxPerAddress();
error ExceededPublicSaleMintingCap();
error ExceededMaxSupply();
error InsufficientEth();
function publicSaleMint(uint256 quantity, uint256 callerSaleKey)
external
payable
callerIsUser
onlyStage(Stage.PUBLIC_SALE)
{
PublicSaleConfig memory config = publicSaleConfig;
uint256 publicSaleKey = uint256(config.key);
uint256 publicSalePrice = uint256(config.price);
uint256 publicSaleMaxBatch = uint256(config.maxBatch);
uint256 publicSaleMintingCap = uint256(config.mintingCap);
uint256 publicSaleMaxPerAddress = uint256(config.maxPerAddress);
if (mintingIsPaused) revert MintingPaused();
if (publicSaleKey != callerSaleKey) revert IncorrectPublicSaleKey();
if (quantity > publicSaleMaxBatch) revert ExceededPublicSaleMaxBatch();
if (_totalMinted() + quantity > collectionSize) revert ExceededMaxSupply();
if (_totalMinted() + quantity > publicSaleMintingCap) revert ExceededPublicSaleMintingCap();
if (numberMinted(msg.sender) + quantity > publicSaleMaxPerAddress) revert ExceededPublicSaleMaxPerAddress();
_safeMint(msg.sender, quantity);
refundIfOver(publicSalePrice * quantity);
}
function refundIfOver(uint256 totalCost) private {
if (msg.value < totalCost) revert InsufficientEth();
if (msg.value > totalCost) {
payable(msg.sender).transfer(msg.value - totalCost);
}
}
error InvalidAllowlistConfiguration();
error InvalidPublicSaleConfiguration();
function configureAllowlistSale(uint32 key, uint32 maxBatch, uint32 maxPerAddress, uint32 mintingCap, uint64 price)
external
onlyOwner
{
if (key == 0) revert InvalidAllowlistConfiguration();
if (maxBatch == 0) revert InvalidAllowlistConfiguration();
if (maxPerAddress == 0) revert InvalidAllowlistConfiguration();
if (price == 0) revert InvalidAllowlistConfiguration();
if (mintingCap == 0) revert InvalidAllowlistConfiguration();
allowlistSaleConfig.key = key;
allowlistSaleConfig.maxBatch = maxBatch;
allowlistSaleConfig.maxPerAddress = maxPerAddress;
allowlistSaleConfig.mintingCap = mintingCap;
allowlistSaleConfig.price = price;
}
function configurePublicSale(uint32 key, uint32 maxBatch, uint32 maxPerAddress, uint32 mintingCap, uint64 price)
external
onlyOwner
{
if (key == 0) revert InvalidPublicSaleConfiguration();
if (maxBatch == 0) revert InvalidPublicSaleConfiguration();
if (maxPerAddress == 0) revert InvalidPublicSaleConfiguration();
if (price == 0) revert InvalidPublicSaleConfiguration();
if (mintingCap == 0) revert InvalidPublicSaleConfiguration();
publicSaleConfig.key = key;
publicSaleConfig.maxBatch = maxBatch;
publicSaleConfig.maxPerAddress = maxPerAddress;
publicSaleConfig.mintingCap = mintingCap;
publicSaleConfig.price = price;
}
error InvalidTransferCurrentlyJackedIn();
error OnlyTokenOwner();
event JackedIn(uint256 indexed tokenID);
event JackedOut(uint256 indexed tokenID);
event Flatlined(uint256 indexed tokenID);
function hackingStats(uint256 tokenID) external view returns (
bool isJackedIn,
uint64 current,
uint64 total
) {
JackInState memory state = jackerTracker[tokenID];
if (state.started != 0) {
isJackedIn = true;
current = uint64(block.timestamp) - state.started;
}
total = state.cumulative + current;
}
function _beforeTokenTransfers(
address,
address,
uint256 startTokenID,
uint256 quantity
) internal view override {
uint256 tokenID = startTokenID;
for (uint256 end = tokenID + quantity; tokenID < end; tokenID++) {
if (jackerTracker[tokenID].started != 0 && !allowTransferWhileJackedIn) {
revert InvalidTransferCurrentlyJackedIn();
}
}
}
function transferWhileJackedIn(
address from,
address to,
uint256 tokenID
) external {
if (ownerOf(tokenID) != _msgSender()) revert OnlyTokenOwner();
allowTransferWhileJackedIn = true;
transferFrom(from, to, tokenID);
allowTransferWhileJackedIn = false;
}
function jackIn(uint256[] calldata tokenIDs) external {
uint256 length = tokenIDs.length;
for (uint256 i = 0; i < length; i++) {
_jackIn(tokenIDs[i]);
}
}
function _jackIn(uint256 tokenID) internal onlyApprovedOrTokenOwner(tokenID) {
JackInState storage state = jackerTracker[tokenID];
if (state.started == 0) {
state.started = uint64(block.timestamp);
emit JackedIn(tokenID);
}
}
function jackOut(uint256[] calldata tokenIDs) external {
uint256 length = tokenIDs.length;
for (uint256 i = 0; i < length; i++) {
_jackOut(tokenIDs[i]);
}
}
function _jackOut(uint256 tokenID) internal onlyApprovedOrTokenOwner(tokenID) {
JackInState storage state = jackerTracker[tokenID];
if (state.started != 0) {
state.cumulative += uint64(block.timestamp) - state.started;
state.started = 0;
emit JackedOut(tokenID);
}
}
function flatline(uint256 tokenID) external onlyOwner {
JackInState storage state = jackerTracker[tokenID];
if (state.started != 0) {
state.cumulative += uint64(block.timestamp) - state.started;
state.started = 0;
emit JackedOut(tokenID);
emit Flatlined(tokenID);
}
}
error MetadataLocked();
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function setBaseURI(string calldata baseURI) external onlyOwner {
if (metadataIsLocked) revert MetadataLocked();
_baseTokenURI = baseURI;
}
function lockMetadata() external onlyOwner {
metadataIsLocked = true;
}
function numberMinted(address owner) public view returns (uint256) {
return _numberMinted(owner);
}
function supportsInterface(bytes4 interfaceId) public view override(ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
}
{
"compilationTarget": {
"contracts/arena.sol": "Hackers"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 1000
},
"remappings": []
}
[{"inputs":[{"internalType":"uint256","name":"_collectionSize","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"ApprovalQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"ApprovalToCurrentOwner","type":"error"},{"inputs":[],"name":"ApproveToCaller","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[],"name":"CallerIsContract","type":"error"},{"inputs":[],"name":"CallerNotApprovedOrTokenOwner","type":"error"},{"inputs":[],"name":"ExceededAllowlistMaxBatch","type":"error"},{"inputs":[],"name":"ExceededAllowlistMaxPerAddress","type":"error"},{"inputs":[],"name":"ExceededAllowlistMintingCap","type":"error"},{"inputs":[],"name":"ExceededAllowlistPersonalAllotment","type":"error"},{"inputs":[],"name":"ExceededMaxSupply","type":"error"},{"inputs":[],"name":"ExceededPublicSaleMaxBatch","type":"error"},{"inputs":[],"name":"ExceededPublicSaleMaxPerAddress","type":"error"},{"inputs":[],"name":"ExceededPublicSaleMintingCap","type":"error"},{"inputs":[],"name":"ExceededTreasuryMaxBatch","type":"error"},{"inputs":[],"name":"FunctionInvalidAtThisStage","type":"error"},{"inputs":[],"name":"IncorrectAllowlistSaleKey","type":"error"},{"inputs":[],"name":"IncorrectPublicSaleKey","type":"error"},{"inputs":[],"name":"InsufficientEth","type":"error"},{"inputs":[],"name":"InvalidAllowlistConfiguration","type":"error"},{"inputs":[],"name":"InvalidAllowlistSignature","type":"error"},{"inputs":[],"name":"InvalidPublicSaleConfiguration","type":"error"},{"inputs":[],"name":"InvalidTransferCurrentlyJackedIn","type":"error"},{"inputs":[],"name":"MetadataLocked","type":"error"},{"inputs":[],"name":"MintToZeroAddress","type":"error"},{"inputs":[],"name":"MintZeroQuantity","type":"error"},{"inputs":[],"name":"MintingPaused","type":"error"},{"inputs":[],"name":"OnlyTokenOwner","type":"error"},{"inputs":[],"name":"OwnerQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"SaleKeyNotSet","type":"error"},{"inputs":[],"name":"SaleMaxBatchNotSet","type":"error"},{"inputs":[],"name":"SaleMaxPerAddressNotSet","type":"error"},{"inputs":[],"name":"SalePriceNotSet","type":"error"},{"inputs":[],"name":"SaleTotalAllotmentNotSet","type":"error"},{"inputs":[],"name":"TransferCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"TransferToNonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"URIQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"WithdrawFailed","type":"error"},{"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":"uint256","name":"tokenID","type":"uint256"}],"name":"Flatlined","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenID","type":"uint256"}],"name":"JackedIn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenID","type":"uint256"}],"name":"JackedOut","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":"advanceStage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"quantity","type":"uint8"},{"internalType":"uint8","name":"userAllotment","type":"uint8"},{"internalType":"uint32","name":"callerSaleKey","type":"uint32"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"allowlistMint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"allowlistSaleConfig","outputs":[{"internalType":"uint32","name":"key","type":"uint32"},{"internalType":"uint32","name":"maxBatch","type":"uint32"},{"internalType":"uint32","name":"maxPerAddress","type":"uint32"},{"internalType":"uint32","name":"mintingCap","type":"uint32"},{"internalType":"uint64","name":"price","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allowlistSignerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[],"name":"collectionSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"key","type":"uint32"},{"internalType":"uint32","name":"maxBatch","type":"uint32"},{"internalType":"uint32","name":"maxPerAddress","type":"uint32"},{"internalType":"uint32","name":"mintingCap","type":"uint32"},{"internalType":"uint64","name":"price","type":"uint64"}],"name":"configureAllowlistSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"key","type":"uint32"},{"internalType":"uint32","name":"maxBatch","type":"uint32"},{"internalType":"uint32","name":"maxPerAddress","type":"uint32"},{"internalType":"uint32","name":"mintingCap","type":"uint32"},{"internalType":"uint64","name":"price","type":"uint64"}],"name":"configurePublicSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenID","type":"uint256"}],"name":"flatline","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenID","type":"uint256"}],"name":"hackingStats","outputs":[{"internalType":"bool","name":"isJackedIn","type":"bool"},{"internalType":"uint64","name":"current","type":"uint64"},{"internalType":"uint64","name":"total","type":"uint64"}],"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":"tokenIDs","type":"uint256[]"}],"name":"jackIn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIDs","type":"uint256[]"}],"name":"jackOut","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"jackerTracker","outputs":[{"internalType":"uint64","name":"started","type":"uint64"},{"internalType":"uint64","name":"cumulative","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockMetadata","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"metadataIsLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintingIsPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"numberMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"publicSaleConfig","outputs":[{"internalType":"uint32","name":"key","type":"uint32"},{"internalType":"uint32","name":"maxBatch","type":"uint32"},{"internalType":"uint32","name":"maxPerAddress","type":"uint32"},{"internalType":"uint32","name":"mintingCap","type":"uint32"},{"internalType":"uint64","name":"price","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"quantity","type":"uint256"},{"internalType":"uint256","name":"callerSaleKey","type":"uint256"}],"name":"publicSaleMint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","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":"_addr","type":"address"}],"name":"setAllowlistSignerAddress","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":"bool","name":"_paused","type":"bool"}],"name":"setMintingIsPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_addr","type":"address"}],"name":"setTreasuryAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stage","outputs":[{"internalType":"enum Hackers.Stage","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenID","type":"uint256"}],"name":"transferWhileJackedIn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasuryAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"quantity","type":"uint8"}],"name":"treasuryMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawMoney","outputs":[],"stateMutability":"nonpayable","type":"function"}]