Skip to content
Verified contractExactMIT

Garden

Address0xd28de34e1d739e5b60e50c77fe64cfa8eb072066
Balance

0 ETH

 

Transactions

8

 

Compiler

solc 0.8.38

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.38+commit.1835d247
Language
solidity
Optimization
Yes, 200 runs
EVM version
cancun
Via IR
yes
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,377,105
Creation transaction
0x2d3e0610b8…3fbab96bcc

58 files

The source code is large: one file is shown at a time. Choose a file in the list.

project/contracts/drops/garden/Garden.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.38;

import "@openzeppelin/contracts/access/Ownable2Step.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import { LibString } from "solady/src/utils/LibString.sol";

import "../../studio/NetworkedAuctionRouter.sol";
import "../../studio/interfaces/INetworkedAuctionEngine.sol";
import "./GardenPatronEdition.sol";

/// @title  The Garden by Doy
///
/// @notice 138 one-of-one works by DOY. 69 Dark and Gold pairs,
///         with fixed IPFS metadata and a companion Patron Edition.
contract Garden is ERC721, Ownable2Step, ReentrancyGuard {
    using LibString for uint256;

    // ───────────────────────────────── Types ─────────────────────────────────

    enum Allocation { Unassigned, Placed, Auction }

    // ─────────────────────── Constants and dependencies ──────────────────────

    uint256 public constant MAX_SUPPLY = 138;
    uint40 public constant AUCTION_DURATION = 48 hours;
    NetworkedAuctionRouter public immutable auctionRouter;
    address public immutable auctionEngine;
    address public immutable patronEdition;
    uint40 public immutable launchStart;
    uint40 public immutable launchEnd;

    // ──────────────────────────────── Storage ────────────────────────────────

    /// @notice The total number of originals minted.
    uint256 public totalSupply;

    /// @notice Fixed IPFS root with a trailing slash.
    string public baseURI;
    /// @notice Permanent assignment of each original.
    mapping(uint256 => Allocation) public allocationOf;

    /// @notice Launch auction controlling the work's Patron window.
    mapping(uint256 => uint256) public firstAuctionOf;

    // ───────────────────────────────── Errors ────────────────────────────────

    error InvalidVenue();
    error InvalidWindow();
    error InvalidBaseURI();
    error InvalidTokenId();
    error InvalidRecipient();
    error InvalidBatch();
    error AllocationClosed();
    error AlreadyAllocated();
    error NotAuctionEngine();
    error InvalidAuction();
    error RenounceDisabled();

    // ────────────────────────────── Constructor ──────────────────────────────

    /// @notice Pin the artist, sale contracts, launch time and metadata.
    constructor(
        address artist,
        address router_,
        address engine_,
        uint40 start,
        string memory baseURI_
    ) ERC721("The Garden", "GRDN") Ownable(artist) {
        if (router_.code.length == 0 || engine_.code.length == 0) revert InvalidVenue();
        if (INetworkedAuctionEngine(engine_).router() != router_) revert InvalidVenue();
        if (start <= block.timestamp || start > type(uint40).max - AUCTION_DURATION) revert InvalidWindow();
        bytes memory root = bytes(baseURI_);
        if (
            root.length <= 8 || bytes7(root) != bytes7("ipfs://")
                || root[root.length - 1] != bytes1("/")
        ) revert InvalidBaseURI();

        auctionRouter = NetworkedAuctionRouter(router_);
        auctionEngine = engine_;
        launchStart = start;
        launchEnd = start + AUCTION_DURATION;
        baseURI = baseURI_;
        GardenPatronEdition edition = new GardenPatronEdition(address(this), engine_);
        patronEdition = address(edition);
    }

    // ─────────────────────────────── Placement ───────────────────────────────

    /// @notice Mint an original to a collector before launch.
    function place(uint256 tokenId, address recipient) external onlyOwner nonReentrant {
        _place(tokenId, recipient);
    }

    /// @notice Place several originals before launch.
    function placeBatch(uint256[] calldata tokenIds, address[] calldata recipients)
        external
        onlyOwner
        nonReentrant
    {
        uint256 count = tokenIds.length;
        if (count == 0 || count > MAX_SUPPLY || count != recipients.length) revert InvalidBatch();
        for (uint256 i; i < count; ++i) _place(tokenIds[i], recipients[i]);
    }

    // ────────────────────────── Auction registration ─────────────────────────

    /// @notice Bind the launch auction and mint the original to the artist.
    ///         The first qualifying bid takes custody.
    /// @dev Only the pinned engine may register a matching router auction.
    ///      The assignment and Patron window cannot be reopened.
    function registerAuction(uint256 tokenId, uint256 auctionId) external nonReentrant {
        if (msg.sender != auctionEngine) revert NotAuctionEngine();
        _requireUnassigned(tokenId);
        if (auctionId == 0) revert InvalidAuction();
        INetworkedAuctionRouter.Auction memory auction = auctionRouter.getAuction(auctionId);
        if (
            auction.seller != owner()
                || auction.request.scope != INetworkedAuctionRouter.Scope.TokenAuction
                || auction.request.tokenStandard != INetworkedAuctionRouter.TokenStandard.ERC721
                || auction.request.collection != address(this)
                || auction.request.tokenId != tokenId || auction.request.quantity != 1
                || auction.startTimestamp != launchStart || auction.endTimestamp != launchEnd
                || auction.outcome != INetworkedAuctionRouter.Outcome.Active
                || auctionRouter.getEngine(auction.engineId).implementation != auctionEngine
        ) revert InvalidAuction();

        allocationOf[tokenId] = Allocation.Auction;
        firstAuctionOf[tokenId] = auctionId;
        ++totalSupply;
        _reportWindow(tokenId, auctionId);
        _safeMint(auction.seller, tokenId);
    }

    // ───────────────────────────── Patron windows ────────────────────────────

    /// @notice Whether the work's Patron window is open.
    function patronOpen(uint256 tokenId) external view returns (bool open) {
        (,, open) = patronWindow(tokenId);
    }

    /// @notice The work's Patron window, inclusive at both ends.
    ///         Placed works use the launch window; auctions follow extensions.
    ///         Unassigned works are closed.
    /// @dev Does not check whether a recipient already holds an edition.
    function patronWindow(uint256 tokenId) public view returns (uint40 start, uint40 end, bool open) {
        _requireValidToken(tokenId);
        (INetworkedAuctionRouter.PatronWindow memory window, bool eligible) = auctionRouter.patronWindow(address(this), tokenId);
        return (window.start, window.end, eligible);
    }

    // ──────────────────────────────── Metadata ───────────────────────────────

    /// @notice Token metadata, available before minting.
    function previewURI(uint256 tokenId) public view returns (string memory) {
        _requireValidToken(tokenId);
        return string.concat(baseURI, "metadata/", tokenId.toString(), ".json");
    }

    /// @inheritdoc ERC721
    function tokenURI(uint256 tokenId) public view override returns (string memory) {
        _requireOwned(tokenId);
        return previewURI(tokenId);
    }

    /// @notice Collection metadata.
    function contractURI() external view returns (string memory) {
        return string.concat(baseURI, "contract.json");
    }

    // ────────────────────────── Collection ownership ─────────────────────────

    /// @notice Disabled. Always reverts.
    function renounceOwnership() public view override onlyOwner {
        revert RenounceDisabled();
    }

    // ─────────────────────────────── Internals ───────────────────────────────

    function _place(uint256 tokenId, address recipient) private {
        _requireUnassigned(tokenId);
        if (recipient == address(0)) revert InvalidRecipient();
        allocationOf[tokenId] = Allocation.Placed;
        ++totalSupply;
        _reportWindow(tokenId, 0);
        _safeMint(recipient, tokenId);
    }

    function _reportWindow(uint256 tokenId, uint256 auctionId) private {
        auctionRouter.registerCollection(address(this));
        auctionRouter.configurePatronWindow(tokenId, auctionId, launchStart, launchEnd, 2500);
    }

    function _requireUnassigned(uint256 tokenId) private view {
        if (block.timestamp >= launchStart) revert AllocationClosed();
        _requireValidToken(tokenId);
        if (allocationOf[tokenId] != Allocation.Unassigned) revert AlreadyAllocated();
    }

    function _requireValidToken(uint256 tokenId) private pure {
        if (tokenId == 0 || tokenId > MAX_SUPPLY) revert InvalidTokenId();
    }
}
Compiler settingsShow
{
  "viaIR": true,
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "npm/@1001-digital/[email protected]/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
    "npm/@openzeppelin/[email protected]/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
    "project/:@1001-digital/erc721-extensions/=npm/@1001-digital/[email protected]/",
    "project/:@openzeppelin/contracts-upgradeable/=npm/@openzeppelin/[email protected]/",
    "project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
    "project/:solady/=npm/[email protected]/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.