Hats Protocol Docs
hatsprotocol.xyzGithub
  • ๐Ÿ‘‹Welcome to Hats Protocol
  • ๐ŸงขGetting Started with Hats
  • โญQuick Start
  • Using The Hats App
    • ๐Ÿค Essentials For Hat Wearers
    • ๐ŸŽฉCreating My First Hat
    • ๐Ÿง™Admins: Creating, Issuing, and Revising Hats
    • ๐Ÿ‘ฅWhat Hats Do I Need?
    • ๐ŸŒณDrafting, Exporting, and Deploying Tree Changes
    • ๐Ÿ—๏ธSetting a Hat's Basic Properties
    • ๐ŸฅณAdding Wearers
    • ๐Ÿ”Connecting Hats w/ Permissions & Authorities
      • Types of Hat-Powered Authorities
      • Connecting Hats to Token Gates
        • Hats Protocol Contract Addresses
        • Finding a Hat's Token ID
      • Documenting Hat Powers & Responsibilities
    • ๐ŸŒŸRevocation & Eligibility: Requirements for Wearers
    • โšกDeactivating & Reactivating Hats
    • โœ…Making Hats Claimable
    • ๐Ÿ”—Linking Trees Together
    • โ›“๏ธHats Protocol Supported Chains
    • โ“Glossary & FAQ
  • Hats Integrations
    • ๐Ÿ”Permissions & Authorities
      • Coordinape
      • Council Voting Vault
      • Charmverse
      • Discord
        • Collab.Land --> Discord
        • Guild.xyz --> Discord
      • Farcaster Casting Rights
      • Fileverse
      • Google Workspace
      • Hats Account
      • Role-Based Compensation
      • Safe Multisig Signing Authority
      • Telegram
        • Collab.Land --> Telegram
        • Guild.xyz --> Telegram
      • Snapshot: Voting, Weight & Proposal Creation
      • Wonderverse
    • ๐ŸŒŸEligibility & Accountability Criteria
      • Agreement Eligibility
      • Allow-List Eligibility
      • CoLinks Eligibility
      • ERC20 Eligibility
      • ERC721 Eligibility
      • ERC1155 Eligibility
      • Hat-Wearing Eligibility
      • Hats Election Eligibility
      • JokeRace Eligibility
      • Pass-Through (Hat-Based) Eligibility
      • Staking Eligibility
      • Subscription or Membership Fee (Unlock Protocol)
      • Gitcoin Passport Eligibility
    • โšกActivation & Deactivation Criteria
      • Seasonal/ Time-Expiry Toggle
      • Pass-Through (Hat-Based) Toggle
    • ๐Ÿ‘ทHatter Modules
      • Multi Claims Hatter
      • DAOhaus Moloch v3 Membership & Share Allocation
  • For Developers
    • ๐Ÿ‘ทHats Protocol, for Developers
      • Hat Properties
      • Wearing a Hat
      • Hat Admins & Hatter Contracts
      • Hats Trees
      • Hat IDs
      • Linking Hats Trees
      • Eligibility Modules
      • Toggle Modules
      • Hat Mutability and Editing
      • Creating Hats
      • Minting Hats
      • Transfering Hats
      • Renouncing Hats
      • Batch Actions
      • Hat Image URIs
      • ERC1155 Compatibility
      • โ›“๏ธSupported Chains
    • ๐Ÿค–v1 Protocol Spec
      • Hats.sol
      • HatsEvents.sol
      • HatsErrors.sol
      • HatsIdUtilities.sol
      • Interfaces
        • IHats.sol
        • IHatsIdUtilities.sol
        • IHatsEligibility.sol
        • IHatsToggle.sol
    • ๐Ÿ–ฅ๏ธv1 SDK
      • Core
        • Getting Started
        • Onchain Reads
        • Onchain Writes
        • Multicall
        • Claiming Hats
        • Utilities
      • Subgraph
        • Getting Started
        • Fetching Hats
        • Fetching Wearers
        • Fetching Trees
        • Misc
        • Types
      • Hat Details
        • Getting Started
        • Usage
    • ๐Ÿ”ญv1 Subgraphs
    • ๐ŸงฉHats Modules
      • ๐Ÿ”ŒModules SDK
        • Getting Started
        • Get Available Modules
        • Create New Instance/s
        • Composing Modules
        • Interact With Instances
        • Utilities
        • Types
      • โš’๏ธBuilding Hats Modules
        • Inside a Hats Module
          • Immutable Arguments
          • Module Setup
          • Versioning
        • Creating New Modules
        • How Module Instances Are Deployed
        • Modules Registry
        • About Module Chains
    • ๐Ÿ”Hats Signer Gate v2
    • ๐Ÿ‘’Hats Signer Gate SDK
      • Getting Started
      • Creating New Instances
      • Hats Signer Gate
      • Multi Hats Signer Gate
      • HSG & MHSG Handlers
    • ๐Ÿ’ผHats Account SDK
      • 1 of N Hats Account
        • Getting Started
        • Creating New Instances
        • Executing From An Instance
        • Constants
        • Types
    • ๐ŸŒHats Security Audits
  • Legal
    • Terms
      • Terms of Service
      • Acceptable Use
      • Privacy Policy
      • Cookie Policy
      • Attribution
Powered by GitBook
On this page
  • Handlers
  • callInstanceWriteFunction
  • getInstanceParameters
  • Metadata
  • getMetadata
  • Types
  • HsgMetadata
  • Role
  • WriteFunction
  • WriteFunctionArg
  1. For Developers
  2. Hats Signer Gate SDK

HSG & MHSG Handlers

PreviousMulti Hats Signer GateNextHats Account SDK

Last updated 1 year ago

The following section describes a different way of interacting with HSG and MHSG instances, than documented in the previous sections. In particular, in the previous sections, for each operation on the and contracts, there's a matching function in the SDK.

In addition to these individual functions, the SDK also includes a single handler for calling the write operations of both HSG and MHSG instances. This enables HSG/MHSG interactions to be optionally handled in a similar way to , by working with the HSG and MHSG and the single write functions .

Handlers

callInstanceWriteFunction

Call a HSG/MHSG instance's write function.

const res = await hatsSignerGateClient.callInstanceWriteFunction({
    account,
    type,
    instance,
    func,
    args,
});

Arguments:

{
    account: Account | Address;
    type: HsgType;
    instance: Address;
    func: WriteFunction;
    args: unknown[];
}
  • account - Viem account (Address for JSON-RPC accounts or Account for other types).

  • type - 'HSG' or 'MHSG'.

  • instance - The MHSG/HSG instance address.

Response:

{
  status: "success" | "reverted";
  transactionHash: `0x${string}`;
}
  • status - "success" if transaction was successful, "reverted" if transaction reverted.

  • transactionHash - transaction's hash.

getInstanceParameters

Get a HSG or MHSG instance live parameters:

  • Safe address

  • Min threshold

  • Target threshold

  • Max signers

  • Owner Hat

const params = await hatsSignerGateClient.getInstanceParameters(instance);

Arguments:

instance: `0x${string}`

instance - Instance's address.

Response:

{
  label: string;
  value: unknown;
  solidityType: string;
  displayType: string;
}[]

An array of objects, each containing a parameter's information:

  • label - The parameter's name/description.

  • value - The parameter's value, as was returned from the instance contract.

  • solidityType - The parameter's Solidity type.

  • displayType- The parameter's display type. Its purpose is for UIs to be able to render an appropriate component for the parameter

Metadata

getMetadata

Get the metadata object of HSG or MHSG.

const metadata = await hatsSignerGateClient.getMetadata(type);

Arguments:

HsgType

"HSG" or "MHSG"

Response:

HsgMetadata

Types

HsgMetadata

Represents a HSG or MHSG metadata object.

{
  customRoles: Role[]; // HSG/MHSG custom roles
  writeFunctions: WriteFunction[]; // HSG/MHSG write functions
  abi: Abi; // HSG/MHSG ABI
}

Role

A custom HSG/MHSG role. Each role is associated with a hat and grants permissions to the hat's wearer(s) to call certain functions on the contract.

There are two special roles with a reserved ID:

  1. public role, associated with functions that are permitted to any caller.

  2. hatAdmins role, associated with functions that are permitted to the target hat's admins.

{
  id: string; // role's ID
  name: string; // role's name
  criteria: string; // The name of the contract function which can be used to retrieve the role's hat
  hatAdminsFallback?: boolean; // 'true' indicates that the role is granted to the target hat's admin(s) if/when the role's criteria function returns zero.
}

WriteFunction

The HSG/MHSG write functions. Each write function is associated with a role that grants permissions to the role's wearer(s) to call the function on the contract.

{
  roles: string[]; // IDs of the roles that have the authority to call the function
  functionName: string; // the name of the function in the contract
  label: string; // the name to be displayed to end users
  description: string; // a description of the function to be displayed to end users
  primary?: boolean; // 'true' indicates that this function is the primary function of the roles it is associated with. Front ends can use this information to display the function more prominently for each role
  args: WriteFunctionArg[]; // the arguments of the function
}

WriteFunctionArg

HSG/MHSG write function argument.

{
  name: string; // arg's name
  description: string; // arg's description
  type: string; // arg's solidity type, e.g. 'uint256'
  displayType: string; // a free-text field that tells front ends how to generate a proper UI component for the parameter
  optional?: boolean; // setting to 'true' indicates that this input is optional
}

func - The write function to call, provided as an object of type .

args - The arguments with which to call the function, as objects of type .

Both the HSG and MHSG metadata objects include their ABIs, all their together with the metadata of each function and the that are associated with them.

An object of type .

๐Ÿ‘’
WriteFunction
WriteFunctionArg
write functions
custom roles
HsgMetadata
HSG
MHSG
metadata objects
handler
Hats Modules interactions