Skip to content
Verified contractPartialMIT

IsoplethFusion

Address0x8a0d1d590226a2cfbd3e3cb56d509431e17373ff
Balance

0 ETH

 

Transactions

5

 

Compiler

solc 0.8.37

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.37+commit.f401782d
Language
solidity
Optimization
Yes, 1,000 runs
EVM version
prague
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,220,708
Creation transaction
0x3dc8188dce…177d623345

IsoplethFusion.sol

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

/// @notice The part of The Isopleth Atlas contract (ERC721SeaDropCloneable) that fusion uses.
interface IIsopleth {
    function ownerOf(uint256 tokenId) external view returns (address);

    /// Burns `tokenId`. The caller must own it or be an approved operator.
    function burn(uint256 tokenId) external;

    /// currentTotalSupply is _totalMinted(): burns never lower it.
    function getMintStats(address minter)
        external
        view
        returns (uint256 minterNumMinted, uint256 currentTotalSupply, uint256 maxSupply);
}

/// @title The Isopleth Atlas — Fusion
/// @notice Pick one of your works as the base and feed it others. The feed is burned,
///         the base keeps its token id and grows. The new traits and the new render are
///         computed off-chain from the Fused events alone, by the published rules
///         (`rulesHash`), so anyone can recompute every result.
/// @dev    No minting rights, no upgrades, no funds. The only power this contract has is
///         to burn tokens of an owner who approved it, and only inside that owner's own call.
contract IsoplethFusion {
    IIsopleth public immutable isopleth;
    address public immutable admin;
    bytes32 public immutable rulesHash;

    /// A fusion chamber holds up to 12 cells: one base and up to 11 in the feed.
    uint256 public constant MAX_FEED = 11;

    bool public open;
    uint256 public fusions;
    mapping(uint256 => bool) public isOneOfOne;

    event Fused(uint256 indexed fusionId, address indexed owner, uint256 indexed base, uint256[] feed);
    event OpenSet(bool open);

    error NotAdmin();
    error Closed();
    error MintNotClosed(uint256 minted, uint256 maxSupply);
    error BadFeedLength(uint256 length);
    error NotOwner(uint256 tokenId);
    error FeedNotAscending();
    error BaseInFeed();
    error OneOfOneMustBeBase(uint256 tokenId);

    /// @param isopleth_   The Isopleth Atlas contract.
    /// @param rulesHash_  sha256 of the fusion rules file the results are computed with.
    /// @param oneOfOnes   Token ids of the one-of-one works (known once the mint is closed).
    constructor(IIsopleth isopleth_, bytes32 rulesHash_, uint256[] memory oneOfOnes) {
        isopleth = isopleth_;
        admin = msg.sender;
        rulesHash = rulesHash_;
        for (uint256 i; i < oneOfOnes.length; ++i) isOneOfOne[oneOfOnes[i]] = true;
    }

    /// @notice Open or pause fusion. Admin only.
    function setOpen(bool open_) external {
        if (msg.sender != admin) revert NotAdmin();
        open = open_;
        emit OpenSet(open_);
    }

    /// @notice Fuse `feed` into `base`. All tokens must be yours, `feed` sorted ascending,
    ///         without repeats and without `base`. If any of them is a one-of-one, the base
    ///         must be a one-of-one. Needs setApprovalForAll(this, true) on Isopleth once.
    function fuse(uint256 base, uint256[] calldata feed) external returns (uint256 fusionId) {
        if (!open) revert Closed();

        // Only after the mint is over: sold out, or supply lowered to what was minted.
        (, uint256 minted, uint256 maxSupply) = isopleth.getMintStats(address(0));
        if (minted != maxSupply) revert MintNotClosed(minted, maxSupply);

        uint256 n = feed.length;
        if (n == 0 || n > MAX_FEED) revert BadFeedLength(n);
        if (isopleth.ownerOf(base) != msg.sender) revert NotOwner(base);

        bool baseIsOne = isOneOfOne[base];
        uint256 prev;
        for (uint256 i; i < n; ++i) {
            uint256 id = feed[i];
            if (i != 0 && id <= prev) revert FeedNotAscending(); // also rules out repeats
            if (id == base) revert BaseInFeed();
            if (!baseIsOne && isOneOfOne[id]) revert OneOfOneMustBeBase(id);
            if (isopleth.ownerOf(id) != msg.sender) revert NotOwner(id);
            prev = id;
        }

        // Burning has no callbacks in ERC721A, so nothing can re-enter between checks and burns.
        for (uint256 i; i < n; ++i) isopleth.burn(feed[i]);

        fusionId = ++fusions;
        emit Fused(fusionId, msg.sender, base, feed);
    }
}
Compiler settingsShow
{
  "metadata": {
    "bytecodeHash": "none"
  },
  "optimizer": {
    "runs": 1000,
    "details": {
      "yul": false
    },
    "enabled": true
  },
  "evmVersion": "prague"
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.