Skip to content
Verified contractPartialCC0-1.0

CC0PERenderer

Address0xb289f56e0970bc3ce92e0ec53aa7ac7c397ee5c6
Balance

0 ETH

 

Transactions

5

 

Compiler

solc 0.8.17

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.17+commit.8df45f5f
Language
solidity
Optimization
Yes, 200 runs
EVM version
london
License
CC0-1.0
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,331,644
Creation transaction
0x45122d41c6…4d27719350

src/CC0PERenderer.sol

// SPDX-License-Identifier: CC0-1.0
pragma solidity 0.8.17;

import {SSTORE2} from "solmate/utils/SSTORE2.sol";
import {LibString} from "solmate/utils/LibString.sol";
import {Owned} from "solmate/auth/Owned.sol";
import {Base64} from "openzeppelin-contracts/utils/Base64.sol";
import {Strings} from "openzeppelin-contracts/utils/Strings.sol";

/**
 * @title CC0PERenderer
 * @notice Holds the generator script onchain (SSTORE2, stored pre-base64'd) and builds
 *         fully onchain metadata: SVG cover (`image`), live HTML piece (`animation_url`)
 *         and traits that mirror the script's own trait logic.
 */
contract CC0PERenderer is Owned {
    using LibString for uint256;

    address[] public scriptChunks; // base64 chunks of the generator (each chunk length % 4 == 0)
    bool public scriptLocked;
    string public imageBase; // optional offchain thumbnails ("" = onchain SVG cover)
    string public desc =
        "CC0PE HARDER is the first collection from CC0PE. All future CC0PE art will only be available by burning pieces from this collection. Fully onchain generative skull glitch art, an homage to the CC0 work of XCOPY. Not made by, affiliated with or endorsed by XCOPY. CC0. Press P to pause, S to save a PNG.";

    error ScriptLocked();

    constructor() Owned(msg.sender) {}

    function addScriptChunk(string calldata b64) external onlyOwner {
        if (scriptLocked) revert ScriptLocked();
        scriptChunks.push(SSTORE2.write(bytes(b64)));
    }

    function resetScript() external onlyOwner {
        if (scriptLocked) revert ScriptLocked();
        delete scriptChunks;
    }

    function lockScript() external onlyOwner {
        scriptLocked = true;
    }

    function setImageBase(string calldata b) external onlyOwner {
        imageBase = b;
    }

    function setDescription(string calldata d) external onlyOwner {
        desc = d;
    }

    /// @notice Raw generator script (decoded), handy for verification / mirrors.
    function scriptBase64() external view returns (string memory out) {
        for (uint256 i; i < scriptChunks.length; ++i) out = string(abi.encodePacked(out, SSTORE2.read(scriptChunks[i])));
    }

    // ------------------------------------------------------------------ traits (mirror art.js)
    function _pick(string memory csv, uint256 n, uint256 idx) internal pure returns (string memory) {
        bytes memory b = bytes(csv);
        uint256 field;
        uint256 st;
        for (uint256 i; i <= b.length; ++i) {
            if (i == b.length || b[i] == "|") {
                if (field == idx % n) {
                    bytes memory o = new bytes(i - st);
                    for (uint256 k; k < o.length; ++k) o[k] = b[st + k];
                    return string(o);
                }
                ++field;
                st = i + 1;
            }
        }
        return "";
    }

    string constant SUBJ = "SKULL|SKULL BUST|REAPER|BURNING SKULL|SCREAMER|HEAD STACK|TWINS|DEATH COIN|GRAVESTONE|GRAVEYARD|CRYPT|CROSSED SCYTHES|COFFIN|CATACOMBS|GRAVE SKULL|SICKLE MOON|CROWNED SKULL|DIAMOND SKULL|ASTRONAUT SKULL|MOON TOMB|CRT SKULL|HACKER SKULL|VR SKULL|BODY BAG|RED CANDLE|PADLOCK JAW|SKULL SWARM|HOURGLASS|THRONE OF COINS|DOOMSCROLL|SPLIT SKULL|HYPNO SKULL";
    string constant PALN = "RED DEATH|ACID|ICE|VAPOR|TOXIC|RED ROOM|BLEACH|BURN|GHOST|SICK|GOLD|MATRIX|BLOODWAVE|BLUEPRINT|PURPLE HAZE|SODA|SLIME|INFRARED|CRT AMBER|NEGATIVE|RUST|OCEAN|BUBBLEGUM|NIGHT VISION|SILVER|ULTRAVIOLET|BONE|GRAVE MOSS|TOMB BLUE|HELLFIRE|COBWEB|VOID PINK";
    // bg,fill,ink,hi per palette (hex without #)
    string constant PALC =
        "000000ff1e1e000000ffffff|0000003dff2e000000ff2bd6|00000018e7ff000000ffffff|0a0014ff2bd60a001418e7ff|000000f2ff00000000ff2200|d40000000000d40000ffffff|ececec111111ecececff0000|120400ff6a00120400ffe600|000000e8e8e8000000ff0000|0e1a00b6ff000e1a00ff006e|000000ffcc00000000ffffff|00000000ff41000000d7ffd7|8b000000f0ff200000ffffff|0033ccffffff0033ccffea00|12001fb026ff12001f00ff9c|ff2e88000000ff2e88ffffff|2a0045c6ff002a0045ff00aa|000000ff0055000000ffd000|0d0700ffb0000d0700fff4d6|ffffff000000ffffff00e5ff|1a0f0ac4501b1a0f0af2e4c9|00121a00ffd500121aff6a00|ffd1f0000000ffd1f0ff004c|0011007dff7d001100ffffff|1a1a1ac0c0c01a1a1a00e5ff|05001a6b2bff05001aff2bd6|1b1712e9dfc41b1712ff2a00|07110a7fae3a07110ae8ffd0|0008143a86ff000814ffbe0b|1a0000ff3c001a0000ffe100|d9d9d92b2b2bd9d9d98f00ff|000000ff7ab6000000ffffff";
    string constant WORDS =
        "GOOD MOURNING|GN FOREVER|REKT IN PEACE|NGMI|REKT|HODL TIL DEATH|DIAMOND BONES|PAPER HANDS PAPER CASKET|WEN TOMB|WEN COFFIN|TO THE TOMB|FEW SURVIVE|DIG YOUR OWN GRAVE|NOT FUNERAL ADVICE|FEAR UNCERTAINTY DEATH|FEAR OF MORTALITY|APED IN DIED OUT|MINT CONDITION CORPSE|SENT TO 0xDEAD|PUMP AND DIE|BODY BAG HOLDER|EXIT LIQUIDITY|DEATH CONTRACT|SMART CONTRACT DUMB SKULL|LAST WORDS: SEED PHRASE|COLD WALLET COLDER BODY|COLD STORAGE|DEAD DROP|ALLOWLISTED FOR HELL|STAKED THROUGH THE HEART|LIQUIDATED|FINAL MARGIN CALL|100X DEAD|ALL TIME LOW|ALL TIME HAUNTED|LIGHT A RED CANDLE|CHART FLATLINED|BLOCK HEIGHT: 6 FT|HARD FORK SOFT SKULL|SLASHED|LAYER 2 OF HELL|ROLLED UP IN A RUG|RUGGED|THE ORACLE SAYS NGMI|DEAD AUTONOMOUS ORG|DEFI-BRILLATOR|CEMETERY FINANCE|TOTAL VALUE LOST|KNOW YOUR CORPSE|NON-FUNGIBLE TOMBSTONE|POST FUNERAL PIC|DEAD JPEG|ROYALTIES: 0%|1 OF 1 LIVES|OPEN EDITION GRAVE|THE REVEAL WAS A SKULL|METAVERSE MORGUE|BURIED ONCHAIN|IN PEACE FOREVER STORED|EXECUTION REVERTED|PENDING FOREVER|NONCE TOO LOW|0xDEAD|SATOSHIS GHOST|ETHEREAL|THE GWEI OF ALL FLESH|DROWNED IN THE MEMPOOL|SANDWICHED|FRONT-RUN BY DEATH|SWEEP THE GRAVEYARD|SER THIS IS A MORGUE|RIGHT-CLICK SAVE AS SKULL|PROBABLY NOTHING|LOOKS RARE|UTILITY: NONE|ROADMAP: GRAVE|DOXXED BY DEATH|SOULBOUND|PROOF OF DEATH|CONSENSUS: DEAD|51% DEAD|HASH RATE FLATLINE|TOKEN-GATED AFTERLIFE|BLUE CHIP CORPSE|BUY THE DIRT|BURY THE DIP|DEPEGGED|ZERO KNOWLEDGE ZERO PULSE|MULTISIG: 0 OF 3 ALIVE|PRIVATE KEY TO THE CRYPT|CRYPT-O|GHOST CHAIN|BRIDGE TO NOWHERE|100% SLIPPAGE|PERMANENT LOSS|GASSED OUT|OUT OF GAS|GAS WAR CASUALTY|DEAD CAT BOUNCE|BEAR MARKET BONES|BULL TRAPPED|WAGMI?|FEW.|FUD|HODL|CTRL+C CTRL+V|COPY PASTE REPEAT|DEAD FRENS|LASER EYES DEAD EYES|FLOOR: 6 FT UNDER|FROM GENESIS TO GRAVE|GRIM MORNING|WE ARE ALL GONNA DIE|GM TO THE DEAD|LFG: LETS FLATLINE GUYS|HAVE FUN STAYING DEAD|TOUCH GRASS FROM BELOW|DYING FOR THE CULTURE|ITS SO OVER|SO BACK FROM THE DEAD|NFA DYOR RIP|SER WHERE IS MY PULSE|BASED AND DEADPILLED|DEGEN TIL DEATH|YOU ARE THE EXIT LIQUIDITY|ALPHA LEAK: EVERYONE DIES|NOT YOUR KEYS NOT YOUR CORPSE|IN CODE WE RUST|CODE IS LAW DEATH IS FINAL|DONT TRUST VERIFY YOUR PULSE|FUNDS ARE NOT SAFU|COPE HARDER|PROBABLY SOMETHING|FEW UNDERSTAND DEATH|FRENS TIL THE END|GN SWEET PRINCE|IYKYK RIP|BOUGHT THE TOP|CAPITULATION|BLOOD IN THE STREETS|CATCHING FALLING KNIVES|STOP LOSS: LIFE|TAKE PROFIT: NEVER|LONG DEAD|SHORT LIFE|SKULL AND CROSS MARGIN|WICKED|LONG WICK SHORT LIFE|SUPPORT IS BROKEN|RESISTANCE IS FUTILE|HEAD AND SHOULDERS|DOUBLE BOTTOM SIX FEET DEEP|COPIUM|OUT OF HOPIUM|NUMBER GO DOWN|NUMBER GO UP IN HEAVEN|FLASH CRASH|PANIC SELL|SOLD MY SOUL AT THE BOTTOM|ORDER BOOK OF THE DEAD|SLIPPED AWAY|ETERNAL CRYPTO WINTER|HALVING MY LIFE|THE 4 YEAR CYCLE OF DEATH|FUNDING RATE: DEATH|OPEN INTEREST: NONE|LIMIT ORDER: LIFETIME|YIELD FARMING THE GRAVEYARD|DRAINED THE POOL|FLASH LOAN FROM THE REAPER|UNCOLLATERALIZED SOUL|HEALTH FACTOR: 0|APY: ALL PERISH YEARLY|APR: ANOTHER PERSON REKT|TREASURY EMPTY|DEATH SPIRAL|PONZINOMICS|RUNWAY: 0 DAYS|VAMPIRE ATTACK|IMPERMANENT LIFE|UNSTABLECOIN|WRAPPED IN A SHROUD|BRIDGED TO THE AFTERLIFE|CROSS-CHAIN CROSSBONES|OMNICHAIN OBITUARY|POINTS PROGRAM: 0 POINTS|SYBIL DETECTED|RESTAKED|PROPOSAL REJECTED|VOTE TO DISSOLVE|GOVERNANCE TOKEN: TOMBSTONE|GAS LIMIT EXCEEDED|BASE FEE: YOUR SOUL|FINALITY|FINALITY REACHED|ORPHANED BLOCK|REORGANIZED REMAINS|SELFDESTRUCT()|REVERT()|REQUIRE(PULSE)|INTEGER UNDERFLOW|REENTRANCY INTO HELL|UPGRADEABLE AFTERLIFE|IMMUTABLE DEATH|VERIFIED DEAD|ERC-RIP|ERC-721 TOMBSTONE|EIP-1559: EVERYTHING BURNS|ULTRA SOUND COFFIN|EXTRACTED VALUE: YOU|MERGED WITH THE VOID|SHARDED SKULL|BLOBSPACE COFFIN|ZK PROOF OF LIFE: FAILED|DECENTRALIZED DECAY|PERMISSIONLESS PURGATORY|TRUSTLESS TOMB|UNSTOPPABLE DEATH|404 PULSE NOT FOUND|LIFE WAS A TESTNET|MERKLE ROOT OF ALL EVIL|RPC ERROR: NO PULSE|WRONG NETWORK|INSUFFICIENT FUNDS FOR GAS|HASH COLLISION|ONCHAIN OR IT DIDNT HAPPEN|FULLY ONCHAIN FULLY DEAD|SSTORE2 THE SOUL|THE FLOOR IS LAVA|PFP OF THE DEAD|DERIVATIVE|DERIVATIVE OF A DERIVATIVE|CC0 FOREVER|NO RIGHTS RESERVED|RIGHT-CLICKER|SCREENSHOT THIS|YOU CANT RIGHT-CLICK DEATH|UNREVEALED|REVEAL DAY: JUDGMENT DAY|TRAIT: DECEASED|RARITY: 1 OF 1 DEAD|GRAIL|BURN TO REDEEM|FREE MINT COSTS YOUR SOUL|OPEN EDITION OPEN CASKET|MINT OR DIE|ROYALTIES ARE DEAD|WASH TRADED|FLIPPED AND FORGOTTEN|GENERATIVE DEATH|METADATA FROZEN|SWEEP ME|12 WORDS 6 FEET|24 WORDS 0 PULSE|SEED PHRASE: 12 FEET DEEP|PHISHED|DRAINED|HOT WALLET HOTTER HELL|CONNECT WALLET|SIGN WITH BLOOD|APPROVE UNLIMITED|SETAPPROVALFORALL(DEATH)|DEAD.ETH|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE|NONE";
    string constant GL = "SLOW BURN|UNSTABLE|MELTDOWN|FLATLINE";
    string constant EYES = "GLOW|WIDE|SOLID|SPIRAL|SPINNER|X|SPINNER|SPIRAL";

    function _col(uint256 pal, uint256 k) internal pure returns (string memory) {
        bytes memory all = bytes(PALC);
        uint256 off = pal * 25 + k * 6;
        bytes memory o = new bytes(7);
        o[0] = "#";
        for (uint256 i; i < 6; ++i) o[i + 1] = all[off + i];
        return string(o);
    }

    function traits(bytes32 h)
        public
        pure
        returns (string memory subj, string memory pal, string memory cap, string memory glitch, string memory eyes)
    {
        subj = _pick(SUBJ, 32, uint8(h[0]));
        pal = _pick(PALN, 32, uint8(h[1]));
        cap = _pick(WORDS, 288, _capIdx(h));
        glitch = _pick(GL, 4, uint8(h[3]));
        eyes = _pick(EYES, 8, uint8(h[4]));
    }

    function _capIdx(bytes32 h) internal pure returns (uint256) {
        return (uint256(uint8(h[2])) << 8) | uint8(h[5]);
    }

    // ------------------------------------------------------------------ rendering
    function _hex(bytes32 h) internal pure returns (string memory) {
        return Strings.toHexString(uint256(h), 32);
    }

    /// @notice Full HTML of the piece, base64 encoded (ready for a data: URI).
    function htmlBase64(string memory name, uint256 id, bytes32 h) public view returns (string memory) {
        bytes memory pre = abi.encodePacked(
            "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><title>",
            name,
            " #",
            id.toString(),
            "</title><style>html,body{margin:0;height:100%;background:#000;display:flex;align-items:center;justify-content:center;overflow:hidden}canvas{image-rendering:pixelated}</style></head><body><script>window.tokenData={hash:\"",
            _hex(h),
            "\",tokenId:\"",
            id.toString(),
            "\"}</script><script>"
        );
        while (pre.length % 3 != 0) pre = abi.encodePacked(pre, " ");
        bytes memory out = bytes(Base64.encode(pre));
        for (uint256 i; i < scriptChunks.length; ++i) out = abi.encodePacked(out, SSTORE2.read(scriptChunks[i]));
        return string(abi.encodePacked(out, Base64.encode("</script></body></html>")));
    }

    function _a(string memory a, string memory b, string memory c, string memory d) internal pure returns (bytes memory) {
        return abi.encodePacked(a, b, c, d);
    }

    function _glyph(uint256 s, string memory fi, string memory ink, string memory hi) internal pure returns (bytes memory) {
        if (s == 8 || s == 9 || s == 10 || s == 12 || s == 14 || s == 15 || s == 19) {
            // GRAVE family: tombstone with skull carving
            return abi.encodePacked(
                _a("<path d='M48 250V110a80 80 0 0 1 160 0v140z' fill='", fi, "' stroke='", ink),
                _a("' stroke-width='6'/><text x='128' y='214' text-anchor='middle' font-family='monospace' font-weight='900' font-size='26' fill='", ink, "'>R.I.P.</text><g transform='translate(128 132) scale(.42) translate(-128 -126)'>", string(_glyph(0, hi, ink, fi))),
                "</g>"
            );
        }
        if (s == 11) {
            // CROSSED SCYTHES
            return abi.encodePacked(
                _a("<path d='M24 250L226 30M232 250L30 30' stroke='", ink, "' stroke-width='10'/><path d='M226 30q-40-30-90-10q40 0 70 30zM30 30q40-30 90-10q-40 0-70 30z' fill='", hi),
                "'/>",
                _glyph(0, fi, ink, hi)
            );
        }
        if (s == 3) {
            // BURNING SKULL: flames behind the skull glyph
            return abi.encodePacked(
                _a("<path d='M58 120L46 40 78 78 92 14 112 66 128 2 144 66 164 14 178 78 210 40 198 120z' fill='", hi, "' stroke='", fi),
                "' stroke-width='6'/>",
                _glyph(0, fi, ink, hi)
            );
        }
        if (s == 2) {
            // REAPER
            return abi.encodePacked(
                _a("<path d='M30 250L226 30' stroke='", hi, "' stroke-width='6'/><path d='M128 16Q190 40 200 140L220 256H36L56 140Q66 40 128 16z' fill='", fi),
                _a("' stroke='", ink, "' stroke-width='5'/><ellipse cx='128' cy='112' rx='36' ry='48' fill='", ink),
                _a("'/><circle cx='114' cy='104' r='5' fill='", hi, "'/><circle cx='142' cy='104' r='5' fill='", hi),
                "'/>"
            );
        }
        // SKULL family
        return abi.encodePacked(
            _a("<path d='M128 36C58 36 50 96 56 132c4 26 24 32 26 58h92c2-26 22-32 26-58 6-36-2-96-72-96z' fill='", fi, "' stroke='", ink),
            _a("' stroke-width='5'/><ellipse cx='96' cy='124' rx='22' ry='24' fill='", ink, "'/><ellipse cx='162' cy='124' rx='26' ry='27' fill='", ink),
            _a("'/><circle cx='98' cy='124' r='4' fill='", hi, "'/><circle cx='160' cy='126' r='4' fill='", hi),
            _a("'/><path d='M128 150l-10 22h20z' fill='", ink, "'/><rect x='88' y='190' width='80' height='26' fill='", hi),
            _a("' stroke='", ink, "' stroke-width='5'/><path d='M104 190v26M120 190v26M136 190v26M152 190v26' stroke='", ink),
            "' stroke-width='3'/>"
        );
    }

    function _svgTop(uint256 id, bytes32 h, uint256 pal) internal pure returns (bytes memory) {
        return abi.encodePacked(
            "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'><defs><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='0.001 0.25' seed='",
            (id % 997).toString(),
            "'/><feDisplacementMap in='SourceGraphic' scale='",
            (uint256(uint8(h[3]) % 4) * 4 + 4).toString(),
            "'/></filter><pattern id='s' width='4' height='4' patternUnits='userSpaceOnUse'><rect width='4' height='2' fill='#000' opacity='.25'/></pattern></defs><rect width='256' height='256' fill='",
            _col(pal, 0),
            "'/><g filter='url(#g)'>"
        );
    }

    function _capEl(bytes32 h, uint256 pal) internal pure returns (bytes memory) {
        string memory cap = _pick(WORDS, 288, _capIdx(h));
        if (keccak256(bytes(cap)) == keccak256("NONE")) return "";
        uint256 n = bytes(cap).length;
        return abi.encodePacked(
            "<text x='128' y='30' text-anchor='middle' font-family='Impact,Arial Black,sans-serif' font-weight='900' font-size='",
            n > 18 ? "15" : n > 12 ? "19" : "24",
            "' fill='",
            _col(pal, 3), "' stroke='", _col(pal, 2), "' stroke-width='1'>", cap, "</text>"
        );
    }

    /// @notice Onchain SVG cover used as `image` (marketplace grids can't run JS).
    function svg(uint256 id, bytes32 h) public pure returns (string memory) {
        uint256 pal = uint8(h[1]) % 32;
        return string(
            abi.encodePacked(
                _svgTop(id, h, pal),
                _glyph(uint8(h[0]) % 32, _col(pal, 1), _col(pal, 2), _col(pal, 3)),
                "</g>",
                _capEl(h, pal),
                "<rect width='256' height='256' fill='url(#s)'/><text x='248' y='248' text-anchor='end' font-family='monospace' font-size='10' fill='",
                _col(pal, 3), "'>#", id.toString(), "</text></svg>"
            )
        );
    }

    function _attrs(bytes32 h) internal pure returns (bytes memory) {
        (string memory s, string memory p, string memory c, string memory g, string memory e) = traits(h);
        return abi.encodePacked(
            abi.encodePacked("[{\"trait_type\":\"Subject\",\"value\":\"", s, "\"},{\"trait_type\":\"Palette\",\"value\":\"", p),
            abi.encodePacked("\"},{\"trait_type\":\"Caption\",\"value\":\"", c, "\"},{\"trait_type\":\"Glitch\",\"value\":\"", g),
            "\"},{\"trait_type\":\"Eyes\",\"value\":\"", e, "\"}]"
        );
    }

    function _image(uint256 id, bytes32 h) internal view returns (string memory) {
        if (bytes(imageBase).length > 0) return string(abi.encodePacked(imageBase, id.toString()));
        return string(abi.encodePacked("data:image/svg+xml;base64,", Base64.encode(bytes(svg(id, h)))));
    }

    function tokenURI(string calldata name, uint256 id, bytes32 h) external view returns (string memory) {
        bytes memory json = abi.encodePacked(
            "{\"name\":\"", name, " #", id.toString(),
            "\",\"description\":\"", desc,
            "\",\"image\":\"", _image(id, h),
            "\",\"animation_url\":\"data:text/html;base64,", htmlBase64(name, id, h),
            "\",\"attributes\":", _attrs(h), "}"
        );
        return string(abi.encodePacked("data:application/json;base64,", Base64.encode(json)));
    }
}

lib/openzeppelin-contracts/contracts/utils/Base64.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides a set of functions to operate with Base64 strings.
 *
 * _Available since v4.5._
 */
library Base64 {
    /**
     * @dev Base64 Encoding/Decoding Table
     */
    string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

    /**
     * @dev Converts a `bytes` to its Bytes64 `string` representation.
     */
    function encode(bytes memory data) internal pure returns (string memory) {
        /**
         * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence
         * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol
         */
        if (data.length == 0) return "";

        // Loads the table into memory
        string memory table = _TABLE;

        // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter
        // and split into 4 numbers of 6 bits.
        // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up
        // - `data.length + 2`  -> Round up
        // - `/ 3`              -> Number of 3-bytes chunks
        // - `4 *`              -> 4 characters for each chunk
        string memory result = new string(4 * ((data.length + 2) / 3));

        /// @solidity memory-safe-assembly
        assembly {
            // Prepare the lookup table (skip the first "length" byte)
            let tablePtr := add(table, 1)

            // Prepare result pointer, jump over length
            let resultPtr := add(result, 32)

            // Run over the input, 3 bytes at a time
            for {
                let dataPtr := data
                let endPtr := add(data, mload(data))
            } lt(dataPtr, endPtr) {

            } {
                // Advance 3 bytes
                dataPtr := add(dataPtr, 3)
                let input := mload(dataPtr)

                // To write each character, shift the 3 bytes (18 bits) chunk
                // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)
                // and apply logical AND with 0x3F which is the number of
                // the previous character in the ASCII table prior to the Base64 Table
                // The result is then added to the table to get the character to write,
                // and finally write it in the result pointer but with a left shift
                // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits

                mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance
            }

            // When data `bytes` is not exactly 3 bytes long
            // it is padded with `=` characters at the end
            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 result;
    }
}

lib/openzeppelin-contracts/contracts/utils/Strings.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

lib/openzeppelin-contracts/contracts/utils/math/Math.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

lib/solmate/src/auth/Owned.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Simple single owner authorization mixin.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Owned.sol)
abstract contract Owned {
    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    event OwnerUpdated(address indexed user, address indexed newOwner);

    /*//////////////////////////////////////////////////////////////
                            OWNERSHIP STORAGE
    //////////////////////////////////////////////////////////////*/

    address public owner;

    modifier onlyOwner() virtual {
        require(msg.sender == owner, "UNAUTHORIZED");

        _;
    }

    /*//////////////////////////////////////////////////////////////
                               CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    constructor(address _owner) {
        owner = _owner;

        emit OwnerUpdated(address(0), _owner);
    }

    /*//////////////////////////////////////////////////////////////
                             OWNERSHIP LOGIC
    //////////////////////////////////////////////////////////////*/

    function setOwner(address newOwner) public virtual onlyOwner {
        owner = newOwner;

        emit OwnerUpdated(msg.sender, newOwner);
    }
}

lib/solmate/src/utils/LibString.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

/// @notice Efficient library for creating string representations of integers.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/LibString.sol)
/// @author Modified from Solady (https://github.com/Vectorized/solady/blob/main/src/utils/LibString.sol)
library LibString {
    function toString(uint256 value) internal pure returns (string memory str) {
        assembly {
            // The maximum value of a uint256 contains 78 digits (1 byte per digit), but we allocate 160 bytes
            // to keep the free memory pointer word aligned. We'll need 1 word for the length, 1 word for the
            // trailing zeros padding, and 3 other words for a max of 78 digits. In total: 5 * 32 = 160 bytes.
            let newFreeMemoryPointer := add(mload(0x40), 160)

            // Update the free memory pointer to avoid overriding our string.
            mstore(0x40, newFreeMemoryPointer)

            // Assign str to the end of the zone of newly allocated memory.
            str := sub(newFreeMemoryPointer, 32)

            // Clean the last word of memory it may not be overwritten.
            mstore(str, 0)

            // Cache the end of the memory to calculate the length later.
            let end := str

            // We write the string from rightmost digit to leftmost digit.
            // The following is essentially a do-while loop that also handles the zero case.
            // prettier-ignore
            for { let temp := value } 1 {} {
                // Move the pointer 1 byte to the left.
                str := sub(str, 1)

                // Write the character to the pointer.
                // The ASCII index of the '0' character is 48.
                mstore8(str, add(48, mod(temp, 10)))

                // Keep dividing temp until zero.
                temp := div(temp, 10)

                 // prettier-ignore
                if iszero(temp) { break }
            }

            // Compute and cache the final total length of the string.
            let length := sub(end, str)

            // Move the pointer 32 bytes leftwards to make room for the length.
            str := sub(str, 32)

            // Store the string's length at the start of memory allocated for our string.
            mstore(str, length)
        }
    }
}

lib/solmate/src/utils/SSTORE2.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Read and write to persistent storage at a fraction of the cost.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SSTORE2.sol)
/// @author Modified from 0xSequence (https://github.com/0xSequence/sstore2/blob/master/contracts/SSTORE2.sol)
library SSTORE2 {
    uint256 internal constant DATA_OFFSET = 1; // We skip the first byte as it's a STOP opcode to ensure the contract can't be called.

    /*//////////////////////////////////////////////////////////////
                               WRITE LOGIC
    //////////////////////////////////////////////////////////////*/

    function write(bytes memory data) internal returns (address pointer) {
        // Prefix the bytecode with a STOP opcode to ensure it cannot be called.
        bytes memory runtimeCode = abi.encodePacked(hex"00", data);

        bytes memory creationCode = abi.encodePacked(
            //---------------------------------------------------------------------------------------------------------------//
            // Opcode  | Opcode + Arguments  | Description  | Stack View                                                     //
            //---------------------------------------------------------------------------------------------------------------//
            // 0x60    |  0x600B             | PUSH1 11     | codeOffset                                                     //
            // 0x59    |  0x59               | MSIZE        | 0 codeOffset                                                   //
            // 0x81    |  0x81               | DUP2         | codeOffset 0 codeOffset                                        //
            // 0x38    |  0x38               | CODESIZE     | codeSize codeOffset 0 codeOffset                               //
            // 0x03    |  0x03               | SUB          | (codeSize - codeOffset) 0 codeOffset                           //
            // 0x80    |  0x80               | DUP          | (codeSize - codeOffset) (codeSize - codeOffset) 0 codeOffset   //
            // 0x92    |  0x92               | SWAP3        | codeOffset (codeSize - codeOffset) 0 (codeSize - codeOffset)   //
            // 0x59    |  0x59               | MSIZE        | 0 codeOffset (codeSize - codeOffset) 0 (codeSize - codeOffset) //
            // 0x39    |  0x39               | CODECOPY     | 0 (codeSize - codeOffset)                                      //
            // 0xf3    |  0xf3               | RETURN       |                                                                //
            //---------------------------------------------------------------------------------------------------------------//
            hex"60_0B_59_81_38_03_80_92_59_39_F3", // Returns all code in the contract except for the first 11 (0B in hex) bytes.
            runtimeCode // The bytecode we want the contract to have after deployment. Capped at 1 byte less than the code size limit.
        );

        assembly {
            // Deploy a new contract with the generated creation code.
            // We start 32 bytes into the code to avoid copying the byte length.
            pointer := create(0, add(creationCode, 32), mload(creationCode))
        }

        require(pointer != address(0), "DEPLOYMENT_FAILED");
    }

    /*//////////////////////////////////////////////////////////////
                               READ LOGIC
    //////////////////////////////////////////////////////////////*/

    function read(address pointer) internal view returns (bytes memory) {
        return readBytecode(pointer, DATA_OFFSET, pointer.code.length - DATA_OFFSET);
    }

    function read(address pointer, uint256 start) internal view returns (bytes memory) {
        start += DATA_OFFSET;

        return readBytecode(pointer, start, pointer.code.length - start);
    }

    function read(
        address pointer,
        uint256 start,
        uint256 end
    ) internal view returns (bytes memory) {
        start += DATA_OFFSET;
        end += DATA_OFFSET;

        require(pointer.code.length >= end, "OUT_OF_BOUNDS");

        return readBytecode(pointer, start, end - start);
    }

    /*//////////////////////////////////////////////////////////////
                          INTERNAL HELPER LOGIC
    //////////////////////////////////////////////////////////////*/

    function readBytecode(
        address pointer,
        uint256 start,
        uint256 size
    ) private view returns (bytes memory data) {
        assembly {
            // Get a pointer to some free memory.
            data := mload(0x40)

            // Update the free memory pointer to prevent overriding our data.
            // We use and(x, not(31)) as a cheaper equivalent to sub(x, mod(x, 32)).
            // Adding 31 to size and running the result through the logic above ensures
            // the memory pointer remains word-aligned, following the Solidity convention.
            mstore(0x40, add(data, and(add(add(size, 32), 31), not(31))))

            // Store the size of the data in the first 32 byte chunk of free memory.
            mstore(data, size)

            // Copy the code into memory right after the 32 bytes we used to store the size.
            extcodecopy(pointer, add(data, 32), start, size)
        }
    }
}
Compiler settingsShow
{
  "metadata": {
    "bytecodeHash": "none"
  },
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "london",
  "remappings": [
    "ERC721A-Upgradeable/=lib/ERC721A-Upgradeable/contracts/",
    "ERC721A/=lib/ERC721A/contracts/",
    "create2-helpers/=lib/create2-helpers/",
    "create2-scripts/=lib/create2-helpers/script/",
    "ds-test/=lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/",
    "murky/=lib/murky/src/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
    "operator-filter-registry/=lib/operator-filter-registry/src/",
    "seadrop/=src/",
    "solmate/=lib/solmate/src/",
    "utility-contracts/=lib/utility-contracts/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.