A utility contract for creating a quick and simple configuration for a shared Farcaster account. In a single transaction, this contract will...
- Deploy a simple Hats tree according to a predetermined template
- Deploy a HatsFarcasterDelegator instance
- Prepare the delegator instance to receive FID of the Farcaster account to be shared
Use this contract by calling deployTreeAndPrepareHatsFarcasterDelegator
with the following parameters:
superAdmin
: The address to mint the top hat toadmins
: The addresses to mint the admin hats to (at least 1)casters
: The addresses to mint the caster hats to (at least 1)factory
: The HatsModuleFactory address, typically the most recent deployment of HatsModuleFactorydelegatorImplementation
: The HatsFarcasterDelegator implementation address, typically the most recent version of HatsFarcasterDelegatorsaltNonce
: A salt nonce to use for the HatsFarcasterDelegator deploymentfid
: The Farcaster FID to be shared
This contract defines a simple Hats tree with the below structure of four hats.
- Hat x — The top hat, worn by the super admin (typically a DAO, multisig, etc)
- Hat x.1 — The autonomous admin hat, unworn to start and meant as a placeholder for future flexibility
- Hat x.1.1 — The admin hat, worn by the specified admins
- Hat x.1.1.1 — The caster hat, worn by the specified casters
The properties of these hats — collectively known as the treeTemplate
— are defined on contract deployment as a constructor argument. The template cannot be changed after deployment.
The treeTemplate
is an array of HatTemplate
s, each holding the properties of the hat at that index in the array (see the numbered list above). The configurable properties of each hat are as follows:
struct HatTemplate {
address eligibility; // The address of the eligibility module for the hat
uint32 maxSupply; // The maximum number of wearers of the hat
address toggle; // The address of the toggle module for the hat
bool mutable_; // Whether the hat is mutable
string details; // The details of the hat, typically as an IPFS CID
string imageURI; // The URI of the hat's image, typically as an IPFS CID
}
Note When using this contract to deploy a new tree, the
eligibility
module for the caster hat will always be set as the first address in theadmins
array, overriding the template if necessary.
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