Skip to content
Verified contractExactUNLICENSED

CipherMinterV2

Address0x8d4b84a013e9ee6a1abcbcd1cf71888234fcfff0
Balance

0 ETH

 

Transactions

42

 

Compiler

solc 0.8.27

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.27+commit.40a35a09
Language
solidity
Optimization
No
EVM version
prague
License
UNLICENSED
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
24,948,755
Creation transaction
0x4b40caa003…36d57adff8

src/CipherMinterV2.sol

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Owned} from "../lib/solmate/src/auth/Owned.sol";

interface IEncryptedERC721V2 {
    function mintFrom(
        uint[2] calldata _pA,
        uint[2][2] calldata _pB,
        uint[2] calldata _pC,
        uint[14] calldata _pubSignals,
        address to
    ) external;

    function tokenIds() external view returns (uint256);

    function maxNumber() external view returns (uint256);
}

/// @notice Tiered-price minter for EncryptedERC721
/// @dev Three explicit address groups, owner-managed:
///      Group 1 — existing holders (added by owner)   → HOLDER_PRICE
///      Group 2 — key-registered addresses            → KEY_PRICE
///      Group 3 — everyone else                       → PUBLIC_PRICE
///      An address in both groups gets Group 1 pricing.
///      Each discounted group has a per-address mint cap.
///      Once an address exhausts its cap it falls through to PUBLIC_PRICE.
/// @author plsdlr
contract CipherMinterV2 is Owned {
    // ============================================================
    //                      CONSTANTS
    // ============================================================

    uint256 public constant HOLDER_PRICE = 0.01 ether;
    uint256 public constant KEY_PRICE = 0.03 ether;
    uint256 public constant PUBLIC_PRICE = 0.06 ether;

    // ============================================================
    //                      STATE
    // ============================================================

    IEncryptedERC721V2 public immutable nft;

    address public artist;

    mapping(address => bool) public isGroup1;
    mapping(address => bool) public isGroup2;

    /// @notice Max discounted mints per address for each group.
    uint256 public group1MaxMints;
    uint256 public group2MaxMints;

    /// @notice Tracks how many discounted mints each address has used.
    mapping(address => uint256) public group1MintsUsed;
    mapping(address => uint256) public group2MintsUsed;

    // ============================================================
    //                      EVENTS
    // ============================================================

    event ArtistUpdated(address indexed oldArtist, address indexed newArtist);
    event Group1Updated(address indexed addr, bool added);
    event Group2Updated(address indexed addr, bool added);

    // ============================================================
    //                      CONSTRUCTOR
    // ============================================================

    constructor(address _nft, address _artist) Owned(msg.sender) {
        require(_nft != address(0), "Invalid nft");
        require(_artist != address(0), "Invalid artist");
        nft = IEncryptedERC721V2(_nft);
        artist = _artist;
    }

    // ============================================================
    //                      MINT
    // ============================================================

    function mint(
        uint[2] calldata _pA,
        uint[2][2] calldata _pB,
        uint[2] calldata _pC,
        uint[14] calldata _pubSignals,
        address to
    ) external payable {
        uint256 price = getPrice(msg.sender);
        require(msg.value == price, "Wrong price");

        if (price == HOLDER_PRICE) {
            group1MintsUsed[msg.sender]++;
        } else if (price == KEY_PRICE) {
            group2MintsUsed[msg.sender]++;
        }

        _processMint(_pA, _pB, _pC, _pubSignals, to);
    }

    // ============================================================
    //                      VIEW
    // ============================================================

    function getPrice(address user) public view returns (uint256) {
        if (isGroup1[user] && group1MintsUsed[user] < group1MaxMints) {
            return HOLDER_PRICE;
        } else if (isGroup2[user] && group2MintsUsed[user] < group2MaxMints) {
            return KEY_PRICE;
        } else {
            return PUBLIC_PRICE;
        }
    }

    function remainingSupply() external view returns (uint256) {
        return nft.maxNumber() - nft.tokenIds();
    }

    // ============================================================
    //                      OWNER — LIST MANAGEMENT
    // ============================================================

    /// @param maxMints Discount cap applied to every address in this group.
    function addGroup1(
        address[] calldata addrs,
        uint256 maxMints
    ) external onlyOwner {
        group1MaxMints = maxMints;
        for (uint256 i = 0; i < addrs.length; i++) {
            isGroup1[addrs[i]] = true;
            emit Group1Updated(addrs[i], true);
        }
    }

    function removeGroup1(address[] calldata addrs) external onlyOwner {
        for (uint256 i = 0; i < addrs.length; i++) {
            isGroup1[addrs[i]] = false;
            emit Group1Updated(addrs[i], false);
        }
    }

    /// @param maxMints Discount cap applied to every address in this group.
    function addGroup2(
        address[] calldata addrs,
        uint256 maxMints
    ) external onlyOwner {
        group2MaxMints = maxMints;
        for (uint256 i = 0; i < addrs.length; i++) {
            isGroup2[addrs[i]] = true;
            emit Group2Updated(addrs[i], true);
        }
    }

    function removeGroup2(address[] calldata addrs) external onlyOwner {
        for (uint256 i = 0; i < addrs.length; i++) {
            isGroup2[addrs[i]] = false;
            emit Group2Updated(addrs[i], false);
        }
    }

    // ============================================================
    //                      OWNER — CONFIG
    // ============================================================

    function setArtist(address _artist) external onlyOwner {
        require(_artist != address(0), "Invalid artist");
        emit ArtistUpdated(artist, _artist);
        artist = _artist;
    }

    // ============================================================
    //                      INTERNAL
    // ============================================================

    function _processMint(
        uint[2] calldata _pA,
        uint[2][2] calldata _pB,
        uint[2] calldata _pC,
        uint[14] calldata _pubSignals,
        address to
    ) internal {
        (bool ok, ) = artist.call{value: msg.value}("");
        require(ok, "ETH transfer to artist failed");
        nft.mintFrom(_pA, _pB, _pC, _pubSignals, to);
    }
}

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 OwnershipTransferred(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 OwnershipTransferred(address(0), _owner);
    }

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

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

        emit OwnershipTransferred(msg.sender, newOwner);
    }
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "evmVersion": "prague",
  "remappings": [
    "ds-test/=lib/solmate/lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/",
    "solady/=lib/solady/src/",
    "solmate/=lib/solmate/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.