编译器
0.8.12+commit.f00d7308
文件 1 的 21:Address.sol
pragma solidity ^0.8.1;
library Address {
function isContract(address account) internal view returns (bool) {
return account.code.length > 0;
}
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 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 的 21:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
文件 3 的 21:ECDSA.sol
pragma solidity ^0.8.0;
import "../Strings.sol";
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return;
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
文件 4 的 21: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 的 21:ERC2981Base.sol
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "./IERC2981Royalties.sol";
abstract contract ERC2981Base is ERC165, IERC2981Royalties {
struct RoyaltyInfo {
address recipient;
uint24 amount;
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override
returns (bool)
{
return
interfaceId == type(IERC2981Royalties).interfaceId ||
super.supportsInterface(interfaceId);
}
}
文件 6 的 21:ERC2981ContractWideRoyalties.sol
pragma solidity ^0.8.9;
import "./ERC2981Base.sol";
abstract contract ERC2981ContractWideRoyalties is ERC2981Base {
RoyaltyInfo private _royalties;
function _setRoyalties(
address _recipient,
uint256 _value
)
internal
{
_royalties = RoyaltyInfo(_recipient, uint24(_value));
}
function royaltyInfo(
uint256,
uint256 _value
)
external
view
override
returns (address receiver, uint256 royaltyAmount)
{
RoyaltyInfo memory royalties = _royalties;
receiver = royalties.recipient;
royaltyAmount = (_value * royalties.amount) / 10000;
}
}
文件 7 的 21:ERC721.sol
pragma solidity ^0.8.12;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "../utils/Context.sol";
import "../utils/Address.sol";
abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
string private _name;
string private _symbol;
uint256 internal immutable _startingTokenID;
address[] internal _owners;
mapping(uint256 => address) private _tokenApprovals;
mapping(address => mapping(address => bool)) private _operatorApprovals;
constructor(
string memory name_,
string memory symbol_,
uint256 startingTokenID_
) {
_name = name_;
_symbol = symbol_;
_startingTokenID = startingTokenID_;
}
function _internalTokenID(
uint256 externalTokenID_
)
private
view
returns (uint256)
{
require(
externalTokenID_ >= _startingTokenID,
"ERC721: owner query for nonexistent token"
);
unchecked {
return externalTokenID_ - _startingTokenID;
}
}
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 (uint)
{
require(owner != address(0), "ERC721: balance query for the zero address");
uint count;
for (uint i; i < _owners.length; ++i) {
if (owner == _owners[i]) ++count;
}
return count;
}
function ownerOf(uint256 tokenId)
public
view
virtual
override
returns (address)
{
address owner = _owners[_internalTokenID(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 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
{
require(operator != _msgSender(), "ERC721: approve to caller");
_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 {
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) {
if (tokenId < _startingTokenID) return false;
uint256 internalID = _internalTokenID(tokenId);
return internalID < _owners.length && _owners[internalID] != 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);
_owners.push(to);
emit Transfer(address(0), to, tokenId);
}
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
_approve(address(0), tokenId);
_owners[_internalTokenID(tokenId)] = address(0);
emit Transfer(owner, address(0), tokenId);
}
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(
ERC721.ownerOf(tokenId) == from,
"ERC721: transfer of token that is not own"
);
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
_approve(address(0), tokenId);
_owners[_internalTokenID(tokenId)] = to;
emit Transfer(from, to, tokenId);
}
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
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 ,
address ,
uint256
) internal virtual {}
}
文件 8 的 21:ERC721Enumerable.sol
pragma solidity ^0.8.12;
import "./ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
function supportsInterface(
bytes4 interfaceId
)
public
view
virtual
override (IERC165, ERC721)
returns (bool)
{
return interfaceId == type(IERC721Enumerable).interfaceId
|| super.supportsInterface(interfaceId);
}
function totalSupply()
public
view
virtual
override
returns (uint256)
{
return _owners.length;
}
function tokenByIndex(
uint256 index
)
public
view
virtual
override
returns (uint256)
{
require(
index < _owners.length,
"ERC721Enumerable: global index out of bounds"
);
unchecked {
return index + _startingTokenID;
}
}
function tokenOfOwnerByIndex(
address owner,
uint256 index
)
public
view
virtual
override
returns (uint256 tokenId)
{
require(
index < balanceOf(owner),
"ERC721Enumerable: owner index out of bounds"
);
uint count;
unchecked {
for (uint i; i < _owners.length; i++) {
if (owner == _owners[i]) {
if (count == index) return _startingTokenID + i;
else count++;
}
}
}
revert("ERC721Enumerable: owner index out of bounds");
}
}
文件 9 的 21:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 10 的 21:IERC2981Royalties.sol
pragma solidity ^0.8.9;
interface IERC2981Royalties {
function royaltyInfo(uint256 _tokenId, uint256 _value)
external
view
returns (address _receiver, uint256 _royaltyAmount);
}
文件 11 的 21: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;
}
文件 12 的 21:IERC721Enumerable.sol
pragma solidity ^0.8.0;
import "../IERC721.sol";
interface IERC721Enumerable is IERC721 {
function totalSupply() external view returns (uint256);
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
function tokenByIndex(uint256 index) external view returns (uint256);
}
文件 13 的 21: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);
}
文件 14 的 21:IERC721Receiver.sol
pragma solidity ^0.8.0;
interface IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
文件 15 的 21:IStuckTokens.sol
pragma solidity ^0.8.12;
interface IStuckERC20 {
function transfer(
address to,
uint256 amount
) external returns (bool);
}
interface IStuckERC721 {
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
}
文件 16 的 21:ISupremeSkulls.sol
pragma solidity ^0.8.12;
interface ISupremeSkulls {
enum SaleState {
Paused,
Whitelist,
Public,
Open
}
event SaleStateChanged(
SaleState newSaleState
);
error AlreadyRevokedRegistryApproval();
error ExceedsMaxMintPerTx();
error ExceedsMaxRoyaltiesPercentage();
error ExceedsMaxSupply();
error ExceedsMintPhaseAllocation();
error FailedToWithdraw();
error IncorrectPaymentAmount();
error InvalidSignature();
error ProvenanceHashAlreadyLocked();
error SalePhaseNotActive();
error TokenDoesNotExist();
}
文件 17 的 21:Ownable.sol
pragma solidity ^0.8.12;
import "./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 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);
}
}
文件 18 的 21:SafeERC20.sol
pragma solidity ^0.8.0;
import "./IStuckTokens.sol";
import "./../utils/Address.sol";
library SafeERC20 {
using Address for address;
function safeTransfer(
IStuckERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function _callOptionalReturn(IStuckERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
文件 19 的 21: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);
}
}
文件 20 的 21:SupremeSkulls.sol
pragma solidity ^0.8.12;
import "./ISupremeSkulls.sol";
import "./token/ERC721Enumerable.sol";
import "./token/ERC2981ContractWideRoyalties.sol";
import "./token/TokenRescuer.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
contract SupremeSkulls is
ISupremeSkulls,
ERC721Enumerable,
ERC2981ContractWideRoyalties,
TokenRescuer
{
uint256 public constant MAX_SUPPLY = 6666;
uint256 public constant MAX_WHITELIST_MINT = 2;
uint256 public constant MAX_MINT_PER_TX = 2;
uint256 public constant MAX_ROYALTIES_PCT = 1000;
uint256 public priceWhitelist;
uint256 public pricePublic;
string public baseURI;
string public contractURI;
bytes32 public provenanceHash;
bool public provenanceIsLocked;
bool public isRevealed;
SaleState public saleState;
address public proxyRegistry;
address public couponSigner;
mapping(address => bool) public userRevokedRegistryApproval;
mapping(address => uint256) public whitelistMinted;
modifier onlyInSaleState(SaleState _saleState) {
if (saleState != _saleState) revert SalePhaseNotActive();
_;
}
modifier onlyWithValidMintAmount(uint256 _mintAmount) {
if (_mintAmount > MAX_MINT_PER_TX) revert ExceedsMaxMintPerTx();
_;
}
modifier onlyWithCorrectPayment(uint256 _mintAmount, uint256 _price) {
unchecked {
if (msg.value != _mintAmount * _price)
revert IncorrectPaymentAmount();
}
_;
}
modifier onlyWithValidSignature(
bytes calldata _signature,
SaleState _saleState
) {
if (!isValidSignature(
_signature,
_msgSender(),
_saleState,
block.chainid
)) revert InvalidSignature();
_;
}
constructor(
string memory _name,
string memory _symbol,
uint256 _startingTokenID,
address _couponSigner,
uint256 _priceWhitelist,
uint256 _pricePublic,
string memory _contractURI,
string memory _baseURI,
address _proxyRegistry,
address _royaltiesReceiver,
uint256 _royaltiesPercent
)
ERC721(_name, _symbol, _startingTokenID)
{
couponSigner = _couponSigner;
priceWhitelist = _priceWhitelist;
pricePublic = _pricePublic;
contractURI = _contractURI;
baseURI = _baseURI;
proxyRegistry = _proxyRegistry;
setRoyalties(
_royaltiesReceiver,
_royaltiesPercent
);
}
function mintWhitelist(
uint256 _mintAmount,
bytes calldata _signature
)
external
payable
onlyInSaleState(SaleState.Whitelist)
onlyWithCorrectPayment(_mintAmount, priceWhitelist)
onlyWithValidSignature(_signature, SaleState.Whitelist)
{
unchecked {
whitelistMinted[_msgSender()] += _mintAmount;
}
if (whitelistMinted[_msgSender()] > MAX_WHITELIST_MINT)
revert ExceedsMintPhaseAllocation();
_mint(_mintAmount);
}
function mintPublic(
uint256 _mintAmount,
bytes calldata _signature
)
external
payable
onlyInSaleState(SaleState.Public)
onlyWithValidMintAmount(_mintAmount)
onlyWithCorrectPayment(_mintAmount, pricePublic)
onlyWithValidSignature(_signature, SaleState.Public)
{
_mint(_mintAmount);
}
function mintOpen(
uint256 _mintAmount
)
external
payable
onlyInSaleState(SaleState.Open)
onlyWithValidMintAmount(_mintAmount)
onlyWithCorrectPayment(_mintAmount, pricePublic)
{
_mint(_mintAmount);
}
function revokeRegistryApproval()
external
{
if (userRevokedRegistryApproval[_msgSender()])
revert AlreadyRevokedRegistryApproval();
userRevokedRegistryApproval[_msgSender()] = true;
}
function mintPromo(
uint256 _mintAmount
)
external
onlyOwner
{
_mint(_mintAmount);
}
function setSaleState(
SaleState _newSaleState
)
external
onlyOwner
{
saleState = _newSaleState;
emit SaleStateChanged(_newSaleState);
}
function setPriceWhitelist(
uint256 _newPrice
)
external
onlyOwner
{
priceWhitelist = _newPrice;
}
function setPricePublic(
uint256 _newPrice
)
external
onlyOwner
{
pricePublic = _newPrice;
}
function setProxyRegistry(
address _newProxyRegistry
)
external
onlyOwner
{
proxyRegistry = _newProxyRegistry;
}
function setCouponSigner(
address _newCouponSigner
)
external
onlyOwner
{
couponSigner = _newCouponSigner;
}
function setContractURI(
string calldata _newContractURI
)
external
onlyOwner
{
contractURI = _newContractURI;
}
function setBaseURI(
string calldata _newBaseURI,
bool _doReveal
)
external
onlyOwner
{
baseURI = _newBaseURI;
isRevealed = _doReveal;
}
function setProvenanceHash(
bytes32 _newProvenanceHash,
bool _lockForever
)
external
onlyOwner
{
if (provenanceIsLocked) revert ProvenanceHashAlreadyLocked();
provenanceHash = _newProvenanceHash;
if (_lockForever) provenanceIsLocked = true;
}
function withdrawAll()
external
onlyOwner
{
withdraw(address(this).balance);
}
function withdraw(
uint256 _weiAmount
)
public
onlyOwner
{
(bool success, ) = payable(_msgSender()).call{value: _weiAmount}("");
if (!success) revert FailedToWithdraw();
}
function setRoyalties(
address _recipient,
uint256 _value
)
public
onlyOwner
{
if (_value > MAX_ROYALTIES_PCT) revert ExceedsMaxRoyaltiesPercentage();
_setRoyalties(
_recipient,
_value
);
}
function isOwnerOf(
address _account,
uint256[] calldata _tokenIDs
)
external
view
returns (bool)
{
unchecked {
for (uint256 i; i < _tokenIDs.length; ++i) {
if (ownerOf(_tokenIDs[i]) != _account)
return false;
}
}
return true;
}
function walletOfOwner(
address _owner
)
public
view
returns (uint256[] memory)
{
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) return new uint256[](0);
uint256[] memory tokenIDs = new uint256[](tokenCount);
unchecked {
for (uint256 i; i < tokenCount; i++) {
tokenIDs[i] = tokenOfOwnerByIndex(_owner, i);
}
}
return tokenIDs;
}
function isApprovedForAll(
address _owner,
address _operator
)
public
view
override (ERC721, IERC721)
returns (bool)
{
if (!userRevokedRegistryApproval[_owner]) {
OpenSeaProxyRegistry reg = OpenSeaProxyRegistry(proxyRegistry);
if (address(reg.proxies(_owner)) == _operator) return true;
}
return super.isApprovedForAll(_owner, _operator);
}
function tokenURI(
uint256 _tokenID
)
public
view
override
returns (string memory)
{
if (!_exists(_tokenID)) revert TokenDoesNotExist();
if (!isRevealed) return baseURI;
return string(
abi.encodePacked(
baseURI,
Strings.toString(_tokenID),
".json"
)
);
}
function supportsInterface(
bytes4 _interfaceId
)
public
view
override (ERC721Enumerable, ERC2981Base)
returns (bool)
{
return super.supportsInterface(_interfaceId);
}
function isValidSignature(
bytes calldata _signature,
address _sender,
SaleState _saleState,
uint256 _chainId
)
public
view
returns (bool)
{
bytes32 hash = ECDSA.toEthSignedMessageHash(
keccak256(
abi.encodePacked(
_sender,
_saleState,
_chainId
)
)
);
return couponSigner == ECDSA.recover(hash, _signature);
}
function _mint(
uint256 _mintAmount
)
internal
{
uint256 totalSupply = _owners.length;
unchecked {
if (totalSupply + _mintAmount > MAX_SUPPLY)
revert ExceedsMaxSupply();
for (uint256 i; i < _mintAmount; i++) {
_owners.push(_msgSender());
emit Transfer(
address(0),
_msgSender(),
_startingTokenID + totalSupply + i
);
}
}
}
}
contract OwnableDelegateProxy {}
contract OpenSeaProxyRegistry {
mapping(address => OwnableDelegateProxy) public proxies;
}
文件 21 的 21:TokenRescuer.sol
pragma solidity ^0.8.12;
import "./IStuckTokens.sol";
import "./SafeERC20.sol";
import "../utils/Ownable.sol";
error ArrayLengthMismatch();
contract TokenRescuer is Ownable {
using SafeERC20 for IStuckERC20;
function rescueBatchERC20(
address _token,
address[] calldata _receivers,
uint256[] calldata _amounts
)
external
onlyOwner
{
if (_receivers.length != _amounts.length) revert ArrayLengthMismatch();
unchecked {
for (uint i; i < _receivers.length; i += 1) {
_rescueERC20(_token, _receivers[i], _amounts[i]);
}
}
}
function rescueERC20(
address _token,
address _receiver,
uint256 _amount
)
external
onlyOwner
{
_rescueERC20(_token, _receiver, _amount);
}
function rescueBatchERC721(
address _token,
address[] calldata _receivers,
uint256[][] calldata _tokenIDs
)
external
onlyOwner
{
if (_receivers.length != _tokenIDs.length) revert ArrayLengthMismatch();
unchecked {
for (uint i; i < _receivers.length; i += 1) {
uint256[] memory tokenIDs = _tokenIDs[i];
for (uint j; j < tokenIDs.length; j += 1) {
_rescueERC721(_token, _receivers[i], tokenIDs[j]);
}
}
}
}
function rescueERC721(
address _token,
address _receiver,
uint256 _tokenID
)
external
onlyOwner
{
_rescueERC721(_token, _receiver, _tokenID);
}
function _rescueERC20(
address _token,
address _receiver,
uint256 _amount
)
private
{
IStuckERC20(_token).safeTransfer(_receiver, _amount);
}
function _rescueERC721(
address _token,
address _receiver,
uint256 _tokenID
)
private
{
IStuckERC721(_token).safeTransferFrom(
address(this),
_receiver,
_tokenID
);
}
}
{
"compilationTarget": {
"contracts/SupremeSkulls.sol": "SupremeSkulls"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 10000
},
"remappings": []
}
[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint256","name":"_startingTokenID","type":"uint256"},{"internalType":"address","name":"_couponSigner","type":"address"},{"internalType":"uint256","name":"_priceWhitelist","type":"uint256"},{"internalType":"uint256","name":"_pricePublic","type":"uint256"},{"internalType":"string","name":"_contractURI","type":"string"},{"internalType":"string","name":"_baseURI","type":"string"},{"internalType":"address","name":"_proxyRegistry","type":"address"},{"internalType":"address","name":"_royaltiesReceiver","type":"address"},{"internalType":"uint256","name":"_royaltiesPercent","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyRevokedRegistryApproval","type":"error"},{"inputs":[],"name":"ArrayLengthMismatch","type":"error"},{"inputs":[],"name":"ExceedsMaxMintPerTx","type":"error"},{"inputs":[],"name":"ExceedsMaxRoyaltiesPercentage","type":"error"},{"inputs":[],"name":"ExceedsMaxSupply","type":"error"},{"inputs":[],"name":"ExceedsMintPhaseAllocation","type":"error"},{"inputs":[],"name":"FailedToWithdraw","type":"error"},{"inputs":[],"name":"IncorrectPaymentAmount","type":"error"},{"inputs":[],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"ProvenanceHashAlreadyLocked","type":"error"},{"inputs":[],"name":"SalePhaseNotActive","type":"error"},{"inputs":[],"name":"TokenDoesNotExist","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":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"enum ISupremeSkulls.SaleState","name":"newSaleState","type":"uint8"}],"name":"SaleStateChanged","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":"MAX_MINT_PER_TX","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_ROYALTIES_PCT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_SUPPLY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_WHITELIST_MINT","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":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"couponSigner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"address","name":"_account","type":"address"},{"internalType":"uint256[]","name":"_tokenIDs","type":"uint256[]"}],"name":"isOwnerOf","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isRevealed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_signature","type":"bytes"},{"internalType":"address","name":"_sender","type":"address"},{"internalType":"enum ISupremeSkulls.SaleState","name":"_saleState","type":"uint8"},{"internalType":"uint256","name":"_chainId","type":"uint256"}],"name":"isValidSignature","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_mintAmount","type":"uint256"}],"name":"mintOpen","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_mintAmount","type":"uint256"}],"name":"mintPromo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_mintAmount","type":"uint256"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"mintPublic","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_mintAmount","type":"uint256"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"mintWhitelist","outputs":[],"stateMutability":"payable","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":"pricePublic","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceWhitelist","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"provenanceHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"provenanceIsLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxyRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address[]","name":"_receivers","type":"address[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"rescueBatchERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address[]","name":"_receivers","type":"address[]"},{"internalType":"uint256[][]","name":"_tokenIDs","type":"uint256[][]"}],"name":"rescueBatchERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"rescueERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_tokenID","type":"uint256"}],"name":"rescueERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revokeRegistryApproval","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"royaltyAmount","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":[],"name":"saleState","outputs":[{"internalType":"enum ISupremeSkulls.SaleState","name":"","type":"uint8"}],"stateMutability":"view","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":"_newBaseURI","type":"string"},{"internalType":"bool","name":"_doReveal","type":"bool"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_newContractURI","type":"string"}],"name":"setContractURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newCouponSigner","type":"address"}],"name":"setCouponSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newPrice","type":"uint256"}],"name":"setPricePublic","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newPrice","type":"uint256"}],"name":"setPriceWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_newProvenanceHash","type":"bytes32"},{"internalType":"bool","name":"_lockForever","type":"bool"}],"name":"setProvenanceHash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newProxyRegistry","type":"address"}],"name":"setProxyRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"setRoyalties","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum ISupremeSkulls.SaleState","name":"_newSaleState","type":"uint8"}],"name":"setSaleState","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":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"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":"","type":"address"}],"name":"userRevokedRegistryApproval","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"walletOfOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_weiAmount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAll","outputs":[],"stateMutability":"nonpayable","type":"function"}]