Types

Hat Types

Hat

interface Hat {
  id: `0x${string}`; // Hat ID
  prettyId?: string; // pretty ID format
  status?: boolean; // 'true' if active, 'false' otherwise
  createdAt?: string | null; // timestamp of hat creation, null if not created yet
  details?: string; // Hat's details field
  maxSupply?: string; // max amount of wearers
  eligibility?: `0x${string}`; // eligibility address
  toggle?: `0x${string}`; // toggle address
  mutable?: boolean; // 'true' if mutable, 'false' otherwise
  imageUri?: string; // Hat's image URI
  levelAtLocalTree?: number; // Hat's level at its local tree (not including linked trees)
  currentSupply?: string; // current amount of hat wearers
  tree?: Tree; // Tree which contains the Hat
  wearers?: Wearer[]; // Hat's Wearers
  badStandings?: Wearer[]; // Hat's Wearers in bad standing
  admin?: Hat; // Hat's admin Hat
  subHats?: Hat[]; // Hat's children Hats
  linkRequestFromTree?: Tree[];  // Link requests from Trees
  linkedTrees?: Tree[]; // Trees linked to the Hat
  claimableBy?: ClaimsHatter[]; // Claims Hatters that the Hat is made claimable by
  claimableForBy?: ClaimsHatter[]; // Claims Hatters that the Hat is made claimable for by
  events?: HatsEvent[]; // Hat's events
}

HatPropsConfig

Query configuration for a Hat's properties.

The Hat's ID property is required and thus is not included in the config. The rest of the properties are optional.

  • To choose Scalar properties (non-object), include their key with a value of true.

  • To choose an Object property, include its key with a value compatible with the object's config type:

    • For single-object properties (e.g. tree), the config type includes the object's available properties without filters.

    • For multi-object properties (e.g. wearers), the config type includes both the object's available properties and optional filters (currently supports only the 'first' filter).

interface HatPropsConfig {
  prettyId?: boolean;
  status?: boolean;
  createdAt?: boolean;
  details?: boolean;
  maxSupply?: boolean;
  eligibility?: boolean;
  toggle?: boolean;
  mutable?: boolean;
  imageUri?: boolean;
  levelAtLocalTree?: boolean;
  currentSupply?: boolean;
  tree?: TreePropsConfig;
  wearers?: WearersConfig;
  badStandings?: WearersConfig;
  admin?: HatPropsConfig;
  subHats?: HatsConfig;
  linkRequestFromTree?: TreesConfig;
  linkedTrees?: TreesConfig;
  claimableBy?: ClaimsHattersConfig;
  claimableForBy?: ClaimsHattersConfig;
  events?: HatsEventsConfig;
}

HatsConfig

Query configuration for a multi Hats property, i.e. a property that returns multiple Hats.

interface HatsConfig {
  props: HatPropsConfig; // properties to include in each hat
  filters?: { // filters to apply on the property query
    first?: number; // fetch only the 'first' amount of hats
  };
}

Wearer Types

Wearer

interface Wearer {
  id: `0x${string}`; // Wearer's address
  currentHats?: Hat[]; // Wearer's current Hats
  mintEvent?: HatsEvent[]; // Hat mint events for the Wearer
  burnEvent?: HatsEvent[]; // Hat burn events for the Wearer
}

WearerPropsConfig

Query configuration for a Wearer's properties.

The Wearer's ID property is required and thus is not included in the config. The rest of the properties are optional.

  • To choose Scalar properties (non-object), include their key with a value of true.

  • To choose an Object property, include its key with a value compatible with the object's config type:

    • For single-object properties (e.g. the tree property of a Hat), the config type includes the object's available properties.

    • For multi-object properties (e.g. currentHats), the config type includes both the object's available properties and optional filters (currently supports only the 'first' filter).

interface WearerPropsConfig {
 currentHats?: HatsConfig;
  mintEvent?: HatsEventsConfig;
  burnEvent?: HatsEventsConfig;
}

WearersConfig

Query configuration for a multi Wearers property, i.e. a property that returns multiple Wearers.

interface WearerPropsConfig {
  props: WearerPropsConfig; // properties to include in each wearer
  filters?: { // filters to apply on the property query
    first?: number; // fetch only the 'first' amount of wearers
  };
}

Tree Types

Tree

interface Tree {
  id: `0x${string}`; // Tree ID (Tree's top-hat domain - first 4 bytes of the top-hat ID)
  hats?: Hat[]; // Tree's Hats
  childOfTree?: Tree; // if linked, the Tree which this Tree is linked to
  parentOfTrees?: Tree[]; // Trees which are linked to this Tree
  linkedToHat?: Hat; // if linked, the Hat which this Tree is linked to
  linkRequestFromTree?: Tree[]; // Trees with a linkage request to this Tree
  requestedLinkToTree?: Tree; // Tree which this Tree has a linkage request to
  requestedLinkToHat?: Hat; // Hat which this Tree has a linkage request to
  events?: HatsEvent[]; // Tree's events
}

TreePropsConfig

Query configuration for a Tree's properties.

The Tree's ID property is required and thus is not included in the config. The rest of the properties are optional.

  • To choose Scalar properties (non-object), include their key with a value of true.

  • To choose an Object property, include its key with a value compatible with the object's config type:

    • For single-object properties (e.g. childOfTree), the config type includes the object's available properties.

    • For multi-object properties (e.g. hats), the config type includes both the object's available properties and optional filters (currently supports only the 'first' filter).

interface TreePropsConfig {
  hats?: HatsConfig;
  childOfTree?: TreePropsConfig;
  parentOfTrees?: TreesConfig;
  linkedToHat?: HatPropsConfig;
  linkRequestFromTree?: TreesConfig;
  requestedLinkToTree?: TreePropsConfig;
  requestedLinkToHat?: HatPropsConfig;
  events?: HatsEventsConfig;
}

TreesConfig

Query configuration for a multi Trees property, i.e. a property that returns multiple Trees.

interface TreePropsConfig {
  props: TreePropsConfig; // properties to include in each tree
  filters?: { // filters to apply on the property query
    first?: number; // fetch only the 'first' amount of trees
  };
}

Event Types

HatsEventBase

Base type, which contains the common properties of Hats Events, and which is then extended by each specific event.

interface HatsEventBase {
  id: string; // Event's ID
  timestamp?: bigint; // Event's timestamp
  blockNumber?: number; // Event's block number
  transactionID?: string; // transaction ID which the Event was emitted in
  hat?: Hat; // Hat that relates to the Event
  tree?: Tree; // Tree that relates to the Event
}

HatsEventPropsConfig

Query configuration for the basic properties of a Hats Event.

The HatsEvent's ID property is required and thus is not included in the config. The rest of the properties are optional.

To choose Scalar properties (non-object), include their key with a value of true. To choose an Object property, include its key with a value compatible with the object's config.

interface HatsEventConfig {
  timestamp?: boolean;
  blockNumber?: boolean;
  transactionID?: boolean;
  hat?: HatPropsConfig;
  tree?: HatPropsConfig;
}

Following are the various Hats Events, emitted from Hats-Protocol in response to various actions.

Fetched events will include the event's base properties, as well as the additional properties that are included in each specific event, according to its type.

HatCreatedEvent

interface HatCreatedEvent extends HatsEventBase {
  __typename: "HatCreatedEvent";
  hatDetails: string;
  hatMaxSupply: `0x${string}`;
  hatEligibility: `0x${string}`;
  hatToggle: string;
  hatMutable: boolean;
  hatImageUri: string;
}

HatMintedEvent

interface HatMintedEvent extends HatsEventBase {
  __typename: "HatMintedEvent";
  wearer: {
    id: `0x${string}`;
  };
  operator: `0x${string}`;
}

HatBurnedEvent

interface HatBurnedEvent extends HatsEventBase {
  __typename: "HatBurnedEvent";
  wearer: {
    id: `0x${string}`;
  };
  operator: `0x${string}`;
}

HatMutabilityChangedEvent

interface HatMutabilityChangedEvent extends HatsEventBase {
  __typename: "HatMutabilityChangedEvent";
}

HatStatusChangedEvent

interface HatStatusChangedEvent extends HatsEventBase {
  __typename: "HatStatusChangedEvent";
  hatNewStatus: boolean;
}

HatDetailsChangedEvent

interface HatDetailsChangedEvent extends HatsEventBase {
  __typename: "HatDetailsChangedEvent";
  hatNewDetails: string;
}

HatEligibilityChangedEvent

interface HatEligibilityChangedEvent extends HatsEventBase {
  __typename: "HatEligibilityChangedEvent";
  hatNewEligibility: `0x${string}`;
}

HatToggleChangedEvent

interface HatToggleChangedEvent extends HatsEventBase {
  __typename: "HatToggleChangedEvent";
  hatNewToggle: `0x${string}`;
}

HatMaxSupplyChangedEvent

interface HatMaxSupplyChangedEvent extends HatsEventBase {
  __typename: "HatMaxSupplyChangedEvent";
  hatNewMaxSupply: string;
}

HatImageURIChangedEvent

interface HatImageURIChangedEvent extends HatsEventBase {
  __typename: "HatImageURIChangedEvent";
  hatNewImageURI: string;
}

TopHatLinkRequestedEvent

interface TopHatLinkRequestedEvent extends HatsEventBase {
  __typename: "TopHatLinkRequestedEvent";
  newAdmin: `0x${string}`;
}

TopHatLinkedEvent

interface TopHatLinkedEvent extends HatsEventBase {
  __typename: "TopHatLinkedEvent";
  newAdmin: `0x${string}`;
}

WearerStandingChangedEvent

interface WearerStandingChangedEvent extends HatsEventBase {
  __typename: "WearerStandingChangedEvent";
  wearer: {
    id: `0x${string}`;
  };
  wearerStanding: boolean;
}

HatsEvent

type HatsEvent =
  | HatCreatedEvent
  | HatMintedEvent
  | HatBurnedEvent
  | HatMutabilityChangedEvent
  | HatStatusChangedEvent
  | HatDetailsChangedEvent
  | HatEligibilityChangedEvent
  | HatToggleChangedEvent
  | HatMaxSupplyChangedEvent
  | HatImageURIChangedEvent
  | TopHatLinkRequestedEvent
  | TopHatLinkedEvent
  | WearerStandingChangedEvent;

Claims Hatter Types

ClaimsHatter

interface ClaimsHatter {
  id: string; // ClaimsHatter's ID
  claimableHats?: Hat[]; // Hats made claimable by this Hatter
  claimableForHats?: Hat[]; // Hats made 'claimable for' by this Hatter 
}

ClaimsHatterPropsConfig

Query configuration for a ClaimsHatter's properties.

The ClaimsHatter's ID property is required and thus is not included in the config. The rest of the properties are optional.

interface ClaimsHatterPropsConfig {
  claimableHats?: HatsConfig;
  claimableForHats?: HatsConfig;
}

ClaimsHattersConfig

Query configuration for a multi ClaimsHatters property, e.g. a property that returns multiple Claims Hatters.

interface ClaimsHattersConfig {
  props: ClaimsHatterPropsConfig; // properties to include in each claims hatter
  filters?: { // filters to apply on the property query
    first?: number; // fetch only the 'first' amount of hatters
  };
}

More

EndpointsConfig

Subgraph endpoints configuration, optionally provided at the client's creation.

interface EndpointsConfig {
  [chainId: number]: { endpoint: string };
}

Last updated