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
  • deployHatsSignerGateAndSafe
  • deployHatsSignerGate
  • deployMultiHatsSignerGateAndSafe
  • deployMultiHatsSignerGate
  1. For Developers
  2. Hats Signer Gate SDK

Creating New Instances

PreviousGetting StartedNextHats Signer Gate

Last updated 1 year ago

Create new Instances of Hats Signer Gate (HSG) and/or Multi Hats Signer Gate (MHSG), optionally together with a new Safe, using the .

deployHatsSignerGateAndSafe

Create a new HSG and a new Safe, all wired up together.

const createHsgResult = await hatsSignerGateClient.deployHatsSignerGateAndSafe({
    account,
    ownerHatId,
    signersHatId,
    minThreshold,
    targetThreshold,
    maxSigners,
});

Arguments:

{
    account: Account | Address;
    ownerHatId: bigint;
    signersHatId: bigint;
    minThreshold: bigint;
    targetThreshold: bigint;
    maxSigners: bigint;
}
  • account - Viem account (Address for JSON-RPC accounts or Account for other types).

  • ownerHatId - ID of the HSG's Owner Hat.

  • signersHatId - ID of the HSG's Signers Hat.

  • minThreshold - HSG's min threshold.

  • targetThreshold - HSG's target threshold.

  • maxSigners - HSG's max amount of signers.

Response:

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

  • transactionHash - transaction's hash.

  • newHsgInstance - In case of success, the address of the new HSG instance.

  • newSafeInstance - In case of success, the address of the new Safe instance.

deployHatsSignerGate

Deploy a new HSG and relate it to an existing Safe. In order to wire it up to the existing Safe, the owners of the Safe must enable it as a module and guard.

  • WARNING: HatsSignerGate must not be attached to a Safe with any other modules.

  • WARNING: HatsSignerGate must not be attached to its Safe if validSignerCount() >= _maxSigners

Before wiring up HatsSignerGate to its Safe, call canAttachHSGToSafe and make sure the result is true. Failure to do so may result in the Safe being locked forever.

const createHsgResult = await hatsSignerGateClient.deployHatsSignerGate({
    account,
    ownerHatId,
    signersHatId,
    safe,
    minThreshold,
    targetThreshold,
    maxSigners,
});

Arguments:

{
    account: Account | Address;
    ownerHatId: bigint;
    signersHatId: bigint;
    safe: Address;
    minThreshold: bigint;
    targetThreshold: bigint;
    maxSigners: bigint;
}
  • account - Viem account (Address for JSON-RPC accounts or Account for other types).

  • ownerHatId - ID of the HSG's Owner Hat.

  • signersHatId - ID of the HSG's Signers Hat.

  • safe - Existing Gnosis Safe that the signers will join.

  • minThreshold - HSG's min threshold.

  • targetThreshold - HSG's target threshold.

  • maxSigners - HSG's max amount of signers.

Response:

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

  • transactionHash - transaction's hash.

  • newHsgInstance - In case of success, the address of the new HSG instance.

deployMultiHatsSignerGateAndSafe

Create a new MHSG and a new Safe, all wired up together.

const createMhsgResult = await hatsSignerGateClient.deployMultiHatsSignerGateAndSafe({
    account,
    ownerHatId,
    signersHatIds,
    minThreshold,
    targetThreshold,
    maxSigners,
});

Arguments:

{
    account: Account | Address;
    ownerHatId: bigint;
    signersHatIds: bigint[];
    minThreshold: bigint;
    targetThreshold: bigint;
    maxSigners: bigint;
}
  • account - Viem account (Address for JSON-RPC accounts or Account for other types).

  • ownerHatId - ID of the MHSG's Owner Hat.

  • signersHatIds - IDs of the MHSG's Signers Hats.

  • minThreshold - MHSG's min threshold.

  • targetThreshold - MHSG's target threshold.

  • maxSigners - MHSG's max amount of signers.

Response:

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

  • transactionHash - transaction's hash.

  • newMultiHsgInstance - In case of success, the address of the new MHSG instance.

  • newSafeInstance - In case of success, the address of the new Safe instance.

deployMultiHatsSignerGate

Deploy a new MHSG and relate it to an existing Safe. In order to wire it up to the existing Safe, the owners of the Safe must enable it as a module and guard.

  • WARNING: MultiHatsSignerGate must not be attached to a Safe with any other modules.

  • WARNING: MultiHatsSignerGate must not be attached to its Safe if validSignerCount() >= _maxSigners

Before wiring up MultiHatsSignerGate to its Safe, call canAttachMHSGToSafe and make sure the result is true. Failure to do so may result in the Safe being locked forever.

const createMhsgResult = await hatsSignerGateClient.deployMultiHatsSignerGate({
    account,
    ownerHatId,
    signersHatIds,
    safe,
    minThreshold,
    targetThreshold,
    maxSigners,
});

Arguments:

{
    account: Account | Address;
    ownerHatId: bigint;
    signersHatIds: bigint[];
    safe: Address;
    minThreshold: bigint;
    targetThreshold: bigint;
    maxSigners: bigint;
}
  • account - Viem account (Address for JSON-RPC accounts or Account for other types).

  • ownerHatId - ID of the MHSG's Owner Hat.

  • signersHatIds - IDs of the MHSG's Signers Hats.

  • safe - Existing Gnosis Safe that the signers will join.

  • minThreshold - MHSG's min threshold.

  • targetThreshold - MHSG's target threshold.

  • maxSigners - MHSG's max amount of signers.

Response:

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

  • transactionHash - transaction's hash.

  • newMultiHsgInstance - In case of success, the address of the new MHSG instance.

👒
Hats Signer Gate Factory