Token Gating


The Token Gating smart contract is designed to restrict access to specific functionalities or privileges based on the ownership of certain NFTs within specified collections. By implementing token gating, it allows for controlled minting and transferring of NFTs, where only the owners of designated tokens can participate in these activities.


Sepolia Testnet

Name of the ContractContract address
Token Gating0xdF878e12b6FD9752eC0c887B7aDC9a04DA3BeBBF

Architecture Overview

The Token Gating contract is built on top of the OpenZeppelin library and Manifold's libraries. It leverages the following key components:

  1. Admin Component:
    • Responsible for managing gating parameters at both the collection and token levels.
    • Interacts with the Token Gating Contract to set up, update, or remove gating limitations.
    • Handles administrative functions such as approving signatures and managing collection data.
    • Can cancel token or collection gating settings.
  2. User Component:
    • Users who own NFTs and want to access gated privileges.
    • Interacts with the Token Gating Contract to acquire gating information, mint new NFTs, or transfer existing NFTs.
    • Requires ownership verification and may need admin-approved signatures for certain actions.
  3. Token Gating Contract Component:
    • Smart contract responsible for managing and enforcing gating limitations.
    • Stores gating parameters such as per-token limits and per-collection limits.
    • Validates gating data and ensures that users meet gating criteria before minting or transferring NFTs.
    • Emits events for gated minting, transfers, and other significant actions.
    • Handles verification of admin signatures to prevent unauthorized actions.
  4. NFT Collection Component:
    • ERC721 or ERC1155 NFT collections gated by the Token Gating Contract.
    • Interacts with the Token Gating Contract to check and update gating limitations.
    • Supports interfaces for transferring and minting NFTs based on gating rules.
    • Can be an existing collection with specific tokens or a new collection created for gated access.
  5. Gated Wallet Component:
    • Wallet addresses of users who own gated NFTs.
    • Receives newly minted NFTs or transfers existing NFTs based on gating criteria.
    • Must be verified for ownership and meet the gating requirements set by the admin.
  6. Signature Component:
    • Admin-generated signatures used for authorizing actions within the Token Gating Contract.
    • Ensures that only authorized actions are performed by validating signatures against admin-approved criteria.
    • Prevents misuse or duplication of signatures through tracking of used signatures.

Smart Contract Interaction

Admin Related Methods

function setTokenGating(
    address collectionAddress,
    uint256 tokenId,
    uint256 limit
) public nonReentrant;

The setTokenGating function is used to enforce restrictions on individual tokens within a collection, ensuring that only a certain number of NFTs can be minted or transferred.

function setCollectionGating(
    address collectionAddress,
    uint256 perTokenLimit,
    uint256 perCollectionLimit
) public nonReentrant;

The setCollectionGating function is used to enforce restrictions across the entire collection, setting both per-token and overall collection limits.

function cancelTokenGating(
    address collectionAddress,
    uint256 tokenId,
    uint256 limit
) public nonReentrant;

function cancelCollectionGating(
    address collectionAddress,
    uint256 perTokenLimit,
    uint256 perCollectionLimit
) public nonReentrant;

This function is used to remove previously set restrictions on individual tokens or the collections , lifting the gating limitations.

User Related Methods

function acquireGating(
    address collectionAddress,
    uint256 tokenId,
    address walletAddress
) public nonReentrant returns (bool);

The acquireGating function allows users to check if they meet the gating criteria and to update the gating data accordingly.

Getter Methods

function getTokenLimitation(
    address gatedCollection,
    uint256 gatedTokenId
) public view returns (uint256);

The purpose of getTokenLimitation function is to to retrieve the current gating limitations for a specific token within a collection.

function getCollectionLimitation(
    address gatedCollection
) public view returns (uint256 perCollectionLimit, uint256 perTokenLimit);

The getCollectionLimitation function retrieves the current gating limitations for an entire collection.


This contract can be deployed using the above address. If you have any questions or require deployment assistance, please contact us at [email protected].