ERC721Eligibility is an eligibility module for Hats Protocol. It requires wearers of a given Hat to own at least one token from a set of TokenIDs from a set ERC721 Contract in order to be eligible.
ERC721Eligibility inherits from the HatsEligibilityModule base contract, from which it receives two major properties:
- It can be cheaply deployed via the HatsModuleFactory minimal proxy factory, and
- It implements the IHatsEligibility interface
A ERC721Eligibility instance requires several parameters to be set at deployment, passed to the
HatsModuleFactory.createHatsModule()
function in various ways.
hatId
: The id of the hat to which this the instance will be attached as an eligibility module, passed as itselfTOKEN
: The address of the ERC721-compatible contract, abi-encoded (packed) and passed as_otherImmutableArgs
The following immutable values will also automatically be set within the instance at deployment:
IMPLEMENTATION
: The address of the ERC721Eligibility implementation contractHATS
: The address of the Hats Protocol contract
The following are abi-encoded (unpacked) and then passed to the HatsModuleFactory.createHatsModule()
function as
_initData
. These values can be changed after deployment by an admin of the hatId
hat.
eligibileTokens
: An array of uin256 tokenIds that will grant their owner eligibility
Mutable hats grant their admins the ability to modify eligible tokens.
If called by an admin, addEligibleTokens()
adds an array of eligible tokens to the existing array. The function does
NOT check for duplication, so care should be taken to ensure duplicate values are not passed. Duplicate values may
result in increased gas consumption and should be avoided.
If called by an admin removeEligibleToken()
removes a specific tokenID from the array eligibleTokens
. If the token
is not found in the array, it will revert.
The following parameters can be changed after deployment by an admin of the hatId
hat. Changes are only allowed while
the hatId
is mutable.
eligibleTokens
, by calling theaddEligibleTokens()
orremoveEligibleToken()
functions.
NOTE: duplicate values inputted into eligibleTokens will result in increased gas consumption and should be avoided.
This repo uses Foundry for development and testing. To get started:
- Fork the project
- Install Foundry
- To compile the contracts, run
forge build
- To test, run
forge test
. The tests require a private key and a valid mainnet rpc API KEY. A .env.example file is provided.