Skip to main content
Version: v2.0_alpha

IHats

Minimal interface for the Hats Protocol contract

Includes only the functions required for the HatsGatekeepers and associated tests

mintTopHat

function mintTopHat(address _target, string _details, string _imageURI) external returns (uint256)

Creates and mints a Hat that is its own admin, i.e. a "topHat"

A topHat has no eligibility and no toggle

Parameters

NameTypeDescription
_targetaddressThe address to which the newly created topHat is minted
_detailsstringA description of the Hat [optional]. Should not be larger than 7000 bytes (enforced in changeHatDetails)
_imageURIstringThe image uri for this top hat and the fallback for its downstream hats [optional]. Should not be larger than 7000 bytes (enforced in changeHatImageURI)

Return Values

NameTypeDescription
[0]uint256topHatId The id of the newly created topHat

createHat

function createHat(uint256 _admin, string _details, uint32 _maxSupply, address _eligibility, address _toggle, bool _mutable, string _imageURI) external returns (uint256)

Creates a new hat. The msg.sender must wear the _admin hat.

Initializes a new Hat struct, but does not mint any tokens.

Parameters

NameTypeDescription
_adminuint256The id of the Hat that will control who wears the newly created hat
_detailsstringA description of the Hat. Should not be larger than 7000 bytes (enforced in changeHatDetails)
_maxSupplyuint32The total instances of the Hat that can be worn at once
_eligibilityaddressThe address that can report on the Hat wearer's status
_toggleaddressThe address that can deactivate the Hat
_mutableboolWhether the hat's properties are changeable after creation
_imageURIstringThe image uri for this hat and the fallback for its downstream hats [optional]. Should not be larger than 7000 bytes (enforced in changeHatImageURI)

Return Values

NameTypeDescription
[0]uint256newHatId The id of the newly created Hat

mintHat

function mintHat(uint256 _hatId, address _wearer) external returns (bool success)

Mints an ERC1155-similar token of the Hat to an eligible recipient, who then "wears" the hat

The msg.sender must wear an admin Hat of _hatId, and the recipient must be eligible to wear _hatId

Parameters

NameTypeDescription
_hatIduint256The id of the Hat to mint
_weareraddressThe address to which the Hat is minted

Return Values

NameTypeDescription
successboolWhether the mint succeeded

isWearerOfHat

function isWearerOfHat(address account, uint256 hat) external view returns (bool)

Checks whether a given address wears a given Hat

Convenience function that wraps balanceOf

Parameters

NameTypeDescription
accountaddressThe address in question
hatuint256The id of the Hat that the _user might wear

Return Values

NameTypeDescription
[0]boolisWearer Whether the _user wears the Hat.