编译器
0.8.10+commit.fc410830
文件 1 的 17: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 的 17: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 的 17: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;
}
}
文件 4 的 17:ERC2981.sol
pragma solidity ^0.8.0;
import "./IERC2981.sol";
import "./ERC165.sol";
abstract contract ERC2981 is IERC2981, ERC165 {
struct RoyaltyInfo {
address receiver;
uint96 royaltyFraction;
}
RoyaltyInfo private _defaultRoyaltyInfo;
mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo;
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) {
return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId);
}
function royaltyInfo(uint256 _tokenId, uint256 _salePrice) public view virtual override returns (address, uint256) {
RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId];
if (royalty.receiver == address(0)) {
royalty = _defaultRoyaltyInfo;
}
uint256 royaltyAmount = (_salePrice * royalty.royaltyFraction) / _feeDenominator();
return (royalty.receiver, royaltyAmount);
}
function _feeDenominator() internal pure virtual returns (uint96) {
return 10000;
}
function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: invalid receiver");
_defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);
}
function _deleteDefaultRoyalty() internal virtual {
delete _defaultRoyaltyInfo;
}
function _setTokenRoyalty(
uint256 tokenId,
address receiver,
uint96 feeNumerator
) internal virtual {
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: Invalid parameters");
_tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);
}
function _resetTokenRoyalty(uint256 tokenId) internal virtual {
delete _tokenRoyaltyInfo[tokenId];
}
}
文件 5 的 17: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 constant BITPOS_EXTRA_DATA = 232;
uint256 private constant BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;
uint256 private constant BITMASK_ADDRESS = (1 << 160) - 1;
uint256 private constant MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;
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;
ownership.extraData = uint24(packed >> BITPOS_EXTRA_DATA);
}
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 _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) {
assembly {
owner := and(owner, BITMASK_ADDRESS)
result := or(owner, or(shl(BITPOS_START_TIMESTAMP, timestamp()), flags))
}
}
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 _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) {
assembly {
result := shl(BITPOS_NEXT_INITIALIZED, eq(quantity, 1))
}
}
function approve(address to, uint256 tokenId) public override {
address owner = ownerOf(tokenId);
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 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 {
transferFrom(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 {
_mint(to, quantity);
unchecked {
if (to.code.length != 0) {
uint256 end = _currentIndex;
uint256 index = end - quantity;
do {
if (!_checkContractOnERC721Received(address(0), to, index++, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
} while (index < end);
if (_currentIndex != end) revert();
}
}
}
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] = _packOwnershipData(
to,
_nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
);
uint256 tokenId = startTokenId;
uint256 end = startTokenId + quantity;
do {
emit Transfer(address(0), to, tokenId++);
} while (tokenId < end);
_currentIndex = end;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
function _mintERC2309(address to, uint256 quantity) internal {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();
if (quantity > MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
unchecked {
_packedAddressData[to] += quantity * ((1 << BITPOS_NUMBER_MINTED) | 1);
_packedOwnerships[startTokenId] = _packOwnershipData(
to,
_nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
);
emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to);
_currentIndex = startTokenId + quantity;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
function _getApprovedAddress(uint256 tokenId)
private
view
returns (uint256 approvedAddressSlot, address approvedAddress)
{
mapping(uint256 => address) storage tokenApprovalsPtr = _tokenApprovals;
assembly {
mstore(0x00, tokenId)
mstore(0x20, tokenApprovalsPtr.slot)
approvedAddressSlot := keccak256(0x00, 0x40)
approvedAddress := sload(approvedAddressSlot)
}
}
function _isOwnerOrApproved(
address approvedAddress,
address from,
address msgSender
) private pure returns (bool result) {
assembly {
from := and(from, BITMASK_ADDRESS)
msgSender := and(msgSender, BITMASK_ADDRESS)
result := or(eq(msgSender, from), eq(msgSender, approvedAddress))
}
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner();
(uint256 approvedAddressSlot, address approvedAddress) = _getApprovedAddress(tokenId);
if (!_isOwnerOrApproved(approvedAddress, from, _msgSenderERC721A()))
if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();
if (to == address(0)) revert TransferToZeroAddress();
_beforeTokenTransfers(from, to, tokenId, 1);
assembly {
if approvedAddress {
sstore(approvedAddressSlot, 0)
}
}
unchecked {
--_packedAddressData[from];
++_packedAddressData[to];
_packedOwnerships[tokenId] = _packOwnershipData(
to,
BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked)
);
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));
(uint256 approvedAddressSlot, address approvedAddress) = _getApprovedAddress(tokenId);
if (approvalCheck) {
if (!_isOwnerOrApproved(approvedAddress, from, _msgSenderERC721A()))
if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();
}
_beforeTokenTransfers(from, address(0), tokenId, 1);
assembly {
if approvedAddress {
sstore(approvedAddressSlot, 0)
}
}
unchecked {
_packedAddressData[from] += (1 << BITPOS_NUMBER_BURNED) - 1;
_packedOwnerships[tokenId] = _packOwnershipData(
from,
(BITMASK_BURNED | BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked)
);
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 _setExtraDataAt(uint256 index, uint24 extraData) internal {
uint256 packed = _packedOwnerships[index];
if (packed == 0) revert OwnershipNotInitializedForExtraData();
uint256 extraDataCasted;
assembly {
extraDataCasted := extraData
}
packed = (packed & BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << BITPOS_EXTRA_DATA);
_packedOwnerships[index] = packed;
}
function _nextExtraData(
address from,
address to,
uint256 prevOwnershipPacked
) private view returns (uint256) {
uint24 extraData = uint24(prevOwnershipPacked >> BITPOS_EXTRA_DATA);
return uint256(_extraData(from, to, extraData)) << BITPOS_EXTRA_DATA;
}
function _extraData(
address from,
address to,
uint24 previousExtraData
) internal view virtual returns (uint24) {}
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)
}
}
}
文件 6 的 17:ERC721AQueryable.sol
pragma solidity ^0.8.4;
import './IERC721AQueryable.sol';
import './ERC721A.sol';
abstract contract ERC721AQueryable is ERC721A, IERC721AQueryable {
function explicitOwnershipOf(uint256 tokenId) public view override returns (TokenOwnership memory) {
TokenOwnership memory ownership;
if (tokenId < _startTokenId() || tokenId >= _nextTokenId()) {
return ownership;
}
ownership = _ownershipAt(tokenId);
if (ownership.burned) {
return ownership;
}
return _ownershipOf(tokenId);
}
function explicitOwnershipsOf(uint256[] memory tokenIds) external view override returns (TokenOwnership[] memory) {
unchecked {
uint256 tokenIdsLength = tokenIds.length;
TokenOwnership[] memory ownerships = new TokenOwnership[](tokenIdsLength);
for (uint256 i; i != tokenIdsLength; ++i) {
ownerships[i] = explicitOwnershipOf(tokenIds[i]);
}
return ownerships;
}
}
function tokensOfOwnerIn(
address owner,
uint256 start,
uint256 stop
) external view override returns (uint256[] memory) {
unchecked {
if (start >= stop) revert InvalidQueryRange();
uint256 tokenIdsIdx;
uint256 stopLimit = _nextTokenId();
if (start < _startTokenId()) {
start = _startTokenId();
}
if (stop > stopLimit) {
stop = stopLimit;
}
uint256 tokenIdsMaxLength = balanceOf(owner);
if (start < stop) {
uint256 rangeLength = stop - start;
if (rangeLength < tokenIdsMaxLength) {
tokenIdsMaxLength = rangeLength;
}
} else {
tokenIdsMaxLength = 0;
}
uint256[] memory tokenIds = new uint256[](tokenIdsMaxLength);
if (tokenIdsMaxLength == 0) {
return tokenIds;
}
TokenOwnership memory ownership = explicitOwnershipOf(start);
address currOwnershipAddr;
if (!ownership.burned) {
currOwnershipAddr = ownership.addr;
}
for (uint256 i = start; i != stop && tokenIdsIdx != tokenIdsMaxLength; ++i) {
ownership = _ownershipAt(i);
if (ownership.burned) {
continue;
}
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
tokenIds[tokenIdsIdx++] = i;
}
}
assembly {
mstore(tokenIds, tokenIdsIdx)
}
return tokenIds;
}
}
function tokensOfOwner(address owner) external view override returns (uint256[] memory) {
unchecked {
uint256 tokenIdsIdx;
address currOwnershipAddr;
uint256 tokenIdsLength = balanceOf(owner);
uint256[] memory tokenIds = new uint256[](tokenIdsLength);
TokenOwnership memory ownership;
for (uint256 i = _startTokenId(); tokenIdsIdx != tokenIdsLength; ++i) {
ownership = _ownershipAt(i);
if (ownership.burned) {
continue;
}
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
tokenIds[tokenIdsIdx++] = i;
}
}
return tokenIds;
}
}
}
文件 7 的 17:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 8 的 17:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
文件 9 的 17: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);
}
文件 10 的 17:IERC721.sol
pragma solidity ^0.8.0;
import "./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,
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);
}
文件 11 的 17:IERC721A.sol
pragma solidity ^0.8.4;
interface IERC721A {
error ApprovalCallerNotOwnerNorApproved();
error ApprovalQueryForNonexistentToken();
error ApproveToCaller();
error BalanceQueryForZeroAddress();
error MintToZeroAddress();
error MintZeroQuantity();
error OwnerQueryForNonexistentToken();
error TransferCallerNotOwnerNorApproved();
error TransferFromIncorrectOwner();
error TransferToNonERC721ReceiverImplementer();
error TransferToZeroAddress();
error URIQueryForNonexistentToken();
error MintERC2309QuantityExceedsLimit();
error OwnershipNotInitializedForExtraData();
struct TokenOwnership {
address addr;
uint64 startTimestamp;
bool burned;
uint24 extraData;
}
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);
event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);
}
文件 12 的 17:IERC721AQueryable.sol
pragma solidity ^0.8.4;
import './IERC721A.sol';
interface IERC721AQueryable is IERC721A {
error InvalidQueryRange();
function explicitOwnershipOf(uint256 tokenId) external view returns (TokenOwnership memory);
function explicitOwnershipsOf(uint256[] memory tokenIds) external view returns (TokenOwnership[] memory);
function tokensOfOwnerIn(
address owner,
uint256 start,
uint256 stop
) external view returns (uint256[] memory);
function tokensOfOwner(address owner) external view returns (uint256[] memory);
}
文件 13 的 17: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 的 17:Ownable.sol
pragma solidity ^0.8.0;
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 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);
}
}
文件 15 的 17: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;
}
}
文件 16 的 17:SafeERC20.sol
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./Address.sol";
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function _callOptionalReturn(IERC20 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");
}
}
}
文件 17 的 17:StarBlockCollection.sol
pragma solidity ^0.8.10;
import "./ERC721AQueryable.sol";
import "./ERC2981.sol";
import "./IERC20.sol";
import "./SafeERC20.sol";
import "./Ownable.sol";
import "./ReentrancyGuard.sol";
import "./IERC721Metadata.sol";
interface IStarBlockCollection is IERC721AQueryable, IERC2981 {
struct SaleConfig {
uint256 startTime;
uint256 endTime;
uint256 price;
uint256 maxAmountPerAddress;
}
event UpdateWhitelistSaleConfig(SaleConfig _whitelistSaleConfig);
event UpdateWhitelistSaleEndTime(uint256 _oldEndTime, uint256 _newEndTime);
event UpdatePublicSaleConfig(SaleConfig _publicSaleConfig);
event UpdatePublicSaleEndTime(uint256 _oldEndTime, uint256 _newEndTime);
event UpdateChargeToken(IERC20 _chargeToken);
function supportsInterface(bytes4 _interfaceId) external view override(IERC165, IERC721A) returns (bool);
function maxSupply() external view returns (uint256);
function exists(uint256 _tokenId) external view returns (bool);
function maxAmountForArtist() external view returns (uint256);
function artistMinted() external view returns (uint256);
function chargeToken() external view returns (IERC20);
function whitelistSaleConfig() external view
returns (uint256 _startTime, uint256 _endTime, uint256 _price, uint256 _maxAmountPerAddress);
function whitelist(address _user) external view returns (bool);
function whitelistAllowed(address _user) external view returns (uint256);
function whitelistAmount() external view returns (uint256);
function whitelistSaleMinted(address _user) external view returns (uint256);
function publicSaleConfig() external view
returns (uint256 _startTime, uint256 _endTime, uint256 _price, uint256 _maxAmountPerAddress);
function publicSaleMinted(address _user) external view returns (uint256);
function userCanMintTotalAmount() external view returns (uint256);
function whitelistMint(uint256 _amount) external payable;
function publicMint(uint256 _amount) external payable;
}
contract StarBlockCollection is IStarBlockCollection, ERC721AQueryable, ERC2981, Ownable, ReentrancyGuard {
using SafeERC20 for IERC20;
uint256 public immutable maxSupply;
string private baseTokenURI;
uint256 public immutable maxAmountForArtist;
uint256 public artistMinted;
IERC20 public chargeToken;
address payable public protocolFeeReceiver;
uint256 public protocolFeeNumerator;
SaleConfig public whitelistSaleConfig;
mapping(address => bool) public whitelist;
mapping(address => uint256) public whitelistAllowed;
uint256 public whitelistAmount;
mapping(address => uint256) public whitelistSaleMinted;
SaleConfig public publicSaleConfig;
mapping(address => uint256) public publicSaleMinted;
modifier callerIsUser() {
require(tx.origin == msg.sender, "StarBlockCollection: The caller is another contract");
_;
}
constructor(
string memory _name,
string memory _symbol,
uint256 _maxSupply,
IERC20 _chargeToken,
string memory _baseTokenURI,
uint256 _maxAmountForArtist,
address payable _protocolFeeReceiver,
uint256 _protocolFeeNumerator,
address _royaltyReceiver,
uint96 _royaltyFeeNumerator
) ERC721A(_name, _symbol) {
require(_maxSupply > 0 && _maxAmountForArtist <= _maxSupply && _protocolFeeReceiver != address(0)
&& _protocolFeeNumerator <= _feeDenominator() && _royaltyFeeNumerator <= _feeDenominator(), "StarBlockCollection: invalid parameters!");
maxSupply = _maxSupply;
chargeToken = _chargeToken;
baseTokenURI = _baseTokenURI;
maxAmountForArtist = _maxAmountForArtist;
protocolFeeReceiver = _protocolFeeReceiver;
protocolFeeNumerator = _protocolFeeNumerator;
if(_royaltyReceiver != address(0)){
_setDefaultRoyalty(_royaltyReceiver, _royaltyFeeNumerator);
}
}
function whitelistMint(uint256 _amount) external payable callerIsUser {
if(whitelistSaleConfig.maxAmountPerAddress == 0){
require(whitelistAllowed[msg.sender] >= (whitelistSaleMinted[msg.sender] + _amount), "StarBlockCollection: whitelist reached allowed!");
}else{
require(whitelist[msg.sender], "StarBlockCollection: not in whitelist!");
}
_checkUserCanMint(whitelistSaleConfig, _amount, whitelistSaleMinted[msg.sender]);
whitelistSaleMinted[msg.sender] += _amount;
if(whitelistSaleConfig.price > 0 || (whitelistSaleConfig.price == 0 && msg.value > 0)){
_charge(whitelistSaleConfig.price * _amount);
}
_safeMint(msg.sender, _amount);
}
function publicMint(uint256 _amount) external payable callerIsUser {
_checkUserCanMint(publicSaleConfig, _amount, publicSaleMinted[msg.sender]);
publicSaleMinted[msg.sender] += _amount;
if(publicSaleConfig.price > 0 || (publicSaleConfig.price == 0 && msg.value > 0)){
_charge(publicSaleConfig.price * _amount);
}
_safeMint(msg.sender, _amount);
}
function artistMint(uint256 _amount) external onlyOwner nonReentrant {
require(_amount > 0, "StarBlockCollection: amount should be greater than 0!");
require((artistMinted + _amount) <= maxAmountForArtist, "StarBlockCollection: reached max amount for artist!");
require((totalSupply() + _amount) <= maxSupply, "StarBlockCollection: reached max supply!");
artistMinted += _amount;
_safeMint(msg.sender, _amount);
}
function userCanMintTotalAmount() public view returns (uint256) {
return maxSupply - (totalSupply() + maxAmountForArtist - artistMinted);
}
function _checkUserCanMint(SaleConfig memory _saleConfig, uint256 _amount, uint256 _mintedAmount) internal view {
require(_amount > 0, "StarBlockCollection: amount should be greater than 0!");
require(userCanMintTotalAmount() >= _amount, "StarBlockCollection: reached max supply!");
require(_saleConfig.startTime > 0, "StarBlockCollection: sale has not set!");
require(_saleConfig.startTime <= block.timestamp, "StarBlockCollection: sale has not started yet!");
require(_saleConfig.endTime == 0 || _saleConfig.endTime >= block.timestamp, "StarBlockCollection: sale has ended!");
require(_saleConfig.maxAmountPerAddress == 0 || (_mintedAmount + _amount) <= _saleConfig.maxAmountPerAddress,
"StarBlockCollection: reached max amount per address!");
}
function _charge(uint256 _amount) internal nonReentrant {
bool success = true;
uint256 shouldChargedETH;
if(address(chargeToken) != address(0)){
uint256 balance = chargeToken.balanceOf(msg.sender);
require(balance >= _amount, "StarBlockCollection: not enough token!");
chargeToken.safeTransferFrom(msg.sender, address(this), _amount);
}else{
require(msg.value >= _amount, "StarBlockCollection: not enough ETH!");
shouldChargedETH = _amount;
}
if (msg.value > shouldChargedETH) {
success = _transferETH(payable(msg.sender), msg.value - shouldChargedETH);
}
require(success, "StarBlockCollection: charge failed!");
}
function supportsInterface(bytes4 _interfaceId) public view virtual override(IStarBlockCollection, ERC2981, ERC721A) returns (bool) {
return _interfaceId == type(IStarBlockCollection).interfaceId
|| _interfaceId == type(IERC721).interfaceId
|| _interfaceId == type(IERC721Metadata).interfaceId
|| _interfaceId == type(IERC721A).interfaceId
|| _interfaceId == type(IERC721AQueryable).interfaceId
|| ERC2981.supportsInterface(_interfaceId)
|| ERC721A.supportsInterface(_interfaceId);
}
function _baseURI() internal view virtual override returns (string memory) {
return baseTokenURI;
}
function setBaseURI(string calldata _baseTokenURI) external onlyOwner nonReentrant {
baseTokenURI = _baseTokenURI;
}
function addWhitelists(address[] memory addresses) external onlyOwner nonReentrant {
require(whitelistSaleConfig.startTime > 0 && whitelistSaleConfig.maxAmountPerAddress > 0, "StarBlockCollection: error whitelist sale config!");
require(addresses.length > 0, "StarBlockCollection: addresses can not be empty!");
for (uint256 i = 0; i < addresses.length; i++) {
if(!whitelist[addresses[i]]){
whitelist[addresses[i]] = true;
whitelistAmount ++;
}
}
}
function removeWhitelists(address[] memory addresses) external onlyOwner nonReentrant {
require(addresses.length > 0, "StarBlockCollection: addresses can not be empty!");
for (uint256 i = 0; i < addresses.length; i++) {
if(whitelist[addresses[i]]){
whitelist[addresses[i]] = false;
whitelistAmount --;
}
}
}
function setWhitelistAllowed(address[] memory addresses, uint256[] memory allowedAmounts) external onlyOwner nonReentrant {
require(whitelistSaleConfig.startTime > 0 && whitelistSaleConfig.maxAmountPerAddress == 0, "StarBlockCollection: error whitelist sale config!");
require(addresses.length > 0 && addresses.length == allowedAmounts.length, "StarBlockCollection: error parameters!");
for (uint256 i = 0; i < addresses.length; i++) {
address addr = addresses[i];
uint256 amount = allowedAmounts[i];
if(amount > 0){
if(whitelistAllowed[addr] == 0){
whitelistAmount ++;
}
whitelistAllowed[addr] = amount;
}
}
}
function removeWhitelistAllowed(address[] memory addresses) external onlyOwner nonReentrant {
require(addresses.length > 0, "StarBlockCollection: error parameters!");
for (uint256 i = 0; i < addresses.length; i++) {
address addr = addresses[i];
if(whitelistAllowed[addr] > 0){
whitelistAllowed[addr] = 0;
whitelistAmount --;
}
}
}
function setInfo(IERC20 _chargeToken, SaleConfig memory _whitelistSaleConfig,
SaleConfig memory _publicSaleConfig,
address _royaltyReceiver, uint96 _royaltyFeeNumerator) external onlyOwner nonReentrant {
updateChargeToken(_chargeToken);
updateWhitelistSaleConfig(_whitelistSaleConfig);
updatePublicSaleConfig(_publicSaleConfig);
if(_royaltyReceiver != address(0)){
_setDefaultRoyalty(_royaltyReceiver, _royaltyFeeNumerator);
}
}
function _checkSaleConfig(SaleConfig memory _saleConfig) internal pure returns (bool) {
return (_saleConfig.startTime == 0 || (_saleConfig.endTime == 0 || (_saleConfig.startTime < _saleConfig.endTime)));
}
function updateWhitelistSaleConfig(SaleConfig memory _whitelistSaleConfig) public onlyOwner {
require(whitelistSaleConfig.startTime == 0 || whitelistSaleConfig.startTime > block.timestamp, "StarBlockCollection: can only change the unstarted sale config!");
require(_whitelistSaleConfig.startTime == 0 || _whitelistSaleConfig.startTime > block.timestamp, "StarBlockCollection: the new config should not be started!");
require(_whitelistSaleConfig.startTime < (block.timestamp + 180 days), "StarBlockCollection: start time should be within 180 days!");
require(_whitelistSaleConfig.endTime < (block.timestamp + 900 days), "StarBlockCollection: end time should be within 900 days!");
require(_checkSaleConfig(_whitelistSaleConfig), "StarBlockCollection: invalid parameters!");
whitelistSaleConfig.startTime = _whitelistSaleConfig.startTime;
whitelistSaleConfig.endTime = _whitelistSaleConfig.endTime;
whitelistSaleConfig.price = _whitelistSaleConfig.price;
whitelistSaleConfig.maxAmountPerAddress = _whitelistSaleConfig.maxAmountPerAddress;
emit UpdateWhitelistSaleConfig(_whitelistSaleConfig);
}
function updateWhitelistSaleEndTime(uint256 _newEndTime) external onlyOwner nonReentrant {
require(whitelistSaleConfig.startTime > 0 && whitelistSaleConfig.startTime < _newEndTime, "StarBlockCollection: the new end time should be greater than start time!");
whitelistSaleConfig.endTime = _newEndTime;
emit UpdateWhitelistSaleEndTime(whitelistSaleConfig.endTime, _newEndTime);
}
function updatePublicSaleConfig(SaleConfig memory _publicSaleConfig) public onlyOwner {
require(publicSaleConfig.startTime == 0 || publicSaleConfig.startTime > block.timestamp, "StarBlockCollection: can only change the unstarted sale config!");
require(_publicSaleConfig.startTime == 0 || _publicSaleConfig.startTime > block.timestamp, "StarBlockCollection: the new config should not be started!");
require(_publicSaleConfig.startTime < (block.timestamp + 180 days), "StarBlockCollection: start time should be within 180 days!");
require(_publicSaleConfig.endTime < (block.timestamp + 900 days), "StarBlockCollection: end time should be within 900 days!");
require(_checkSaleConfig(_publicSaleConfig), "StarBlockCollection: invalid parameters!");
publicSaleConfig.startTime = _publicSaleConfig.startTime;
publicSaleConfig.endTime = _publicSaleConfig.endTime;
publicSaleConfig.price = _publicSaleConfig.price;
publicSaleConfig.maxAmountPerAddress = _publicSaleConfig.maxAmountPerAddress;
emit UpdatePublicSaleConfig(_publicSaleConfig);
}
function updatePublicSaleEndTime(uint256 _newEndTime) external onlyOwner nonReentrant {
require(publicSaleConfig.startTime > 0 && publicSaleConfig.startTime < _newEndTime, "StarBlockCollection: the new end time should be greater than start time!");
publicSaleConfig.endTime = _newEndTime;
emit UpdatePublicSaleEndTime(publicSaleConfig.endTime, _newEndTime);
}
function updateChargeToken(IERC20 _chargeToken) public onlyOwner {
require(whitelistSaleConfig.startTime == 0 || whitelistSaleConfig.startTime > block.timestamp, "StarBlockCollection: whitelist sale has started!");
require(publicSaleConfig.startTime == 0 || publicSaleConfig.startTime > block.timestamp, "StarBlockCollection: public sale has started!");
chargeToken = _chargeToken;
emit UpdateChargeToken(_chargeToken);
}
function updateProtocolFeeReceiverAndNumerator(address payable _protocolFeeReceiver, uint256 _protocolFeeNumerator) external nonReentrant {
require(msg.sender == protocolFeeReceiver, "StarBlockCollection: only protocolFeeReceiver can set!");
require(_protocolFeeReceiver != address(0), "StarBlockCollection: _protocolFeeReceiver can not be zero!");
require(_protocolFeeNumerator <= protocolFeeNumerator, "StarBlockCollection: can only set lower protocol fee numerator!");
protocolFeeReceiver = _protocolFeeReceiver;
protocolFeeNumerator = _protocolFeeNumerator;
}
function withdrawMoney() external onlyOwner {
uint256 revenue = _getRevenueAmount();
uint256 artistRevenue = revenue;
uint256 protocolFee = 0;
if(protocolFeeNumerator > 0 && revenue > 0){
protocolFee = revenue * protocolFeeNumerator / _feeDenominator();
artistRevenue = revenue - protocolFee;
}
bool success = false;
if(artistRevenue > 0){
success = _transferRevenue(payable(owner()), artistRevenue);
}
if(success && protocolFee > 0){
success = _transferRevenue(protocolFeeReceiver, protocolFee);
}
require(success, "StarBlockCollection: withdrawMoney failed!");
}
function _getRevenueAmount() internal view returns (uint256 _amount){
if(address(chargeToken) != address(0)){
_amount = chargeToken.balanceOf(address(this));
}else{
_amount = address(this).balance;
}
}
function _transferRevenue(address payable _user, uint256 _amount) internal nonReentrant returns (bool _success) {
if(address(chargeToken) != address(0)){
chargeToken.safeTransfer(_user, _amount);
_success = true;
}else{
_success = _transferETH(_user, _amount);
}
}
function _transferETH(address payable _user, uint256 _amount) internal returns (bool _success) {
(_success, ) = _user.call{value: _amount}("");
}
function setDefaultRoyalty(address _receiver, uint96 _feeNumerator) public onlyOwner nonReentrant {
_setDefaultRoyalty(_receiver, _feeNumerator);
}
function deleteDefaultRoyalty() external onlyOwner nonReentrant {
_deleteDefaultRoyalty();
}
function exists(uint256 _tokenId) external view returns (bool) {
return _exists(_tokenId);
}
}
interface IStarBlockCollectionFactory {
event CollectionDeployed(IStarBlockCollection _collection, address _user, string _uuid);
function collections(IStarBlockCollection _collection) external view returns (address);
function collectionsAmount() external view returns (uint256);
function collectionProtocolFeeReceiver() external view returns (address payable);
function collectionProtocolFeeNumerator() external view returns (uint256);
function deployCollection(
string memory _uuid,
string memory _name,
string memory _symbol,
uint256 _maxSupply,
IERC20 _chargeToken,
string memory _baseTokenURI,
uint256 _maxAmountForArtist,
address _royaltyReceiver,
uint96 _royaltyFeeNumerator
) external returns (IStarBlockCollection _collection);
}
contract StarBlockCollectionFactory is IStarBlockCollectionFactory, Ownable, ReentrancyGuard {
uint256 public constant FEE_DENOMINATOR = 10000;
mapping(IStarBlockCollection => address) public collections;
uint256 public collectionsAmount;
address payable public collectionProtocolFeeReceiver;
uint256 public collectionProtocolFeeNumerator;
constructor(
address payable _collectionProtocolFeeReceiver,
uint256 _collectionProtocolFeeNumerator
) {
require(_collectionProtocolFeeReceiver != address(0) && _collectionProtocolFeeNumerator <= FEE_DENOMINATOR,
"StarBlockCollectionFactory: invalid parameters!");
collectionProtocolFeeReceiver = _collectionProtocolFeeReceiver;
collectionProtocolFeeNumerator = _collectionProtocolFeeNumerator;
}
function deployCollection(
string memory _uuid,
string memory _name,
string memory _symbol,
uint256 _maxSupply,
IERC20 _chargeToken,
string memory _baseTokenURI,
uint256 _maxAmountForArtist,
address _royaltyReceiver,
uint96 _royaltyFeeNumerator
) external nonReentrant returns (IStarBlockCollection _collection) {
_collection = new StarBlockCollection(_name, _symbol, _maxSupply, _chargeToken, _baseTokenURI,
_maxAmountForArtist, collectionProtocolFeeReceiver, collectionProtocolFeeNumerator,
_royaltyReceiver, _royaltyFeeNumerator);
Ownable(address(_collection)).transferOwnership(msg.sender);
collections[_collection] = msg.sender;
collectionsAmount ++;
emit CollectionDeployed(_collection, msg.sender, _uuid);
}
function updateCollectionProtocolFeeReceiverAndNumerator(address payable _collectionProtocolFeeReceiver,
uint256 _collectionProtocolFeeNumerator) external onlyOwner nonReentrant {
require(_collectionProtocolFeeReceiver != address(0), "StarBlockCollectionFactory: _collectionProtocolFeeReceiver can not be zero!");
require(_collectionProtocolFeeNumerator <= FEE_DENOMINATOR, "StarBlockCollectionFactory: _collectionProtocolFeeNumerator should not be greater than 10000!");
collectionProtocolFeeReceiver = _collectionProtocolFeeReceiver;
collectionProtocolFeeNumerator = _collectionProtocolFeeNumerator;
}
}
{
"compilationTarget": {
"StarBlockCollection.sol": "StarBlockCollection"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint256","name":"_maxSupply","type":"uint256"},{"internalType":"contract IERC20","name":"_chargeToken","type":"address"},{"internalType":"string","name":"_baseTokenURI","type":"string"},{"internalType":"uint256","name":"_maxAmountForArtist","type":"uint256"},{"internalType":"address payable","name":"_protocolFeeReceiver","type":"address"},{"internalType":"uint256","name":"_protocolFeeNumerator","type":"uint256"},{"internalType":"address","name":"_royaltyReceiver","type":"address"},{"internalType":"uint96","name":"_royaltyFeeNumerator","type":"uint96"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"ApprovalQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"ApproveToCaller","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[],"name":"InvalidQueryRange","type":"error"},{"inputs":[],"name":"MintERC2309QuantityExceedsLimit","type":"error"},{"inputs":[],"name":"MintToZeroAddress","type":"error"},{"inputs":[],"name":"MintZeroQuantity","type":"error"},{"inputs":[],"name":"OwnerQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"OwnershipNotInitializedForExtraData","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"},{"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":"fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toTokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"ConsecutiveTransfer","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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20","name":"_chargeToken","type":"address"}],"name":"UpdateChargeToken","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"maxAmountPerAddress","type":"uint256"}],"indexed":false,"internalType":"struct IStarBlockCollection.SaleConfig","name":"_publicSaleConfig","type":"tuple"}],"name":"UpdatePublicSaleConfig","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_oldEndTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_newEndTime","type":"uint256"}],"name":"UpdatePublicSaleEndTime","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"maxAmountPerAddress","type":"uint256"}],"indexed":false,"internalType":"struct IStarBlockCollection.SaleConfig","name":"_whitelistSaleConfig","type":"tuple"}],"name":"UpdateWhitelistSaleConfig","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_oldEndTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_newEndTime","type":"uint256"}],"name":"UpdateWhitelistSaleEndTime","type":"event"},{"inputs":[{"internalType":"address[]","name":"addresses","type":"address[]"}],"name":"addWhitelists","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"artistMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"artistMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"chargeToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deleteDefaultRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"exists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"explicitOwnershipOf","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"bool","name":"burned","type":"bool"},{"internalType":"uint24","name":"extraData","type":"uint24"}],"internalType":"struct IERC721A.TokenOwnership","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"explicitOwnershipsOf","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"bool","name":"burned","type":"bool"},{"internalType":"uint24","name":"extraData","type":"uint24"}],"internalType":"struct IERC721A.TokenOwnership[]","name":"","type":"tuple[]"}],"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":[],"name":"maxAmountForArtist","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":"protocolFeeNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolFeeReceiver","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"publicMint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"publicSaleConfig","outputs":[{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"maxAmountPerAddress","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"publicSaleMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"addresses","type":"address[]"}],"name":"removeWhitelistAllowed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"addresses","type":"address[]"}],"name":"removeWhitelists","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"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":"_baseTokenURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint96","name":"_feeNumerator","type":"uint96"}],"name":"setDefaultRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_chargeToken","type":"address"},{"components":[{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"maxAmountPerAddress","type":"uint256"}],"internalType":"struct IStarBlockCollection.SaleConfig","name":"_whitelistSaleConfig","type":"tuple"},{"components":[{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"maxAmountPerAddress","type":"uint256"}],"internalType":"struct IStarBlockCollection.SaleConfig","name":"_publicSaleConfig","type":"tuple"},{"internalType":"address","name":"_royaltyReceiver","type":"address"},{"internalType":"uint96","name":"_royaltyFeeNumerator","type":"uint96"}],"name":"setInfo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint256[]","name":"allowedAmounts","type":"uint256[]"}],"name":"setWhitelistAllowed","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":[{"internalType":"address","name":"owner","type":"address"}],"name":"tokensOfOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"stop","type":"uint256"}],"name":"tokensOfOwnerIn","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":[{"internalType":"contract IERC20","name":"_chargeToken","type":"address"}],"name":"updateChargeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_protocolFeeReceiver","type":"address"},{"internalType":"uint256","name":"_protocolFeeNumerator","type":"uint256"}],"name":"updateProtocolFeeReceiverAndNumerator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"maxAmountPerAddress","type":"uint256"}],"internalType":"struct IStarBlockCollection.SaleConfig","name":"_publicSaleConfig","type":"tuple"}],"name":"updatePublicSaleConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newEndTime","type":"uint256"}],"name":"updatePublicSaleEndTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"maxAmountPerAddress","type":"uint256"}],"internalType":"struct IStarBlockCollection.SaleConfig","name":"_whitelistSaleConfig","type":"tuple"}],"name":"updateWhitelistSaleConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newEndTime","type":"uint256"}],"name":"updateWhitelistSaleEndTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"userCanMintTotalAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistAllowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"whitelistAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"whitelistMint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"whitelistSaleConfig","outputs":[{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"maxAmountPerAddress","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistSaleMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawMoney","outputs":[],"stateMutability":"nonpayable","type":"function"}]