Skip to content
Verified contractExactMIT

Grails5SignatureGatedMintPassRedeemer

Address0x6fa6e4fbf76b84e478eeeede7e8b6273b1702c19
Balance

0 ETH

 

Transactions

176

 

Compiler

solc 0.8.21

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.21+commit.d9974bed
Language
solidity
Optimization
Yes, 9,999 runs
EVM version
paris
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
18,778,567
Creation transaction
0x25bdc4a01a…6568cc5853

90 files

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

/home/dave/solidifylabs/solidifylabs/contracts/sellers/src/sellable/SellableERC721ACommonByProjectID.sol

// SPDX-License-Identifier: MIT
// Copyright 2023 Proof Holdings Inc.
pragma solidity >=0.8.0 <0.9.0;

import {ISellable} from "solidifylabs/sellers/interfaces/ISellable.sol";
import {SellableERC721ACommon} from "solidifylabs/sellers/sellable/SellableERC721ACommon.sol";

/**
 * @notice Library for encoding and decoding purchase data for the Diamond Exhibition sellers.
 */
library PurchaseByProjectIDLib {
    function encodePurchaseData(uint128[] memory ids) internal pure returns (bytes memory) {
        return abi.encode(ids);
    }

    function decodePurchaseData(bytes memory data) internal pure returns (uint128[] memory) {
        return abi.decode(data, (uint128[]));
    }
}

/**
 * @notice Token information module for SellableERC721ACommonByProjectID.
 * @dev Separated for testability.
 * @author David Huber (@cxkoda)
 * @custom:reviewer Arran Schlosberg (@divergencearran)
 * @custom:reviewer Josh Laird (@jbmlaird)
 */
contract TokenInfoManager {
    /**
     * @notice Encodes token information.
     * @param projectId the ID of the project associated with the token.
     * @param edition the edition of the token within the given project.
     * @param extra extra information.
     */
    struct TokenInfo {
        uint128 projectId;
        uint64 edition;
        bytes8 extra;
    }

    /**
     * @notice Stores token information.
     */
    mapping(uint256 => TokenInfo) private _infos;

    /**
     * @notice Returns the token information for the given token IDs.
     * @dev Intended for off-chain use only.
     */
    function tokenInfos(uint256[] calldata tokenIds) external view returns (TokenInfo[] memory) {
        TokenInfo[] memory infos = new TokenInfo[](tokenIds.length);
        for (uint256 i = 0; i < tokenIds.length; ++i) {
            infos[i] = tokenInfo(tokenIds[i]);
        }
        return infos;
    }

    /**
     * @notice Returns the token information for the given token ID.
     */
    function tokenInfo(uint256 tokenId) public view returns (TokenInfo memory) {
        return _infos[tokenId];
    }

    /**
     * @notice Sets the token information for the given token ID.
     */
    function _setTokenInfo(uint256 tokenId, TokenInfo memory info) internal {
        _infos[tokenId] = info;
    }
}

/**
 * @dev Interface to indicate that the sellable handles purchase data with project IDs.
 */
interface ISellableByProjectID is ISellable {}

/**
 * @notice A sellable ERC721 contract that assigns a project ID to each token.
 * @author David Huber (@cxkoda)
 * @custom:reviewer Arran Schlosberg (@divergencearran)
 * @custom:reviewer Josh Laird (@jbmlaird)
 */
abstract contract SellableERC721ACommonByProjectID is SellableERC721ACommon, TokenInfoManager, ISellableByProjectID {
    // =========================================================================
    //                          Storage
    // =================================================================================================================

    /**
     * @notice The number of tokens minted per project.
     */
    mapping(uint128 => uint64) private _numPurchasedPerProject;

    /**
     * @inheritdoc SellableERC721ACommon
     * @dev Mints tokens with given project IDs encoded in the purchase data.
     */
    function _handleSale(address to, uint64 num, bytes calldata data) internal virtual override {
        uint128[] memory projectIds = PurchaseByProjectIDLib.decodePurchaseData(data);
        assert(projectIds.length == num);

        uint256 tokenId = _nextTokenId();
        for (uint256 i = 0; i < num; ++i) {
            // effects
            uint128 projectId = projectIds[i];
            uint64 edition = _numPurchasedPerProject[projectId]++;
            _setTokenInfo(tokenId, TokenInfo({projectId: projectId, edition: edition, extra: bytes8(0)}));

            // interactions
            _handleProjectMinted(tokenId, projectId, edition);

            tokenId++;
        }

        super._handleSale(to, num, data);
    }

    /**
     * @notice Hook called when a token with a given project ID is minted.
     */
    function _handleProjectMinted(uint256 tokenId, uint128 projectId, uint64 edition) internal virtual {}

    /**
     * @notice Returns the number of tokens minted for a given project.
     */
    function numPurchasedPerProject(uint128 projectId) public view returns (uint64) {
        return _numPurchasedPerProject[projectId];
    }
}
Compiler settingsShow
{
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 9999,
    "enabled": true
  },
  "evmVersion": "paris",
  "remappings": [
    "solidifylabs/presets/=/home/dave/solidifylabs/solidifylabs/contracts/presets/src/",
    "solidifylabs/artblocks/=/home/dave/solidifylabs/solidifylabs/contracts/artblocks/src/",
    "artblocks-contracts/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/artblocks-contracts_7f0af677/packages/contracts/contracts/",
    "artblocks-contracts_root/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/artblocks-contracts_7f0af677/",
    "openzeppelin-contracts-4-7-0/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/openzeppelin-contracts_4-7-0_exact_remap/contracts/",
    "openzeppelin-contracts_root-4-7-0/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/openzeppelin-contracts_4-7-0_exact_remap/",
    "@openzeppelin-4-7-0/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/openzeppelin-contracts_4-7-0_exact_remap/",
    "@openzeppelin-4.7/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/openzeppelin-contracts_4-7-0_exact_remap/",
    "solidifylabs/ethier/=/home/dave/solidifylabs/solidifylabs/contracts/ethier/src/",
    "ERC721A/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/ERC721A_4-2-3/contracts/",
    "ERC721A_root/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/ERC721A_4-2-3/",
    "erc721a/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/ERC721A_4-2-3/",
    "ethier/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/ethier_0-55-0/contracts/",
    "ethier_root/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/ethier_0-55-0/",
    "@divergencetech/ethier/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/ethier_0-55-0/",
    "openzeppelin-contracts/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/openzeppelin-contracts_4-8-1/contracts/",
    "openzeppelin-contracts_root/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/openzeppelin-contracts_4-8-1/",
    "@openzeppelin/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/openzeppelin-contracts_4-8-1/",
    "operator-filter-registry/src/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/operator-filter-registry_1-4-1/src/",
    "operator-filter-registry_root/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/operator-filter-registry_1-4-1/",
    "solidifylabs/redemption/=/home/dave/solidifylabs/solidifylabs/contracts/redemption/src/",
    "solidifylabs/sellers/=/home/dave/solidifylabs/solidifylabs/contracts/sellers/src/",
    "delegation-registry/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/delegation-registry_40d367d7/src/",
    "delegation-registry_root/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/delegation-registry_40d367d7/",
    "solidifylabs/artblocks_test/=/home/dave/solidifylabs/solidifylabs/contracts/artblocks/test/",
    "solidifylabs/constants/=/home/dave/solidifylabs/solidifylabs/contracts/constants/src/",
    "ds-test/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/ds-test_013e6c64/src/",
    "ds-test_root/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/ds-test_013e6c64/",
    "forge-std/=/home/dave/.cache/bazel/_bazel_dave/1a5ef124e5847560f6bb614f5401924c/external/forge-std_1-7-3/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.