Hats Protocol Docs
hatsprotocol.xyzGithub
  • πŸ‘‹Welcome to Hats Protocol
  • 🧒Getting Started with Hats
  • ⭐Quick Start
  • Using The Hats App
    • 🀠Essentials For Hat Wearers
    • 🎩Creating My First Hat
    • πŸ§™Admins: Creating, Issuing, and Revising Hats
    • πŸ‘₯What Hats Do I Need?
    • 🌳Drafting, Exporting, and Deploying Tree Changes
    • πŸ—οΈSetting a Hat's Basic Properties
    • πŸ₯³Adding Wearers
    • πŸ”Connecting Hats w/ Permissions & Authorities
      • Types of Hat-Powered Authorities
      • Connecting Hats to Token Gates
        • Hats Protocol Contract Addresses
        • Finding a Hat's Token ID
      • Documenting Hat Powers & Responsibilities
    • 🌟Revocation & Eligibility: Requirements for Wearers
    • ⚑Deactivating & Reactivating Hats
    • βœ…Making Hats Claimable
    • πŸ”—Linking Trees Together
    • ⛓️Hats Protocol Supported Chains
    • ❓Glossary & FAQ
  • Hats Integrations
    • πŸ”Permissions & Authorities
      • Coordinape
      • Council Voting Vault
      • Charmverse
      • Discord
        • Collab.Land --> Discord
        • Guild.xyz --> Discord
      • Farcaster Casting Rights
      • Fileverse
      • Google Workspace
      • Hats Account
      • Role-Based Compensation
      • Safe Multisig Signing Authority
      • Telegram
        • Collab.Land --> Telegram
        • Guild.xyz --> Telegram
      • Snapshot: Voting, Weight & Proposal Creation
      • Wonderverse
    • 🌟Eligibility & Accountability Criteria
      • Agreement Eligibility
      • Allow-List Eligibility
      • CoLinks Eligibility
      • ERC20 Eligibility
      • ERC721 Eligibility
      • ERC1155 Eligibility
      • Hat-Wearing Eligibility
      • Hats Election Eligibility
      • JokeRace Eligibility
      • Pass-Through (Hat-Based) Eligibility
      • Staking Eligibility
      • Subscription or Membership Fee (Unlock Protocol)
      • Gitcoin Passport Eligibility
    • ⚑Activation & Deactivation Criteria
      • Seasonal/ Time-Expiry Toggle
      • Pass-Through (Hat-Based) Toggle
    • πŸ‘·Hatter Modules
      • Multi Claims Hatter
      • DAOhaus Moloch v3 Membership & Share Allocation
  • For Developers
    • πŸ‘·Hats Protocol, for Developers
      • Hat Properties
      • Wearing a Hat
      • Hat Admins & Hatter Contracts
      • Hats Trees
      • Hat IDs
      • Linking Hats Trees
      • Eligibility Modules
      • Toggle Modules
      • Hat Mutability and Editing
      • Creating Hats
      • Minting Hats
      • Transfering Hats
      • Renouncing Hats
      • Batch Actions
      • Hat Image URIs
      • ERC1155 Compatibility
      • ⛓️Supported Chains
    • πŸ€–v1 Protocol Spec
      • Hats.sol
      • HatsEvents.sol
      • HatsErrors.sol
      • HatsIdUtilities.sol
      • Interfaces
        • IHats.sol
        • IHatsIdUtilities.sol
        • IHatsEligibility.sol
        • IHatsToggle.sol
    • πŸ–₯️v1 SDK
      • Core
        • Getting Started
        • Onchain Reads
        • Onchain Writes
        • Multicall
        • Claiming Hats
        • Utilities
      • Subgraph
        • Getting Started
        • Fetching Hats
        • Fetching Wearers
        • Fetching Trees
        • Misc
        • Types
      • Hat Details
        • Getting Started
        • Usage
    • πŸ”­v1 Subgraphs
    • 🧩Hats Modules
      • πŸ”ŒModules SDK
        • Getting Started
        • Get Available Modules
        • Create New Instance/s
        • Composing Modules
        • Interact With Instances
        • Utilities
        • Types
      • βš’οΈBuilding Hats Modules
        • Inside a Hats Module
          • Immutable Arguments
          • Module Setup
          • Versioning
        • Creating New Modules
        • How Module Instances Are Deployed
        • Modules Registry
        • About Module Chains
    • πŸ”Hats Signer Gate v2
    • πŸ‘’Hats Signer Gate SDK
      • Getting Started
      • Creating New Instances
      • Hats Signer Gate
      • Multi Hats Signer Gate
      • HSG & MHSG Handlers
    • πŸ’ΌHats Account SDK
      • 1 of N Hats Account
        • Getting Started
        • Creating New Instances
        • Executing From An Instance
        • Constants
        • Types
    • 🌐Hats Security Audits
  • Legal
    • Terms
      • Terms of Service
      • Acceptable Use
      • Privacy Policy
      • Cookie Policy
      • Attribution
Powered by GitBook
On this page
  • HatsModule.sol
  • Extensions
  1. For Developers
  2. Hats Modules
  3. Building Hats Modules

Inside a Hats Module

PreviousBuilding Hats ModulesNextImmutable Arguments

Last updated 1 year ago

Typically, Hats Modules inherit from the contract. This is an abstract contract that provides a generic structure that modules can extend to support any specific use case.

It serves several key functions:

  1. Provide the basic boiler plate required for a new Hats module contract.

  2. Enable compatibility with , the easiest and cheapest way for users to deploy new instances of a given module.

  3. Enable compatibility with the , which facilitates user discovery and integration into Hats front ends.

Inheriting from HatsModule.sol is necessary to be deployable via HatsModuleFactory, to be listed in the Module registry, and to appear natively in the applications using the registry.

However, it is not required for compatibility with Hats Protocol more generally. See the docs for and modules for those requirements.

The remainder of this documentation assumes inheritance of HatsModule.

HatsModule.sol

HatsModule.sol's primary function is to enable a module to be configured and deployed via . Often, each new hat to which a module is attached involves a new instance of that module, so its important for deployment to be gas-efficient. Additionally, each module is likely to be called many times over its life, so its also important for runtime execution to be gas-efficient.

For these reasons, HatsModule.sol is structured as a minimal proxy (clone) contract β€” similar to the standard β€”Β that also supports immutable arguments. It implements the gas-efficient library.

See the following pages for more detail about how HatsModule.sol operates:

Extensions

There are a couple stock extensions to HatsModule.sol that are useful starting points for common types of modules:

HatsEligibilityModule.sol: implements

HatsToggleModule.sol: implements

🧩
βš’οΈ
HatsModule.sol
HatsModuleFactory.sol
module registry
Eligibility
Toggle
HatsModuleFactory
EIP-1167
LibClone.sol
Immutable Arguments
Module Setup
Versioning
IHatsEligibility.sol
IHatsToggle.sol