编译器
0.8.22+commit.4fc1097e
文件 1 的 17:ART0x1.sol
pragma solidity ^0.8.22;
import "sstore2/contracts/SSTORE2.sol";
import {IERC721} from "openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IART0x1} from "./interfaces/IART0x1.sol";
import {ART0x1Types} from "./ART0x1Types.sol";
import {ERC721Base} from "./ERC721Base.sol";
contract ART0x1 is ERC721Base {
address[] public programAddresses;
mapping(uint => uint) public tokenToProgramAddress;
bool public earlyMintActive;
bool public publicMintActive;
address public preRevealInstructions;
mapping(uint => address) public tokenInstructions;
mapping(uint => ART0x1Types.Gallery) public galleries;
mapping(uint => address) public galleryToCurator;
mapping(uint => mapping(address => bool)) public isArtistInvitedToGallery;
mapping(uint => bool) public isGalleryRevealed;
mapping(uint => uint) public tokenToGalleryId;
mapping(uint => uint[]) public tokenToVisitedGalleries;
bool public isGalleryCurationPermissionless;
address[] public gfxModuleAddresses;
mapping(address => ART0x1Types.GfxModule) public gfxModules;
mapping(uint => address) public tokenToGfxModuleAddress;
mapping(uint => uint) public tokenToGfxModuleUint;
mapping(uint => string) public tokenToGfxModuleString;
mapping(uint => address[]) public tokenToExecutedGfxModules;
constructor() ERC721Base("ART0x1", "ART0X1", 0.068 ether, 1024) {}
function addProgramAddress(address _newAddress) public onlyOwner {
programAddresses.push(_newAddress);
}
function setTokenProgramAddress(
uint[] memory _tokenIds,
uint _index
) public {
require(
_index < programAddresses.length,
"ART0x1: no program at _index."
);
for (uint i; i < _tokenIds.length; i++) {
require(
msg.sender == ownerOf(_tokenIds[i]),
"ART0x1: one or more tokens are not yours."
);
tokenToProgramAddress[_tokenIds[i]] = _index;
}
}
function toggleEarly() public onlyOwner {
require(
programAddresses.length > 0 && preRevealInstructions != address(0),
"ART0x1: program not configured."
);
earlyMintActive = !earlyMintActive;
}
function togglePublic() public onlyOwner {
publicMintActive = !publicMintActive;
}
function mintAdmin(
uint _numToBeMinted
) external onlyOwner withinMintLimit(6, _numToBeMinted) nonReentrant {
require(
programAddresses.length > 0 && preRevealInstructions != address(0),
"ART0x1: program not configured."
);
_mintMany(_msgSender(), _numToBeMinted);
}
function mintEarly(
uint _numToBeMinted
)
external
payable
hasExactPayment(_numToBeMinted)
withinMintLimit(3, _numToBeMinted)
nonReentrant
{
require(earlyMintActive, "ART0x1: cannot mint yet.");
require(
IERC721(0x4E1f41613c9084FdB9E34E11fAE9412427480e56).balanceOf(
msg.sender
) > 0,
"ART0x1: need Terraforms to mint early."
);
_mintMany(_msgSender(), _numToBeMinted);
}
function mint(
uint _numToBeMinted
)
external
payable
hasExactPayment(_numToBeMinted)
withinMintLimit(3, _numToBeMinted)
nonReentrant
{
require(publicMintActive, "ART0x1: public cannot mint yet.");
_mintMany(_msgSender(), _numToBeMinted);
}
function setPreRevealInstructions(
string[12] memory _instructions
) public onlyOwner {
preRevealInstructions = storeInstructions(_instructions);
}
function setTokenInstructions(
uint _tokenId,
string[12] memory _instructions
) public {
require(_exists(_tokenId), "ART0x1: token does not exist.");
require(ownerOf(_tokenId) == msg.sender, "ART0x1: not your token.");
require(
isGalleryRevealed[0] == true,
"ART0x1: cannot set instructions until after genesis reveal."
);
tokenInstructions[_tokenId] = storeInstructions(_instructions);
}
function getTokenInstructions(
uint _tokenId
) public view returns (string[12] memory) {
require(_exists(_tokenId), "ART0x1: token does not exist.");
require(
tokenInstructions[_tokenId] != address(0),
"ART0x1: token instructions not set."
);
bytes memory instr = SSTORE2.read(tokenInstructions[_tokenId]);
bytes[12] memory byteStrings = abi.decode(instr, (bytes[12]));
string[12] memory result;
for (uint i = 0; i < byteStrings.length; ) {
result[i] = string(byteStrings[i]);
unchecked {
++i;
}
}
return result;
}
function clearTokenInstructions(uint[] memory _tokenIds) public {
for (uint i = 0; i < _tokenIds.length; ) {
uint tokenId = _tokenIds[i];
require(_exists(tokenId), "ART0x1: token does not exist.");
require(ownerOf(tokenId) == msg.sender, "ART0x1: not your token.");
tokenInstructions[tokenId] = address(0);
unchecked {
++i;
}
}
}
function assignGalleryCurator(
uint _galleryIndex,
address _curatorAddress
) public {
if (!isGalleryCurationPermissionless) {
require(
owner() == msg.sender,
"ART0x1: only owner can assign gallery curators."
);
}
require(
galleryToCurator[_galleryIndex] == address(0),
"ART0x1: _galleryIndex is taken."
);
galleryToCurator[_galleryIndex] = _curatorAddress;
}
function inviteGalleryArtists(
uint _galleryIndex,
address[] memory _artistAddressList
) public {
require(
galleryToCurator[_galleryIndex] == msg.sender,
"ART0x1: only curator of _galleryIndex can invite artists."
);
uint len = _artistAddressList.length;
for (uint i = 0; i < len; ) {
isArtistInvitedToGallery[_galleryIndex][
_artistAddressList[i]
] = true;
unchecked {
i++;
}
}
}
function addGalleryItem(
uint _galleryIndex,
string[12] memory _instructions
) public {
require(
isArtistInvitedToGallery[_galleryIndex][msg.sender],
"ART0x1: only invited artists can add to gallery"
);
address data = storeInstructions(_instructions);
galleries[_galleryIndex].instructions.push(data);
galleries[_galleryIndex].artists.push(msg.sender);
}
function addGalleryItems(
uint _galleryIndex,
string[12][] memory _instructionsList
) public {
require(
!isGalleryRevealed[_galleryIndex],
"ART0x1: gallery already revealed, cannot add instructions."
);
for (uint i = 0; i < _instructionsList.length; i++) {
require(
isArtistInvitedToGallery[_galleryIndex][msg.sender],
"ART0x1: only invited artists can add to gallery"
);
}
uint len = _instructionsList.length;
for (uint i = 0; i < len; ) {
addGalleryItem(_galleryIndex, _instructionsList[i]);
unchecked {
i++;
}
}
}
function revealGallery(
uint _galleryIndex,
string memory _name,
uint _price
) public {
require(
galleryToCurator[_galleryIndex] == msg.sender,
"ART0x1: only gallery curator can reveal."
);
require(
(!isGalleryRevealed[_galleryIndex]),
"ART0x1: gallery at _galleryIndex already revealed."
);
uint instructionsLength = galleries[_galleryIndex].instructions.length;
require(
instructionsLength != 0,
"ART0x1: gallery at _galleryIndex is empty."
);
galleries[_galleryIndex].name = _name;
galleries[_galleryIndex].price = _price;
galleries[_galleryIndex].curator = msg.sender;
address[] storage instructions = galleries[_galleryIndex].instructions;
address[] storage artists = galleries[_galleryIndex].artists;
for (uint i = instructionsLength - 1; i > 0; i--) {
uint j = uint(
keccak256(
abi.encodePacked(
block.timestamp,
blockhash(block.number - 1),
i
)
)
) % (i + 1);
address tempInstruction = instructions[i];
instructions[i] = instructions[j];
instructions[j] = tempInstruction;
address tempArtist = artists[i];
artists[i] = artists[j];
artists[j] = tempArtist;
}
isGalleryRevealed[_galleryIndex] = true;
}
function setTokenGallery(
uint _tokenId,
uint _galleryIndex
) public payable nonReentrant {
require(
isGalleryRevealed[0],
"ART0x1: cannot set new gallery before genesis reveal."
);
require(
galleries[_galleryIndex].instructions.length > 0 &&
isGalleryRevealed[_galleryIndex],
"ART0x1: gallery does not exist or is not yet revealed."
);
require(_exists(_tokenId), "ART0x1: token does not exist.");
require(ownerOf(_tokenId) == msg.sender, "ART0x1: not your token.");
bool previouslyVisited = false;
for (uint i = 0; i < tokenToVisitedGalleries[_tokenId].length; ) {
if (tokenToVisitedGalleries[_tokenId][i] == _galleryIndex) {
previouslyVisited = true;
break;
}
unchecked {
++i;
}
}
uint galleryPrice = galleries[_galleryIndex].price;
if (!previouslyVisited) {
require(msg.value >= galleryPrice, "ART0x1: insufficient payment.");
}
tokenToGalleryId[_tokenId] = _galleryIndex;
tokenInstructions[_tokenId] = address(0);
if (!previouslyVisited) {
tokenToVisitedGalleries[_tokenId].push(_galleryIndex);
}
if (msg.value > galleryPrice) {
payable(msg.sender).transfer(msg.value - galleryPrice);
}
if (galleryPrice > 0 && !previouslyVisited) {
uint fee = (galleryPrice * 2) / 100;
uint amountToCurator = galleryPrice - fee;
address curatorAddress = galleries[_galleryIndex].curator;
payable(curatorAddress).transfer(amountToCurator);
}
}
function listGfxModule(
string memory _name,
address _moduleAddress,
uint _price
) public {
require(
gfxModules[_moduleAddress].moduleAddress == address(0),
"Module already listed for this address"
);
ART0x1Types.GfxModule memory newModule = ART0x1Types.GfxModule(
_name,
msg.sender,
_moduleAddress,
_price
);
gfxModuleAddresses.push(_moduleAddress);
gfxModules[_moduleAddress] = newModule;
}
function getGfxModuleByIndex(
uint _index
) public view returns (ART0x1Types.GfxModule memory) {
require(
_index < gfxModuleAddresses.length,
"ART0x1: gfx module does not exist."
);
address moduleAddress = gfxModuleAddresses[_index];
return gfxModules[moduleAddress];
}
function getGfxModules()
public
view
returns (ART0x1Types.GfxModule[] memory)
{
ART0x1Types.GfxModule[] memory modules = new ART0x1Types.GfxModule[](
gfxModuleAddresses.length
);
for (uint i = 0; i < gfxModuleAddresses.length; i++) {
modules[i] = gfxModules[gfxModuleAddresses[i]];
}
return modules;
}
function setTokenGfxModule(
uint _tokenId,
address _gfxModuleAddress,
uint _uint,
string memory _string
) public payable nonReentrant {
require(_exists(_tokenId), "ART0x1: token does not exist.");
require(ownerOf(_tokenId) == msg.sender, "ART0x1: not your token.");
require(
gfxModules[_gfxModuleAddress].moduleAddress != address(0),
"ART0x1: gfx module does not exist."
);
require(
isGalleryRevealed[0],
"ART0x1: cannot set modules until after genesis gallery reveal."
);
if (gfxModuleAddresses[0] == _gfxModuleAddress) {
require(
IERC721(0x4E1f41613c9084FdB9E34E11fAE9412427480e56).ownerOf(
_uint
) == msg.sender,
"ART0x1: not your terraforms token."
);
}
bool previouslyExecuted = false;
for (uint i = 0; i < tokenToExecutedGfxModules[_tokenId].length; ) {
if (tokenToExecutedGfxModules[_tokenId][i] == _gfxModuleAddress) {
previouslyExecuted = true;
break;
}
unchecked {
++i;
}
}
uint modulePrice = gfxModules[_gfxModuleAddress].price;
if (!previouslyExecuted) {
require(msg.value >= modulePrice, "ART0x1: insufficient payment.");
}
tokenToGfxModuleAddress[_tokenId] = _gfxModuleAddress;
tokenToGfxModuleUint[_tokenId] = _uint;
tokenToGfxModuleString[_tokenId] = _string;
if (!previouslyExecuted) {
tokenToExecutedGfxModules[_tokenId].push(_gfxModuleAddress);
}
if (msg.value > modulePrice) {
payable(msg.sender).transfer(msg.value - modulePrice);
}
if (modulePrice > 0 && !previouslyExecuted) {
uint fee = (modulePrice * 2) / 100;
uint amountToAuthor = modulePrice - fee;
address authorAddress = gfxModules[_gfxModuleAddress].authorAddress;
payable(authorAddress).transfer(amountToAuthor);
}
}
function resetTokenGfxModule(uint[] memory _tokenIds) public {
for (uint i = 0; i < _tokenIds.length; ) {
uint tokenId = _tokenIds[i];
require(_exists(tokenId), "ART0x1: token does not exist.");
require(ownerOf(tokenId) == msg.sender, "ART0x1: not your token.");
tokenToGfxModuleAddress[tokenId] = address(0);
tokenToGfxModuleUint[tokenId] = 0;
tokenToGfxModuleString[tokenId] = "";
unchecked {
++i;
}
}
}
function tokenHTML(uint _tokenId) public view returns (string memory) {
require(_exists(_tokenId), "ART0x1: token does not exist.");
return getTokenProgram(_tokenId).tokenHTML(getTokenContext(_tokenId));
}
function tokenSVG(uint _tokenId) public view returns (string memory) {
require(_exists(_tokenId), "ART0x1: token does not exist.");
return getTokenProgram(_tokenId).tokenSVG(getTokenContext(_tokenId));
}
function tokenURI(
uint _tokenId
) public view override returns (string memory) {
require(_exists(_tokenId), "ART0x1: token does not exist.");
return getTokenProgram(_tokenId).tokenURI(getTokenContext(_tokenId));
}
function getTokenProgram(uint _tokenId) private view returns (IART0x1) {
return IART0x1(programAddresses[tokenToProgramAddress[_tokenId]]);
}
function getTokenContext(
uint _tokenId
) internal view returns (ART0x1Types.TokenCtx memory tokenCtx) {
tokenCtx.id = _tokenId;
tokenCtx.prn = tokenToPRN[_tokenId];
tokenCtx.galleryId = tokenToGalleryId[_tokenId];
ART0x1Types.Gallery memory gallery = galleries[tokenCtx.galleryId];
if (!isGalleryRevealed[0]) {
tokenCtx.instructions = abi.decode(
SSTORE2.read(preRevealInstructions),
(bytes[12])
);
tokenCtx.mode = ART0x1Types.Mode.PRE_REVEAL;
} else {
address instructionsAddress = tokenInstructions[_tokenId];
uint galleryItemCount = gallery.instructions.length;
if (instructionsAddress != address(0)) {
tokenCtx.instructions = abi.decode(
SSTORE2.read(instructionsAddress),
(bytes[12])
);
tokenCtx.mode = ART0x1Types.Mode.ORIGINAL;
tokenCtx.artistAddress = ownerOf(_tokenId);
} else {
tokenCtx.instructions = abi.decode(
SSTORE2.read(
gallery.instructions[tokenCtx.prn % galleryItemCount]
),
(bytes[12])
);
tokenCtx.mode = ART0x1Types.Mode.GALLERY;
tokenCtx.artistAddress = gallery.artists[
tokenCtx.prn % galleryItemCount
];
tokenCtx.galleryName = gallery.name;
tokenCtx.galleryCurator = galleryToCurator[tokenCtx.galleryId];
}
}
(
tokenCtx.gfx.colors,
tokenCtx.gfx.fontName,
tokenCtx.gfx.fontFilename,
tokenCtx.gfx.fontSize
) = getTokenPresetGfx(tokenCtx.prn);
address gfxModuleAddress = tokenToGfxModuleAddress[_tokenId];
ART0x1Types.GfxModule memory gfxModule = gfxModules[gfxModuleAddress];
tokenCtx.moduleName = gfxModule.name;
tokenCtx.moduleAuthor = gfxModule.authorAddress;
tokenCtx.moduleAddress = gfxModuleAddress;
tokenCtx.moduleUint = tokenToGfxModuleUint[_tokenId];
tokenCtx.moduleString = tokenToGfxModuleString[_tokenId];
}
function getTokenPresetGfx(
uint _prn
)
internal
pure
returns (
string[3] memory _colors,
string memory _fontName,
string memory _fontFilename,
string memory _fontSize
)
{
string[12] memory presetColorsOpts = [
"#f4f4f4",
"#262626",
"#8d8d8d29",
"#161616",
"#161616",
"#c6c6c6",
"#6f6f6f",
"#8d8d8d",
"#161616",
"#c6c6c6",
"#6f6f6f",
"#8d8d8d"
];
uint colorId = _prn % 4;
_colors[0] = presetColorsOpts[colorId];
_colors[1] = presetColorsOpts[4 + colorId];
_colors[2] = presetColorsOpts[8 + colorId];
_fontName = "IBM Plex Mono";
_fontFilename = "IBMPlexMono-Regular.woff2";
_fontSize = "12px";
}
function storeInstructions(
string[12] memory _instructions
) internal returns (address) {
bytes[12] memory bytesInstructions;
for (uint i = 0; i < _instructions.length; ) {
bytesInstructions[i] = bytes(_instructions[i]);
unchecked {
++i;
}
}
return SSTORE2.write(abi.encode(bytesInstructions));
}
}
文件 2 的 17:ART0x1Types.sol
pragma solidity ^0.8.22;
library ART0x1Types {
enum Mode {
PRE_REVEAL,
ORIGINAL,
GALLERY
}
struct InitInstructions {
bytes1 sym1;
bytes1 sym2;
uint nCol;
uint mCol;
string title;
}
struct ShapeInstructions {
bytes1 sym;
uint8 arr;
int16 row;
int16 col;
int16 nR;
int16 nC;
int16[] repeatRows;
int16[] repeatCols;
}
struct Gallery {
string name;
uint price;
address curator;
address[] instructions;
address[] artists;
}
struct GfxModule {
string name;
address authorAddress;
address moduleAddress;
uint price;
}
struct TokenGfx {
string[3] colors;
string fontName;
string fontFilename;
string fontSize;
}
struct TokenCtx {
uint id;
uint prn;
uint galleryId;
uint moduleUint;
address artistAddress;
address galleryCurator;
address moduleAuthor;
address moduleAddress;
bytes[12] instructions;
TokenGfx gfx;
Mode mode;
string galleryName;
string moduleName;
string moduleString;
}
}
文件 3 的 17:Bytecode.sol
pragma solidity ^0.8.0;
library Bytecode {
error InvalidCodeAtRange(uint256 _size, uint256 _start, uint256 _end);
function creationCodeFor(bytes memory _code) internal pure returns (bytes memory) {
return abi.encodePacked(
hex"63",
uint32(_code.length),
hex"80_60_0E_60_00_39_60_00_F3",
_code
);
}
function codeSize(address _addr) internal view returns (uint256 size) {
assembly { size := extcodesize(_addr) }
}
function codeAt(address _addr, uint256 _start, uint256 _end) internal view returns (bytes memory oCode) {
uint256 csize = codeSize(_addr);
if (csize == 0) return bytes("");
if (_start > csize) return bytes("");
if (_end < _start) revert InvalidCodeAtRange(csize, _start, _end);
unchecked {
uint256 reqSize = _end - _start;
uint256 maxSize = csize - _start;
uint256 size = maxSize < reqSize ? maxSize : reqSize;
assembly {
oCode := mload(0x40)
mstore(0x40, add(oCode, and(add(add(size, 0x20), 0x1f), not(0x1f))))
mstore(oCode, size)
extcodecopy(_addr, add(oCode, 0x20), _start, size)
}
}
}
}
文件 4 的 17:Context.sol
pragma solidity ^0.8.20;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
文件 5 的 17:ERC165.sol
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
abstract contract ERC165 is IERC165 {
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
文件 6 的 17:ERC2981.sol
pragma solidity ^0.8.20;
import {IERC2981} from "../../interfaces/IERC2981.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
abstract contract ERC2981 is IERC2981, ERC165 {
struct RoyaltyInfo {
address receiver;
uint96 royaltyFraction;
}
RoyaltyInfo private _defaultRoyaltyInfo;
mapping(uint256 tokenId => RoyaltyInfo) private _tokenRoyaltyInfo;
error ERC2981InvalidDefaultRoyalty(uint256 numerator, uint256 denominator);
error ERC2981InvalidDefaultRoyaltyReceiver(address receiver);
error ERC2981InvalidTokenRoyalty(uint256 tokenId, uint256 numerator, uint256 denominator);
error ERC2981InvalidTokenRoyaltyReceiver(uint256 tokenId, address receiver);
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 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 {
uint256 denominator = _feeDenominator();
if (feeNumerator > denominator) {
revert ERC2981InvalidDefaultRoyalty(feeNumerator, denominator);
}
if (receiver == address(0)) {
revert ERC2981InvalidDefaultRoyaltyReceiver(address(0));
}
_defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);
}
function _deleteDefaultRoyalty() internal virtual {
delete _defaultRoyaltyInfo;
}
function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal virtual {
uint256 denominator = _feeDenominator();
if (feeNumerator > denominator) {
revert ERC2981InvalidTokenRoyalty(tokenId, feeNumerator, denominator);
}
if (receiver == address(0)) {
revert ERC2981InvalidTokenRoyaltyReceiver(tokenId, address(0));
}
_tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);
}
function _resetTokenRoyalty(uint256 tokenId) internal virtual {
delete _tokenRoyaltyInfo[tokenId];
}
}
文件 7 的 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 {
struct TokenApprovalRef {
address value;
}
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;
bytes32 private constant _TRANSFER_EVENT_SIGNATURE =
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;
uint256 private _currentIndex;
uint256 private _burnCounter;
string private _name;
string private _symbol;
mapping(uint256 => uint256) private _packedOwnerships;
mapping(address => uint256) private _packedAddressData;
mapping(uint256 => TokenApprovalRef) 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 virtual returns (uint256) {
return _currentIndex;
}
function totalSupply() public view virtual override returns (uint256) {
unchecked {
return _currentIndex - _burnCounter - _startTokenId();
}
}
function _totalMinted() internal view virtual returns (uint256) {
unchecked {
return _currentIndex - _startTokenId();
}
}
function _totalBurned() internal view virtual returns (uint256) {
return _burnCounter;
}
function balanceOf(address owner) public view virtual override returns (uint256) {
if (owner == address(0)) _revert(BalanceQueryForZeroAddress.selector);
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 virtual {
uint256 packed = _packedAddressData[owner];
uint256 auxCasted;
assembly {
auxCasted := aux
}
packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX);
_packedAddressData[owner] = packed;
}
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return
interfaceId == 0x01ffc9a7 ||
interfaceId == 0x80ac58cd ||
interfaceId == 0x5b5e139f;
}
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.selector);
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 ownerOf(uint256 tokenId) public view virtual override returns (address) {
return address(uint160(_packedOwnershipOf(tokenId)));
}
function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) {
return _unpackedOwnership(_packedOwnershipOf(tokenId));
}
function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) {
return _unpackedOwnership(_packedOwnerships[index]);
}
function _ownershipIsInitialized(uint256 index) internal view virtual returns (bool) {
return _packedOwnerships[index] != 0;
}
function _initializeOwnershipAt(uint256 index) internal virtual {
if (_packedOwnerships[index] == 0) {
_packedOwnerships[index] = _packedOwnershipOf(index);
}
}
function _packedOwnershipOf(uint256 tokenId) private view returns (uint256 packed) {
if (_startTokenId() <= tokenId) {
packed = _packedOwnerships[tokenId];
if (packed == 0) {
if (tokenId >= _currentIndex) _revert(OwnerQueryForNonexistentToken.selector);
for (;;) {
unchecked {
packed = _packedOwnerships[--tokenId];
}
if (packed == 0) continue;
if (packed & _BITMASK_BURNED == 0) return packed;
_revert(OwnerQueryForNonexistentToken.selector);
}
}
if (packed & _BITMASK_BURNED == 0) return packed;
}
_revert(OwnerQueryForNonexistentToken.selector);
}
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 _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 _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) {
assembly {
result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))
}
}
function approve(address to, uint256 tokenId) public payable virtual override {
_approve(to, tokenId, true);
}
function getApproved(uint256 tokenId) public view virtual override returns (address) {
if (!_exists(tokenId)) _revert(ApprovalQueryForNonexistentToken.selector);
return _tokenApprovals[tokenId].value;
}
function setApprovalForAll(address operator, bool approved) public virtual override {
_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 _exists(uint256 tokenId) internal view virtual returns (bool result) {
if (_startTokenId() <= tokenId) {
if (tokenId < _currentIndex) {
uint256 packed;
while ((packed = _packedOwnerships[tokenId]) == 0) --tokenId;
result = packed & _BITMASK_BURNED == 0;
}
}
}
function _isSenderApprovedOrOwner(
address approvedAddress,
address owner,
address msgSender
) private pure returns (bool result) {
assembly {
owner := and(owner, _BITMASK_ADDRESS)
msgSender := and(msgSender, _BITMASK_ADDRESS)
result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))
}
}
function _getApprovedSlotAndAddress(uint256 tokenId)
private
view
returns (uint256 approvedAddressSlot, address approvedAddress)
{
TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId];
assembly {
approvedAddressSlot := tokenApproval.slot
approvedAddress := sload(approvedAddressSlot)
}
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public payable virtual override {
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
from = address(uint160(uint256(uint160(from)) & _BITMASK_ADDRESS));
if (address(uint160(prevOwnershipPacked)) != from) _revert(TransferFromIncorrectOwner.selector);
(uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);
if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
if (!isApprovedForAll(from, _msgSenderERC721A())) _revert(TransferCallerNotOwnerNorApproved.selector);
_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;
}
}
}
}
uint256 toMasked = uint256(uint160(to)) & _BITMASK_ADDRESS;
assembly {
log4(
0,
0,
_TRANSFER_EVENT_SIGNATURE,
from,
toMasked,
tokenId
)
}
if (toMasked == 0) _revert(TransferToZeroAddress.selector);
_afterTokenTransfers(from, to, tokenId, 1);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public payable virtual override {
safeTransferFrom(from, to, tokenId, '');
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public payable virtual override {
transferFrom(from, to, tokenId);
if (to.code.length != 0)
if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {
_revert(TransferToNonERC721ReceiverImplementer.selector);
}
}
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 _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.selector);
}
assembly {
revert(add(32, reason), mload(reason))
}
}
}
function _mint(address to, uint256 quantity) internal virtual {
uint256 startTokenId = _currentIndex;
if (quantity == 0) _revert(MintZeroQuantity.selector);
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
unchecked {
_packedOwnerships[startTokenId] = _packOwnershipData(
to,
_nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
);
_packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);
uint256 toMasked = uint256(uint160(to)) & _BITMASK_ADDRESS;
if (toMasked == 0) _revert(MintToZeroAddress.selector);
uint256 end = startTokenId + quantity;
uint256 tokenId = startTokenId;
do {
assembly {
log4(
0,
0,
_TRANSFER_EVENT_SIGNATURE,
0,
toMasked,
tokenId
)
}
} while (++tokenId != end);
_currentIndex = end;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
function _mintERC2309(address to, uint256 quantity) internal virtual {
uint256 startTokenId = _currentIndex;
if (to == address(0)) _revert(MintToZeroAddress.selector);
if (quantity == 0) _revert(MintZeroQuantity.selector);
if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) _revert(MintERC2309QuantityExceedsLimit.selector);
_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 _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal virtual {
_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.selector);
}
} while (index < end);
if (_currentIndex != end) _revert(bytes4(0));
}
}
}
function _safeMint(address to, uint256 quantity) internal virtual {
_safeMint(to, quantity, '');
}
function _approve(address to, uint256 tokenId) internal virtual {
_approve(to, tokenId, false);
}
function _approve(
address to,
uint256 tokenId,
bool approvalCheck
) internal virtual {
address owner = ownerOf(tokenId);
if (approvalCheck && _msgSenderERC721A() != owner)
if (!isApprovedForAll(owner, _msgSenderERC721A())) {
_revert(ApprovalCallerNotOwnerNorApproved.selector);
}
_tokenApprovals[tokenId].value = to;
emit Approval(owner, to, tokenId);
}
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) = _getApprovedSlotAndAddress(tokenId);
if (approvalCheck) {
if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
if (!isApprovedForAll(from, _msgSenderERC721A())) _revert(TransferCallerNotOwnerNorApproved.selector);
}
_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 _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {
uint256 packed = _packedOwnerships[index];
if (packed == 0) _revert(OwnershipNotInitializedForExtraData.selector);
uint256 extraDataCasted;
assembly {
extraDataCasted := extraData
}
packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA);
_packedOwnerships[index] = packed;
}
function _extraData(
address from,
address to,
uint24 previousExtraData
) internal view virtual returns (uint24) {}
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 _msgSenderERC721A() internal view virtual returns (address) {
return msg.sender;
}
function _toString(uint256 value) internal pure virtual returns (string memory str) {
assembly {
let m := add(mload(0x40), 0xa0)
mstore(0x40, m)
str := sub(m, 0x20)
mstore(str, 0)
let end := str
for { let temp := value } 1 {} {
str := sub(str, 1)
mstore8(str, add(48, mod(temp, 10)))
temp := div(temp, 10)
if iszero(temp) { break }
}
let length := sub(end, str)
str := sub(str, 0x20)
mstore(str, length)
}
}
function _revert(bytes4 errorSelector) internal pure {
assembly {
mstore(0x00, errorSelector)
revert(0x00, 0x04)
}
}
}
文件 8 的 17:ERC721Base.sol
pragma solidity ^0.8.22;
import {IERC721A, ERC721A} from "erc721a/contracts/ERC721A.sol";
import {IERC20} from "openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC2981, ERC2981} from "@openzeppelin/contracts/token/common/ERC2981.sol";
import {Ownable} from "openzeppelin/contracts/access/Ownable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
abstract contract ERC721Base is ERC721A, ERC2981, Ownable, ReentrancyGuard {
uint public immutable price;
uint public immutable maxSupply;
mapping(uint => uint) public tokenToPRN;
bool public operatorFilteringEnabled;
event Initialized();
constructor(
string memory _name,
string memory _symbol,
uint _price,
uint _maxSupply
) Ownable(msg.sender) ERC721A(_name, _symbol) {
price = _price;
maxSupply = _maxSupply;
_setDefaultRoyalty(msg.sender, 200);
emit Initialized();
}
function _startTokenId() internal pure override returns (uint) {
return 1;
}
function totalMinted() public view returns (uint) {
return _totalMinted();
}
error MintLimitExceeded(uint limit);
error MintSupplyExceeded(uint supply);
error WrongPayment();
modifier withinMintLimit(uint limit, uint numToBeMinted) {
if (_numberMinted(_msgSender()) + numToBeMinted > limit) {
revert MintLimitExceeded(limit);
}
_;
}
modifier withinSupply(
uint supply,
uint numMinted,
uint numToBeMinted
) {
if (numMinted + numToBeMinted > supply) {
revert MintSupplyExceeded(supply);
}
_;
}
modifier withinMaxSupply(uint numToBeMinted) {
if (_totalMinted() + numToBeMinted > maxSupply) {
revert MintSupplyExceeded(maxSupply);
}
_;
}
modifier hasExactPayment(uint numToBeMinted) {
if (msg.value != price * numToBeMinted) {
revert WrongPayment();
}
_;
}
function _mintMany(address to, uint numToBeMinted) internal {
_mintMany(to, numToBeMinted, "");
}
function _mintMany(
address to,
uint numToBeMinted,
bytes memory data
) internal withinMaxSupply(numToBeMinted) {
uint batchSize = 10;
uint currentTotalMinted = totalMinted();
for (uint i = 0; i < numToBeMinted; i += batchSize) {
uint mintAmount = (i + batchSize > numToBeMinted)
? numToBeMinted - i
: batchSize;
_safeMint(to, mintAmount, data);
for (uint j = 0; j < mintAmount; ++j) {
uint tokenId = currentTotalMinted + i + j;
tokenToPRN[tokenId] = uint(
keccak256(
abi.encodePacked(
tokenId,
to,
block.timestamp,
block.prevrandao,
j
)
)
);
}
}
}
function supportsInterface(
bytes4 interfaceId
) public view virtual override(ERC721A, ERC2981) returns (bool) {
return
ERC721A.supportsInterface(interfaceId) ||
ERC2981.supportsInterface(interfaceId);
}
function setDefaultRoyalty(
address receiver,
uint96 feeNumerator
) public onlyOwner {
_setDefaultRoyalty(receiver, feeNumerator);
}
function setOperatorFilteringEnabled(bool value) public onlyOwner {
operatorFilteringEnabled = value;
}
function _operatorFilteringEnabled() internal view returns (bool) {
return operatorFilteringEnabled;
}
function _isPriorityOperator(
address operator
) internal pure returns (bool) {
return operator == address(0x1E0049783F008A0085193E00003D00cd54003c71);
}
function withdrawAll() external nonReentrant {
require(address(this).balance > 0, "ART0x1: zero balance.");
(bool sent, ) = owner().call{value: address(this).balance}("");
require(sent, "ART0x1: failed to withdraw.");
}
function withdrawAllERC20(IERC20 token) external nonReentrant {
token.transfer(owner(), token.balanceOf(address(this)));
}
function normalizeOwnership(uint startTokenId, uint quantity) external {
for (uint i = 0; i < quantity; i++) {
_initializeOwnershipAt(startTokenId + i);
}
}
}
文件 9 的 17:IART0x1.sol
pragma solidity ^0.8.22;
import {ART0x1Types} from "../ART0x1Types.sol";
interface IART0x1 {
function tokenHTML(
ART0x1Types.TokenCtx memory _tokenCtx
) external view returns (string memory);
function tokenSVG(
ART0x1Types.TokenCtx memory _tokenCtx
) external view returns (string memory);
function tokenURI(
ART0x1Types.TokenCtx memory _tokenCtx
) external view returns (string memory);
}
文件 10 的 17:IERC165.sol
pragma solidity ^0.8.20;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 11 的 17:IERC20.sol
pragma solidity ^0.8.20;
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 value) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
文件 12 的 17:IERC2981.sol
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";
interface IERC2981 is IERC165 {
function royaltyInfo(
uint256 tokenId,
uint256 salePrice
) external view returns (address receiver, uint256 royaltyAmount);
}
文件 13 的 17:IERC721.sol
pragma solidity ^0.8.20;
import {IERC165} from "../../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, 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);
}
文件 14 的 17:IERC721A.sol
pragma solidity ^0.8.4;
interface IERC721A {
error ApprovalCallerNotOwnerNorApproved();
error ApprovalQueryForNonexistentToken();
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 payable;
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external payable;
function transferFrom(
address from,
address to,
uint256 tokenId
) external payable;
function approve(address to, uint256 tokenId) external payable;
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);
}
文件 15 的 17:Ownable.sol
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
error OwnableUnauthorizedAccount(address account);
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 16 的 17:ReentrancyGuard.sol
pragma solidity ^0.8.20;
abstract contract ReentrancyGuard {
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
_status = ENTERED;
}
function _nonReentrantAfter() private {
_status = NOT_ENTERED;
}
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
文件 17 的 17:SSTORE2.sol
pragma solidity ^0.8.0;
import "./utils/Bytecode.sol";
library SSTORE2 {
error WriteError();
function write(bytes memory _data) internal returns (address pointer) {
bytes memory code = Bytecode.creationCodeFor(
abi.encodePacked(
hex'00',
_data
)
);
assembly { pointer := create(0, add(code, 32), mload(code)) }
if (pointer == address(0)) revert WriteError();
}
function read(address _pointer) internal view returns (bytes memory) {
return Bytecode.codeAt(_pointer, 1, type(uint256).max);
}
function read(address _pointer, uint256 _start) internal view returns (bytes memory) {
return Bytecode.codeAt(_pointer, _start + 1, type(uint256).max);
}
function read(address _pointer, uint256 _start, uint256 _end) internal view returns (bytes memory) {
return Bytecode.codeAt(_pointer, _start + 1, _end + 1);
}
}
{
"compilationTarget": {
"packages/contracts/src/ART0x1.sol": "ART0x1"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "none"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@openzeppelin/contracts/=packages/contracts/lib/openzeppelin-contracts/contracts/",
":ERC721A/=packages/contracts/lib/ERC721A/contracts/",
":abdk-libraries-solidity/=packages/contracts/lib/abdk-libraries-solidity/",
":base64/=packages/contracts/lib/base64/",
":ds-test/=packages/contracts/lib/ds-test/src/",
":erc4626-tests/=packages/contracts/lib/openzeppelin-contracts/lib/erc4626-tests/",
":erc721a/=packages/contracts/lib/ERC721A/",
":ethfs/=packages/contracts/lib/ethfs/",
":forge-std/=packages/contracts/lib/forge-std/src/",
":openzeppelin-contracts/=packages/contracts/lib/openzeppelin-contracts/",
":openzeppelin/=packages/contracts/lib/openzeppelin-contracts/",
":solady/=packages/contracts/lib/ethfs/packages/contracts/lib/solady/src/",
":sstore2/=packages/contracts/lib/sstore2/"
]
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"ApprovalQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[{"internalType":"uint256","name":"numerator","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"}],"name":"ERC2981InvalidDefaultRoyalty","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC2981InvalidDefaultRoyaltyReceiver","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"numerator","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"}],"name":"ERC2981InvalidTokenRoyalty","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC2981InvalidTokenRoyaltyReceiver","type":"error"},{"inputs":[{"internalType":"uint256","name":"_size","type":"uint256"},{"internalType":"uint256","name":"_start","type":"uint256"},{"internalType":"uint256","name":"_end","type":"uint256"}],"name":"InvalidCodeAtRange","type":"error"},{"inputs":[],"name":"MintERC2309QuantityExceedsLimit","type":"error"},{"inputs":[{"internalType":"uint256","name":"limit","type":"uint256"}],"name":"MintLimitExceeded","type":"error"},{"inputs":[{"internalType":"uint256","name":"supply","type":"uint256"}],"name":"MintSupplyExceeded","type":"error"},{"inputs":[],"name":"MintToZeroAddress","type":"error"},{"inputs":[],"name":"MintZeroQuantity","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"OwnerQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"OwnershipNotInitializedForExtraData","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[],"name":"TransferCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"TransferToNonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"URIQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"WriteError","type":"error"},{"inputs":[],"name":"WrongPayment","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":[],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"uint256","name":"_galleryIndex","type":"uint256"},{"internalType":"string[12]","name":"_instructions","type":"string[12]"}],"name":"addGalleryItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_galleryIndex","type":"uint256"},{"internalType":"string[12][]","name":"_instructionsList","type":"string[12][]"}],"name":"addGalleryItems","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newAddress","type":"address"}],"name":"addProgramAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_galleryIndex","type":"uint256"},{"internalType":"address","name":"_curatorAddress","type":"address"}],"name":"assignGalleryCurator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"clearTokenInstructions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"earlyMintActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"galleries","outputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"address","name":"curator","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"galleryToCurator","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":"uint256","name":"_index","type":"uint256"}],"name":"getGfxModuleByIndex","outputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"authorAddress","type":"address"},{"internalType":"address","name":"moduleAddress","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"}],"internalType":"struct ART0x1Types.GfxModule","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGfxModules","outputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"authorAddress","type":"address"},{"internalType":"address","name":"moduleAddress","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"}],"internalType":"struct ART0x1Types.GfxModule[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getTokenInstructions","outputs":[{"internalType":"string[12]","name":"","type":"string[12]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"gfxModuleAddresses","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"gfxModules","outputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"authorAddress","type":"address"},{"internalType":"address","name":"moduleAddress","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_galleryIndex","type":"uint256"},{"internalType":"address[]","name":"_artistAddressList","type":"address[]"}],"name":"inviteGalleryArtists","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"isArtistInvitedToGallery","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isGalleryCurationPermissionless","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"isGalleryRevealed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"address","name":"_moduleAddress","type":"address"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"listGfxModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_numToBeMinted","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_numToBeMinted","type":"uint256"}],"name":"mintAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_numToBeMinted","type":"uint256"}],"name":"mintEarly","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"startTokenId","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"normalizeOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"operatorFilteringEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":"preRevealInstructions","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"programAddresses","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"publicMintActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"resetTokenGfxModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_galleryIndex","type":"uint256"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"revealGallery","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":"payable","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":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","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":"bool","name":"value","type":"bool"}],"name":"setOperatorFilteringEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string[12]","name":"_instructions","type":"string[12]"}],"name":"setPreRevealInstructions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_galleryIndex","type":"uint256"}],"name":"setTokenGallery","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_gfxModuleAddress","type":"address"},{"internalType":"uint256","name":"_uint","type":"uint256"},{"internalType":"string","name":"_string","type":"string"}],"name":"setTokenGfxModule","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"string[12]","name":"_instructions","type":"string[12]"}],"name":"setTokenInstructions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"setTokenProgramAddress","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":[],"name":"toggleEarly","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"togglePublic","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"tokenHTML","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenInstructions","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"tokenSVG","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenToExecutedGfxModules","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenToGalleryId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenToGfxModuleAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenToGfxModuleString","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenToGfxModuleUint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenToPRN","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenToProgramAddress","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenToVisitedGalleries","outputs":[{"internalType":"uint256","name":"","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":"totalMinted","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":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"}],"name":"withdrawAllERC20","outputs":[],"stateMutability":"nonpayable","type":"function"}]