Skip to content
Verified contractExactGPL-3.0

EditionSaleV3

Address0xc0ded6ff2a1abd92b54d98627b0f46dee761e6c7
Balance

0 ETH

 

Transactions

0

 

Compiler

solc 0.8.30

 

Same code

1 more contract

 

Details

Compiler
solc 0.8.30+commit.73712a01
Language
solidity
Optimization
Yes, 10,000 runs
EVM version
cancun
License
GPL-3.0
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,355,401
Creation transaction
0x3a3fb30fa6…2ee6e93093

src/EditionSaleV3.sol

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.24;
// Generation 8 twin of EditionSaleV2.sol, made by scripts/gen-template-twins.mjs:
// EditionSaleV2's audited text with three changes and no others: this header,
// the contract's name, and the fee library (FeeV2, imported under the name
// Fee), so the press's one percent goes to the IncomeForwarder (FeeV2.sol).
// scripts/verify-template-twins.mjs fails unless every other byte is EditionSaleV2's.

import {MiniERC721} from "./MiniERC721.sol";
import {MetaEscape} from "./MetaEscape.sol";
import {MetaEscapeV2} from "./MetaEscapeV2.sol";
import {FeeV2 as Fee} from "./FeeV2.sol";

interface ICollection {
    function mintFromSale(address to) external returns (uint256);
    function tokenURI(uint256 id) external view returns (string memory);
}

interface IInscriptions {
    function dataURI(uint256 id) external view returns (string memory);
    function sizeOf(uint256 id) external view returns (uint256);
}


/// The artist's own edition, immutable after deploy. Cap at most 100; price
/// fixed at deploy, forever: nothing raises, nothing reopens, nothing
/// discounts early conviction. One lever only, close(), one way: a stalled
/// run stays open at the artist's pleasure or seals in the holders' favor.
/// Payment forwards on every mint, 99 percent to the artist and 1 percent
/// to the press; a receiver that refuses is owed instead and withdrawn by
/// pull, so no refusal can ever stop the run or trap a wei.
/// Generation 5 (v20): the same edition with the work's description in
/// its metadata. The frozen EditionSale is untouched; this is a new file.
contract EditionSaleV3 is MiniERC721 {
    uint256 public immutable price;
    uint256 public cap;      // drops to minted on close, never rises
    uint256 public minted;
    bool public closed;
    string public mediaURI;
    /// the work's description, the artist's words, part of the token's
    /// metadata from the first block: set at deploy, never editable
    string public description;
    /// The sale window, fixed at deploy like everything else. Zero startsAt
    /// opens at deploy; zero endsAt runs until the artist closes. A timed
    /// edition is this same contract with the clock set: the chain, not the
    /// server, refuses the early mint and the late one.
    uint64 public immutable startsAt;
    uint64 public immutable endsAt;
    /// generation 5: the window as ONE static struct (solc's stack takes no
    /// more flat arguments once the description joins); it encodes in place,
    /// the same two words in the same order
    struct Window {
        uint64 startsAt;
        uint64 endsAt;
    }
    /// when set, the artwork is bytes in the chain, not an address elsewhere
    address public immutable inscriptions;
    /// when set, the work is minted into the artist's collection, not here
    address public immutable collection;
    uint256 public immutable inscriptionId;

    /// The pull side of a refused payment: owed balances, withdrawn by
    /// anyone, paid only ever to the owed address.
    mapping(address => uint256) public owed;
    uint256 public totalOwed;
    /// this sale's mint number => the id it was given in the collection
    mapping(uint256 => uint256) public collectionTokenId;

    event Minted(address indexed to, uint256 indexed tokenId);
    event Closed(uint256 finalCap);
    event Owed(address indexed to, uint256 amount);
    event Withdrawn(address indexed to, uint256 amount);

    error WrongPrice();
    error SoldOut();
    error AlreadyClosed();
    error NothingOwed();
    error NotYetOpen();
    error WindowOver();

    constructor(
        address artist_,
        uint256 price_,
        uint256 cap_,
        uint96 royaltyBps_,
        string memory title_,
        string memory mediaURI_,
        address inscriptions_,
        uint256 inscriptionId_,
        address collection_,
        Window memory window_,
        string memory description_
    ) MiniERC721(artist_, royaltyBps_, title_, "ETCHD") {
        require(price_ > 0, "an edition needs its price");
        require(bytes(description_).length <= MetaEscapeV2.MAX_DESCRIPTION, "description: up to 2000 bytes");

        require(cap_ >= 1 && cap_ <= 100, "cap: 1 to 100");
        require(window_.endsAt == 0 || window_.endsAt > window_.startsAt, "the window must close after it opens");
        price = price_;
        cap = cap_;
        mediaURI = mediaURI_;
        inscriptions = inscriptions_;
        inscriptionId = inscriptionId_;
        collection = collection_;
        startsAt = window_.startsAt;
        endsAt = window_.endsAt;
        description = description_;
    }

    function mint() external payable {
        if (block.timestamp < startsAt) revert NotYetOpen();
        if (endsAt != 0 && block.timestamp >= endsAt) revert WindowOver();
        if (closed || minted >= cap) revert SoldOut();
        if (msg.value != price) revert WrongPrice();
        uint256 id = ++minted;
        if (collection != address(0)) {
            collectionTokenId[id] = ICollection(collection).mintFromSale(msg.sender);
        } else
        _mint(msg.sender, id);
        (uint256 toPress, uint256 toArtist) = Fee.splitPrimary(msg.value);
        if (toPress > 0) _pay(Fee.recipient(), toPress);
        _pay(artist, toArtist);
        emit Minted(msg.sender, id);
    }

    /// Push politely, with a gas cap; a refusal becomes a balance to pull.
    /// A mint can therefore never be stopped by a receiver that reverts.
    function _pay(address to, uint256 amount) internal {
        (bool ok,) = to.call{value: amount, gas: 30_000}("");
        if (!ok) {
            owed[to] += amount;
            totalOwed += amount;
            emit Owed(to, amount);
        }
    }

    /// Pay anyone what they are owed. Callable by anyone; the money only
    /// ever goes to the owed address. A failed send changes nothing and can
    /// be retried forever.
    function withdraw(address to) external {
        uint256 amount = owed[to];
        if (amount == 0) revert NothingOwed();
        owed[to] = 0;
        totalOwed -= amount;
        (bool ok,) = to.call{value: amount}("");
        require(ok, "withdraw failed");
        emit Withdrawn(to, amount);
    }

    /// One way. The cap drops to what exists; early conviction is never diluted.
    function close() external {
        if (msg.sender != artist) revert NotAuthorized();
        if (closed) revert AlreadyClosed();
        closed = true;
        cap = minted;
        emit Closed(cap);
    }

    /// In collection mode the token lives in the collection, so metadata is
    /// answered there; standalone, the sale answers for its own tokens.
    /// base64 JSON either way: OpenSea and Etherscan both render it. An
    /// inscribed work also carries its onchain identity (chain id, store,
    /// inscription id) so the render is always re-derivable from the chain.
    function tokenURI(uint256 tokenId) external view override returns (string memory) {
        if (collection != address(0)) return ICollection(collection).tokenURI(collectionTokenId[tokenId]);
        ownerOf(tokenId);
        if (inscriptions == address(0)) {
            // demo-chain URL: escaped at source (the image is inserted raw into JSON)
            return MetaEscapeV2.tokenJSON(name, description, MetaEscape.esc(mediaURI));
        }
        return MetaEscapeV2.tokenJSONOnchain(name, description, _image(), inscriptions, inscriptionId);
    }

    /// The image, sized for the indexer's eth_call budget: a work that fits
    /// inline rides INSIDE the tokenURI (fully onchain, no server); a larger
    /// work is onchain-stored, gateway-rendered — its bytes stay permanent
    /// onchain and the image points at the chain-scoped gateway, which
    /// reconstructs them chunk-by-chunk via eth_getCode.
    function _image() internal view returns (string memory) {
        if (IInscriptions(inscriptions).sizeOf(inscriptionId) <= MetaEscape.INLINE_MAX) {
            return IInscriptions(inscriptions).dataURI(inscriptionId);
        }
        return MetaEscape.gatewayImage(inscriptions, inscriptionId);
    }
}

src/Fee.sol

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.24;

/// The press's terms, written into every contract it deploys and never
/// written again: one percent of a primary sale, to the address below.
///
/// There is no setter. There is no owner. There is no upgrade path. The
/// primary percentage and the address are constants in the bytecode of every
/// sale contract and every collection, so an artist can read them before they
/// deploy and a collector can read them before they bid. What is deployed
/// cannot be changed by anyone, including us.
///
/// The one percent of a secondary sale is named here for reference only. It
/// is NOT charged by any contract below and never touches an artist's
/// royalty: it is a consideration the press adds to the orders it itself
/// builds, so it never reaches the deployed bytecode and a trade made
/// anywhere else pays the press nothing.
library Fee {
    /// One percent of a primary sale, taken here, in the contract.
    uint256 internal constant PRIMARY_BPS = 100;

    /// One percent of a secondary sale, taken as a consideration on the
    /// orders the press builds, never from the artist's royalty and never
    /// from a trade made anywhere else. Named here so both numbers are read
    /// in one place; no contract below spends it.
    uint256 internal constant SECONDARY_BPS = 100;

    /// Where the press's share goes, forever, per chain. On Ethereum the
    /// CypherPunks treasury, a multisig; on Shape the CypherPunks Shape
    /// treasury wallet (Kenny, 2026-09-17). Every contract the press deploys
    /// is bound to these addresses at deploy and nobody, us included, can
    /// point them anywhere else. `recipient()` is the one to call; RECIPIENT
    /// stays named for the contracts printed before Shape had its own.
    address internal constant RECIPIENT = 0x246530326ae20477ebbD4BeB2C28EC186Eb0Dd4F;
    address internal constant SHAPE_RECIPIENT = 0x691267Cd74087ed6848c2772c9dDD6B0C72C8f4B;
    uint256 internal constant SHAPE_MAINNET = 360;
    uint256 internal constant SHAPE_SEPOLIA = 11011;

    /// The press's share on THIS chain: the Shape treasury wallet on Shape
    /// (mainnet and Sepolia, so the testnet proves the branch), the treasury
    /// multisig everywhere else. Read from the chain id the contract runs on,
    /// so one bytecode serves both chains and still names one address each.
    function recipient() internal view returns (address) {
        return block.chainid == SHAPE_MAINNET || block.chainid == SHAPE_SEPOLIA ? SHAPE_RECIPIENT : RECIPIENT;
    }

    /// The press's cut of a primary sale, and what remains for the artist.
    function splitPrimary(uint256 amount) internal pure returns (uint256 toPress, uint256 toArtist) {
        toPress = (amount * PRIMARY_BPS) / 10_000;
        toArtist = amount - toPress;
    }

}

src/FeeV2.sol

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.24;

/// The press's terms from generation 8 on: the same one percent as Fee.sol,
/// to a different address. Fee.sol stays exactly as it was, byte for byte,
/// for every contract already printed with it (they keep paying the
/// CypherPunks treasury multisig for good).
///
/// There is no setter. There is no owner. There is no upgrade path. The
/// percentages and the address are constants in the bytecode of every
/// generation 8 sale contract and of ListingBookV4. What is deployed cannot
/// be changed by anyone, including us.
///
/// What changes is where the address leads. On Ethereum (and every chain but
/// Shape) the press's share goes to the IncomeForwarder (IncomeForwarder.sol),
/// which passes every wei to one payee. The house can name a new payee there,
/// and that is the only thing anyone can change: never the percentage, never
/// what a sale owes, never an artist's or a seller's money.
///
/// The one percent of a secondary sale IS charged in a contract: by
/// ListingBookV4, on every trade it settles, never from the royalty.
///
/// Templates import this library as `Fee` (`import {FeeV2 as Fee}`), so
/// their bodies stay the audited text of the printings before them,
/// character for character (scripts/verify-template-twins.mjs).
library FeeV2 {
    /// One percent of a primary sale, taken in the sale contract.
    uint256 internal constant PRIMARY_BPS = 100;

    /// One percent of a secondary sale, taken in ListingBookV4.
    uint256 internal constant SECONDARY_BPS = 100;

    /// The IncomeForwarder, deployed through the public CREATE2 proxy
    /// (CREATE2_PROXY) with FORWARDER_SALT: its address is fixed by its
    /// creation code before it is deployed. Written by
    /// scripts/freeze-forwarder.mjs, held to IncomeForwarder.sol by
    /// test/FeeV2Address.t.sol and scripts/verify-forwarder-address.mjs.
    address internal constant FORWARDER = 0xC0DE8f70834546717E0e5cE172bB66906Fe2c66F;
    bytes32 internal constant FORWARDER_SALT = 0x00000000000000000000000000000000000000000000000000000000002f0a59;
    address internal constant CREATE2_PROXY = 0x4e59b44847b379578588920cA78FbF26c0B4956C;

    /// Named RECIPIENT as in Fee.sol, so a template's body reads the same.
    address internal constant RECIPIENT = FORWARDER;

    /// Shape keeps the CypherPunks Shape treasury wallet, as Fee.sol pays it
    /// (Shape undecided, 2026-10-03: no generation 8 is planned there).
    address internal constant SHAPE_RECIPIENT = 0x691267Cd74087ed6848c2772c9dDD6B0C72C8f4B;
    uint256 internal constant SHAPE_MAINNET = 360;
    uint256 internal constant SHAPE_SEPOLIA = 11011;

    /// The press's share on THIS chain: the Shape treasury wallet on Shape
    /// (mainnet and Sepolia), the IncomeForwarder everywhere else.
    function recipient() internal view returns (address) {
        return block.chainid == SHAPE_MAINNET || block.chainid == SHAPE_SEPOLIA ? SHAPE_RECIPIENT : FORWARDER;
    }

    /// The press's cut of a primary sale, and what remains for the artist (as Fee.sol).
    function splitPrimary(uint256 amount) internal pure returns (uint256 toPress, uint256 toArtist) {
        toPress = (amount * PRIMARY_BPS) / 10_000;
        toArtist = amount - toPress;
    }
}

src/MetaEscape.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/// JSON string escaping for onchain metadata (audit ETCHD-M04): a quote, a
/// backslash, or a control character in an artist-chosen string can never
/// break out of the JSON string it was placed in. This is a NEW file — the
/// template sources gain an import, which changes the MAINNET template set's
/// bytecode and hashes; the live testnet factories keep serving the pinned
/// artifacts they were deployed with.
library MetaEscape {
    /// Escape for a JSON string context: " -> \" , \ -> \\ , <0x20 -> \u00XX.
    function esc(string memory s) internal pure returns (string memory) {
        bytes memory b = bytes(s);
        bytes memory hexd = "0123456789abcdef";
        bytes memory out = new bytes(b.length * 6); // worst case: all \u00XX
        uint256 o;
        for (uint256 i = 0; i < b.length; i++) {
            uint8 c = uint8(b[i]);
            if (c == 0x22 || c == 0x5c) {
                out[o++] = 0x5c;
                out[o++] = b[i];
            } else if (c < 0x20) {
                out[o++] = 0x5c;
                out[o++] = 0x75; // u
                out[o++] = 0x30; // 0
                out[o++] = 0x30; // 0
                out[o++] = hexd[c >> 4];
                out[o++] = hexd[c & 0x0f];
            } else {
                out[o++] = b[i];
            }
        }
        assembly { mstore(out, o) }
        return string(out);
    }

    // ---- mainnet render policy (size-aware tokenURI) ----
    // Indexers call tokenURI() as an eth_call under a provider gas cap, and
    // reading raw bytes back plus base64-ing them is QUADRATIC in size (EVM
    // memory), so an inline data URI only decodes up to a bounded size before
    // the call fails and nothing renders. INLINE_MAX is the size at or below
    // which the work's bytes ride INSIDE the tokenURI (fully self-contained,
    // no server). Above it the work is ONCHAIN-STORED, GATEWAY-RENDERED: the
    // bytes stay permanent onchain and the image field points at the gateway,
    // which reconstructs them chunk-by-chunk via eth_getCode (never a gas-
    // capped whole-file eth_call). The threshold is measured end-to-end on
    // REAL deployed templates in TokenURIGas.t.sol; the JSON carries the
    // chain id, store and inscription id explicitly so the render is always
    // re-derivable from the chain alone.
    // 100 KB: the size the evidence actually proves. A 100 KB work's full
    // tokenURI costs ~21.5M gas at the real template interface and serves
    // through an ordinary default-capped public RPC (measured live); 250 KB
    // already exceeds geth's 50M eth_call default. Larger works are
    // onchain-stored, gateway-rendered — nothing above the line loses its
    // render, it just rides the gateway. Immutable per generation; raising
    // it requires a new generation and new proof at the new size.
    uint256 internal constant INLINE_MAX = 100_000;
    // the onchain-reconstructing gateway origin, baked into template
    // bytecode: the dedicated cookieless art domain, final before any deploy
    // of this generation (never an application/hosting origin).
    string internal constant GATEWAY = "https://art.etchd.art";

    /// The full mainnet tokenURI: base64-encoded JSON, the form both OpenSea
    /// and Etherscan's NFT view parse reliably (plain data:application/json
    /// leaves Etherscan showing no image). Only the artist NAME is escaped;
    /// the image is a machine-generated data URI or gateway URL, whose every
    /// character is already JSON-safe — running esc() over a megabyte base64
    /// image would allocate 6x its size and blow past any eth_call budget.
    function tokenJSON(string memory name, string memory image) internal pure returns (string memory) {
        string memory json = string.concat('{"name":"', esc(name), '","image":"', image, '"}');
        return string.concat("data:application/json;base64,", b64(bytes(json)));
    }

    /// The mainnet tokenURI for a work whose bytes live in an inscription
    /// store: same base64 JSON, plus the work's onchain identity as explicit
    /// fields — chain id, store, inscription id, and a canonical locator —
    /// so a gateway-rendered image is always re-derivable from the chain
    /// alone, and a cross-chain address collision can never misattribute it.
    function tokenJSONOnchain(string memory name, string memory image, address store, uint256 id)
        internal
        view
        returns (string memory)
    {
        string memory json = string.concat(
            '{"name":"', esc(name),
            '","image":"', image,
            '",', onchainFields(store, id), '}'
        );
        return string.concat("data:application/json;base64,", b64(bytes(json)));
    }

    /// The explicit onchain identity, machine-built and JSON-safe by
    /// construction: hex address, decimal ids, fixed keys.
    function onchainFields(address store, uint256 id) internal view returns (string memory) {
        string memory chainStr = _uintStr(block.chainid);
        string memory storeStr = _hexAddr(store);
        string memory idStr = _uintStr(id);
        return string.concat(
            '"chain_id":', chainStr,
            ',"inscription_store":"', storeStr,
            '","inscription_id":', idStr,
            ',"onchain_locator":"etchd://', chainStr, "/", storeStr, "/", idStr, '"'
        );
    }

    /// The gateway image URL for a work too large to inline: the same bytes,
    /// reconstructed from THIS chain's store by the gateway. The chain id is
    /// part of the permanent URL, so an identical store address on another
    /// chain can never satisfy it: https://.../art/<chainId>/<store>/<id>
    function gatewayImage(address store, uint256 id) internal view returns (string memory) {
        return string.concat(GATEWAY, "/art/", _uintStr(block.chainid), "/", _hexAddr(store), "/", _uintStr(id));
    }

    function _uintStr(uint256 v) internal pure returns (string memory) {
        if (v == 0) return "0";
        uint256 n = v; uint256 len; while (n != 0) { len++; n /= 10; }
        bytes memory b = new bytes(len);
        while (v != 0) { len--; b[len] = bytes1(uint8(48 + v % 10)); v /= 10; }
        return string(b);
    }
    function _hexAddr(address a) internal pure returns (string memory) {
        bytes memory hexd = "0123456789abcdef";
        bytes memory out = new bytes(42);
        out[0] = "0"; out[1] = "x";
        uint160 v = uint160(a);
        for (uint256 i = 0; i < 20; i++) {
            uint8 b = uint8(v >> (8 * (19 - i)));
            out[2 + i * 2] = hexd[b >> 4];
            out[3 + i * 2] = hexd[b & 0x0f];
        }
        return string(out);
    }

    bytes internal constant B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    /// Base64, the same encoder the store uses for dataURI.
    function b64(bytes memory data) internal pure returns (string memory) {
        if (data.length == 0) return "";
        uint256 encodedLen = 4 * ((data.length + 2) / 3);
        bytes memory result = new bytes(encodedLen);
        bytes memory table = B64;
        assembly {
            let tablePtr := add(table, 1)
            let resultPtr := add(result, 32)
            for { let i := 0 } lt(i, mload(data)) { i := add(i, 3) } {
                let input := shr(232, mload(add(add(data, 32), i)))
                mstore8(resultPtr, mload(add(tablePtr, shr(18, input)))) resultPtr := add(resultPtr, 1)
                mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F)))) resultPtr := add(resultPtr, 1)
                mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F)))) resultPtr := add(resultPtr, 1)
                mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F)))) resultPtr := add(resultPtr, 1)
            }
            switch mod(mload(data), 3)
            case 1 { mstore8(sub(resultPtr, 1), 0x3d) mstore8(sub(resultPtr, 2), 0x3d) }
            case 2 { mstore8(sub(resultPtr, 1), 0x3d) }
        }
        return string(result);
    }

    /// A MIME type wears a tight collar: 3 to 100 bytes of
    /// [A-Za-z0-9/+.-] only — nothing that could ever escape a data URI
    /// or a JSON string.
    function validMime(string memory s) internal pure returns (bool) {
        bytes memory b = bytes(s);
        if (b.length < 3 || b.length > 100) return false;
        for (uint256 i = 0; i < b.length; i++) {
            uint8 c = uint8(b[i]);
            bool ok = (c >= 0x61 && c <= 0x7a) || (c >= 0x41 && c <= 0x5a)
                || (c >= 0x30 && c <= 0x39) || c == 0x2f || c == 0x2b || c == 0x2e || c == 0x2d;
            if (!ok) return false;
        }
        return true;
    }
}

src/MetaEscapeV2.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {MetaEscape} from "./MetaEscape.sol";

/// Generation 5 (v20): token JSON that carries the work's description. A
/// NEW library beside MetaEscape, never an edit of it: the frozen templates
/// import MetaEscape and their bytecode (metadata hash included) is pinned,
/// so that file cannot change. Everything here delegates to MetaEscape for
/// escaping, base64 and the onchain identity fields.
library MetaEscapeV2 {
    /// The description's ceiling, in bytes, enforced by every described
    /// template's constructor: bounded storage at deploy, and a tokenURI
    /// whose escaping (6x worst case) stays far inside any eth_call budget.
    uint256 internal constant MAX_DESCRIPTION = 2000;

    /// name + description + image, base64 JSON. Only the artist's strings are
    /// escaped; the image is a machine-built data URI or gateway URL.
    function tokenJSON(string memory name, string memory description, string memory image)
        internal
        pure
        returns (string memory)
    {
        string memory json = string.concat(
            '{"name":"', MetaEscape.esc(name),
            '","description":"', MetaEscape.esc(description),
            '","image":"', image, '"}'
        );
        return string.concat("data:application/json;base64,", MetaEscape.b64(bytes(json)));
    }

    /// The same for an inscribed work: the description rides between the
    /// name and the image, the onchain identity fields follow the image.
    function tokenJSONOnchain(string memory name, string memory description, string memory image, address store, uint256 id)
        internal
        view
        returns (string memory)
    {
        string memory json = string.concat(
            '{"name":"', MetaEscape.esc(name),
            '","description":"', MetaEscape.esc(description),
            '","image":"', image,
            '",', MetaEscape.onchainFields(store, id), '}'
        );
        return string.concat("data:application/json;base64,", MetaEscape.b64(bytes(json)));
    }
}

src/MiniERC721.sol

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.24;

import {Fee} from "./Fee.sol";

interface IERC721Receiver {
    function onERC721Received(address, address, uint256, bytes calldata) external returns (bytes4);
}

/// The smallest honest ERC-721 with ERC-2981: the base for artist sale
/// contracts. No hooks, no extensions, no hidden levers. Primary sales pay
/// the artist 99% and the press 1%, both constants in Fee.sol that nobody
/// can change, and the only royalty lever points down.
abstract contract MiniERC721 {
    string public name;
    string public symbol;

    address public immutable artist;
    uint96 public royaltyBps; // declared forever; reduce only; hard cap 1000

    mapping(uint256 => address) internal _owner;
    mapping(address => uint256) public balanceOf;
    mapping(uint256 => address) public getApproved;
    mapping(address => mapping(address => bool)) public isApprovedForAll;

    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);
    event RoyaltyReduced(uint96 fromBps, uint96 toBps);

    error NotAuthorized();
    error WrongOwner();
    error ZeroAddress();
    error RoyaltyOnlyReducible();

    constructor(address artist_, uint96 royaltyBps_, string memory name_, string memory symbol_) {
        if (artist_ == address(0)) revert ZeroAddress();
        if (royaltyBps_ > 1000) revert RoyaltyOnlyReducible(); // the hard cap
        artist = artist_;
        royaltyBps = royaltyBps_;
        name = name_;
        symbol = symbol_;
    }

    /// EIP-173-shaped view for tooling that asks who owns the contract —
    /// Shape's gasback registration requires it, so the artist can claim the
    /// sequencer fees their sales generate. A view only: it names the artist,
    /// it grants nothing this contract does not already grant.
    function owner() external view returns (address) { return artist; }

    function ownerOf(uint256 tokenId) public view returns (address o) {
        o = _owner[tokenId];
        require(o != address(0), "no such token");
    }

    function approve(address to, uint256 tokenId) external {
        address o = ownerOf(tokenId);
        if (msg.sender != o && !isApprovedForAll[o][msg.sender]) revert NotAuthorized();
        getApproved[tokenId] = to;
        emit Approval(o, to, tokenId);
    }

    function setApprovalForAll(address operator, bool approved) external {
        isApprovedForAll[msg.sender][operator] = approved;
        emit ApprovalForAll(msg.sender, operator, approved);
    }

    function transferFrom(address from, address to, uint256 tokenId) public {
        address o = ownerOf(tokenId);
        if (o != from) revert WrongOwner();
        if (to == address(0)) revert ZeroAddress();
        if (msg.sender != o && msg.sender != getApproved[tokenId] && !isApprovedForAll[o][msg.sender]) {
            revert NotAuthorized();
        }
        delete getApproved[tokenId];
        unchecked {
            balanceOf[from]--;
            balanceOf[to]++;
        }
        _owner[tokenId] = to;
        emit Transfer(from, to, tokenId);
    }

    function safeTransferFrom(address from, address to, uint256 tokenId) external {
        safeTransferFrom(from, to, tokenId, "");
    }

    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public {
        transferFrom(from, to, tokenId);
        if (to.code.length > 0) {
            require(
                IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, data)
                    == IERC721Receiver.onERC721Received.selector,
                "unsafe receiver"
            );
        }
    }

    function _mint(address to, uint256 tokenId) internal {
        if (to == address(0)) revert ZeroAddress();
        require(_owner[tokenId] == address(0), "minted");
        unchecked {
            balanceOf[to]++;
        }
        _owner[tokenId] = to;
        emit Transfer(address(0), to, tokenId);
    }

    /// ERC-2981. Declared at deploy, honored at each marketplace's honor.
    /// The artist's royalty, whole. The press takes nothing here: its one
    /// percent of a resale is a consideration on the orders it builds, not a
    /// claim on the artist's royalty, so a sale anywhere else pays the artist
    /// exactly what they declared and pays the press nothing.
    function royaltyInfo(uint256, uint256 salePrice) external view returns (address, uint256) {
        return (artist, (salePrice * royaltyBps) / 10_000);
    }

    /// The only lever, and it only points down. The artist's call, zero included.
    function reduceRoyalty(uint96 toBps) external {
        if (msg.sender != artist) revert NotAuthorized();
        if (toBps >= royaltyBps) revert RoyaltyOnlyReducible();
        emit RoyaltyReduced(royaltyBps, toBps);
        royaltyBps = toBps;
    }

    function supportsInterface(bytes4 id) external pure returns (bool) {
        return id == 0x01ffc9a7 // ERC-165
            || id == 0x80ac58cd // ERC-721
            || id == 0x5b5e139f // ERC-721 metadata
            || id == 0x2a55205a; // ERC-2981
    }

    function tokenURI(uint256 tokenId) external view virtual returns (string memory);
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 10000,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "forge-std/=lib/forge-std/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.