Gitcoin Passport Eligibility is an eligibility module for Hats Protocol. The module defines eligibility for wearers based on their Gitcoin Passport Score, and whether it passes a certain threshold.
GitcoinPassportEligiblity inherits from the HatsEligibilityModule base contract from which it receives two major properties:
- It can be cheaply deployed via the minimal proxy factoryHatsModuleFactory
- It implements the interface IHatsEligibility
This eligibility module relies on the parameters and logic internal to the GitcoinPassportDecoder.sol contract to determine the eligibility of a target hat.
Specifically, this module reads the user's Gitcin Passport score, and yields a boolean value based on whether said score surpasses a specified threshold. This can be useful for if an onchain organization wants to restrict the eligibility of a target hat based on some minimum Gitcoin Passport score, as a proxy for unique personhood.
The eligibility of the target hat is dynamically determined by the status of the user's Gitcoin passport. For more information, see the official Gitcoin Passport documentation.
Note that every time a hat with this module signs anything, this module will be called. This means that the passport score is realtime, but a hat with this module will pay more to sign a transaction than a hat without this module.
A GitcoinPassportEligiblity 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 instance will be attached as an eligibility module, passed as itselfgitcoinPassportDecoder
: The smart contract instance of a Decoder that creates a bit map of stamp providers, which allows us to score Passports fully onchain.scoreCriterion
: The threshold used to consider if an address belongs to a human. If set to 0, then the module will use Gitcoin Passport's standard criterion for the threshold. If set to a value other than 0, then the module will use the assigned value for the threshold.
This repo uses Foundry for development and testing. To get started:
- Fork the project
- Install Foundry
- To install dependencies, run
forge install
- To compile the contracts, run
forge build
- To test, run
forge test
This repo also supports contracts compiled via IR. Since compiling all contracts via IR would slow down testing workflows, we only want to do this for our target contract(s), not anything in this test
or script
stack. We accomplish this by pre-compiled the target contract(s) and then loading the pre-compiled artifacts in the test suite.
First, we compile the target contract(s) via IR by runningFOUNDRY_PROFILE=optimized forge build
(ensuring that FOUNDRY_PROFILE is not in our .env file)
Next, ensure that tests are using the DeployOptimized
script, and run forge test
as normal.
See the wonderful Seaport repo for more details and options for this approach.
cd packages/foundry
forge script script/DeployImplementation.s.sol -f mainnet
forge script script/DeployInstance.s.sol -f mainnet
yarn deploy --network ${network_name}
yarn verify --network ${network_name}
Forked from the Hats Module Template.
MIT