Inside a Hats Module
Last updated
Last updated
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:
Provide the basic boiler plate required for a new Hats module contract.
Enable compatibility with , the easiest and cheapest way for users to deploy new instances of a given module.
Enable compatibility with the , which facilitates user discovery and integration into Hats front ends.
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:
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