Skip to content
Verified contractExactMIT

HolderArtBlocksProjectEligibility

Address0xb7b425d6dcb0cd12e2f14fbd112a49ae7c8d9414
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.17

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.17+commit.8df45f5f
Language
solidity
Optimization
Yes, 1,000 runs
EVM version
london
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,330,241
Creation transaction
0x96d88b8f59…dcc811ceb7

src/eligibility/HolderArtBlocksProjectEligibility.sol

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

import {HolderThresholdEligibility} from "./HolderThresholdEligibility.sol";
import {ITokensOfOwner} from "../interfaces/ITokensOfOwner.sol";

/// @notice Erfuellt, wenn der AKTUELLE HALTER mindestens `threshold` Token EINES bestimmten
/// Art-Blocks-Projekts besitzt. Ein Art-Blocks-Core enthaelt mehrere Projekte
/// (tokenId = projectId * 1_000_000 + Nummer), deshalb reicht balanceOf() nicht: der
/// V0-Core zaehlt Squiggle (0), Genesis (1) und Construction Token (2) zusammen.
/// Gas waechst mit der Zahl der Core-Token des Halters (tokensOfOwner ist unbounded).
contract HolderArtBlocksProjectEligibility is HolderThresholdEligibility {
    uint256 internal constant PROJECT_SCALE = 1_000_000;

    address public immutable core;
    uint256 public immutable projectId;

    constructor(address nft_, address core_, uint256 projectId_, uint256 threshold_)
        HolderThresholdEligibility(nft_, threshold_)
    {
        core = core_;
        projectId = projectId_;
    }

    function _metric(address holder) internal view override returns (uint256 count) {
        uint256[] memory ids = ITokensOfOwner(core).tokensOfOwner(holder);
        for (uint256 i = 0; i < ids.length; i++) {
            if (ids[i] / PROJECT_SCALE == projectId) count++;
        }
    }
}

src/eligibility/HolderThresholdEligibility.sol

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

import {IEligibilityCondition} from "../interfaces/IEligibilityCondition.sol";
import {IOwnerOf} from "../interfaces/IOwnerOf.sol";

/// @notice Schwester von ThresholdEligibility, prueft aber das Wallet des AKTUELLEN
/// Halters (ownerOf(tokenId) auf dem uebergebenen `nft`-Contract) statt der TBA. Der
/// `tba`-Parameter aus IEligibilityCondition wird bewusst ignoriert -- der Holder wird
/// pro Aufruf frisch aus `tokenId` aufgeloest, bleibt also live korrekt bei jedem
/// Besitzerwechsel.
abstract contract HolderThresholdEligibility is IEligibilityCondition {
    address public immutable nft;
    uint256 public immutable threshold;

    constructor(address nft_, uint256 threshold_) {
        nft = nft_;
        threshold = threshold_;
    }

    function _metric(address holder) internal view virtual returns (uint256);

    function isEligible(address, uint256 tokenId) external view returns (bool) {
        address holder = IOwnerOf(nft).ownerOf(tokenId);
        return _metric(holder) >= threshold;
    }
}

src/interfaces/IEligibilityCondition.sol

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

/// @notice Ja/Nein-Gegenstueck zu ITraitCondition: statt eine Tier-Stufe liefert
/// isEligible() nur "erfuellt der Halter diese eine Bedingung gerade oder nicht" --
/// Grundlage fuer TraitManagers freischaltbare Wahl-Traits (equipTrait).
interface IEligibilityCondition {
    function isEligible(address tba, uint256 tokenId) external view returns (bool);
}

src/interfaces/IOwnerOf.sol

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

/// @notice Minimales gemeinsames Interface fuer ownerOf(uint256) -- fuer JEDEN ERC-721,
/// nicht nur die eigene Kollektion (anders als INftTraitView, das zusaetzlich tbaOf()
/// verlangt und damit nur fuer den eigenen NFT-Contract passt). Gleiches Minimalprinzip
/// wie IBalanceOf.
interface IOwnerOf {
    function ownerOf(uint256 tokenId) external view returns (address);
}

src/interfaces/ITokensOfOwner.sol

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

/// @notice Enumerations-View der Art-Blocks-Core-Contracts (V0/V1): alle Token-IDs einer
/// Wallet als Array. Unbounded -- Gas waechst mit der Zahl der gehaltenen Token.
interface ITokensOfOwner {
    function tokensOfOwner(address owner) external view returns (uint256[] memory);
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 1000,
    "enabled": true
  },
  "evmVersion": "london",
  "remappings": [
    "solady/=lib/solady/src/",
    "forge-std/=lib/forge-std/src/",
    "ERC721A/=lib/ERC721A/contracts/",
    "solmate/=lib/solmate/src/",
    "utility-contracts/=lib/utility-contracts/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
    "seadrop/=lib/seadrop/",
    "ds-test/=/home/philipp/Schreibtisch/Projekte/Crypto/Auditors-EigeneKollektion/contract/contracts/lib/solmate/lib/ds-test/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.