Onchain Writes
mintTopHat
Create a new tophat (new tree).
const mintTopHatResult = await hatsClient.mintTopHat({
account,
target,
details,
imageURI,
});Arguments:
{
account: Account | Address;
target: Address;
details: string;
imageURI?: string;
}account- Viem account (Address for JSON-RPC accounts or Account for other types).target- tophat's wearer address.details- tophat's details field.imageURI- optional tophat's image URI.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.hatId- ID of the created tophat.
createHat
Create a hat.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).admin- hat's admin ID.details- hat's details field.maxSupply- hat's maximum amount of possible wearers.eligibility- hat's eligibility address (zero address is not valid).toggle- hat's toggle address (zero address is not valid).mutable- true if the hat should be mutable, false otherwise.imageURI- optional hat's image URI.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.hatId- ID of the created hat.
batchCreateHats
Create multiple hats.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).admins- hats admin IDs.details- hats details fields.maxSupplies- hats maximum amounts of possible wearers.eligibilityModules- hats eligibility addresses (zero address is not valid).toggleModules- hats toggle addresses (zero address is not valid).mutables- true if the hat should be mutable, false otherwise.imageURIs- optional hats image URIs.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.hatIds- IDs of the created hats.
mintHat
Mint a hat.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).hatId- hat's ID.wearer- address of the new wearer.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.
batchMintHats
Mint multiple hats.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).hatIds- hats IDs.wearers- addresses of the new wearers.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.
setHatStatus
Set a hat's status to active/inactive.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).hatId- hat's ID.newStatus- hat's new status:truefor active,falsefor inactive.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.
checkHatStatus
Check a hat's status by calling its toggle module, and updating the status as needed.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).hatId- hat's ID.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.toggled- true if the hat's status was changed (toggled), false otherwise.newStatus- if hat's status was changed (toggled), then contains its new status.
setHatWearerStatus
Set a hat's wearer status.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).hatId- hat's ID.wearer- wearer address.eligible- wearer's eligibility.truefor eligible,falseotherwise.standing- wearer's standing.truefor good,falsefor bad.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.
checkHatWearerStatus
Check a hat's wearer status by calling the hat's eligibility module. If the wearer is non eligible and/or in bad standing, then its hat is burned.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).hatId- hat's ID.wearer- wearer address.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- Transaction's hash.wearerStandingUpdated-trueif the wearer's standing was changed (toggled),falseotherwise.hatBurned-trueif the wearer's hat was burned in the transaction,falseotherwise.newWearerStanding- if the wearer standing was changed, then contains the new standing status.
renounceHat
Renounce a hat. This action burns the hat for the renouncing wearer (the caller).
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).hatId- hat's ID.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.
transferHat
Transfer a hat from one wearer to another.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).hatId- hat's ID.from- current wearer address.to- new wearer address.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.
makeHatImmutable
Make a hat immutable.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).hatId- hat's ID.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.
changeHatDetails
Change a hat's details.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).hatId- hat's ID.newDetails- hat's new details.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.
changeHatEligibility
Change a hat's eligibility.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).hatId- hat's ID.newEligibility- hat's new eligibility.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.
changeHatToggle
Change a hat's toggle.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).hatId- hat's ID.newToggle- hat's new toggle.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.
changeHatImageURI
Change a hat's image URI.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).hatId- hat's ID.newImageURI- hat's new image URI.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.
changeHatMaxSupply
Change a hat's maximum supply.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).hatId- hat's ID.newMaxSupply- hat's new maximum supply.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.
requestLinkTopHatToTree
Request a link from a tophat to a new admin hat.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).topHatDomain- the tree domain of the requesting tree. The tree domain is the first four bytes of the tophat ID.requestedAdminHat- ID of the requested new admin hat.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.
approveLinkTopHatToTree
Approve a tophat's linkage request.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).topHatDomain- the tree domain of the requesting tree. The tree domain is the first four bytes of the tophat ID.newAdminHat- ID of the new admin hat.newEligibility- optional new eligibility for the linked tophat.newToggle- optional new toggle for the linked tophat.newDetails- optional new details for the linked tophat.newImageURI- optional new image URI for the linked tophat.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.
unlinkTopHatFromTree
Unlink a tree.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).topHatDomain- the tree domain. The tree domain is the first four bytes of the tophat ID.wearer- The current wearer of the tophat that is about to be unlinked.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.
relinkTopHatWithinTree
Relink a tree within the same global tree that it is already part of.
Arguments:
account- Viem account (Address for JSON-RPC accounts or Account for other types).topHatDomain- the tree domain of the relinked tree. The tree domain is the first four bytes of the tophat ID.newAdminHat- ID of the new admin hat.newEligibility- optional new eligibility for the linked tophat.newToggle- optional new toggle for the linked tophat.newDetails- optional new details for the linked tophat.newImageURI- optional new image URI for the linked tophat.
Response:
status- "success" if transaction was successful, "reverted" if transaction reverted.transactionHash- transaction's hash.
Last updated