# Connecting Hats to Token Gates

Hats are ERC1155 tokens, so they can be plugged into token gates to grant the wearers of that hat specific authorities, as long as 1) the wearer’s address is still eligible to wear the hat, and 2) the hat is still active.

You can think of it this way: token gates have two parts, the token and the gate. Hats provides the token, which gets plugged into the necessary gates, to give the hat wearer access to the proper authorities.

<figure><img src="/files/jZsF2F0AAvlAWyMurIPd" alt=""><figcaption></figcaption></figure>

To connect a hat to a token-gate, locate the token-gating permissions for the platform or application you wish to use. In many cases, the process requires that you create a specific role in the platform that has special permissions associated with that role, and then add a specific requirement necessary for a user to hold that role (e.g., holding a particular Hats token). *See the* [*Hat-Gated Authorities*](/hats-integrations/permissions-and-authorities.md) *section of these docs for guides for connecting hats to specific authorities and platforms.*

### Example - Guild.xyz

At Guild.xyz, for example, which provides token-gating for Discord, Telegram, Github, and Google Workspace, you will create a role within your Guild, provide that Guild role with specific "rewards" (aka permissions), and then add a requirement that an address must have possession of a particular NFT to hold that Guild role.

<div><img src="https://hackmd.io/_uploads/BkTwIJXBn.png" alt="" width="375"> <img src="https://hackmd.io/_uploads/By7qBkXHn.png" alt="" width="375"></div>

To connect a hat to a token-gate, you will need to add an NFT (ERC1155) requirement. Then, you'll need to enter two details:

1. [The Hats Protocol contract address](/using-hats/connecting-hats-w-permissions-and-authorities/connecting-hats-to-token-gates/hats-protocol-contract-addresses.md), and
2. [The Hats token ID](/using-hats/connecting-hats-w-permissions-and-authorities/connecting-hats-to-token-gates/finding-a-hats-token-id.md) (sometimes called a Custom ID) for the appropriate hat. This token ID will be the same for all wearers of a single hat.

See below for these details.

{% content-ref url="/pages/uebSSCvVzZMz6wPYjMTV" %}
[Hats Protocol Contract Addresses](/using-hats/connecting-hats-w-permissions-and-authorities/connecting-hats-to-token-gates/hats-protocol-contract-addresses.md)
{% endcontent-ref %}

{% content-ref url="/pages/1zy1c6snF1ytgP8qxjNJ" %}
[Finding a Hat's Token ID](/using-hats/connecting-hats-w-permissions-and-authorities/connecting-hats-to-token-gates/finding-a-hats-token-id.md)
{% endcontent-ref %}

Finally, associate your Hats tree with the Guild/s:

* Select "Edit Tree"
* Locate and select the tree's top-hat
* Select the "Hat Basics" section
* Set the Guild name/s in the "Guilds" field

<figure><img src="/files/P4lb16twchoLo3QvBOOr" alt=""><figcaption></figcaption></figure>

Now, Guild authorities will be automatically displayed on the relevant hats.

<figure><img src="/files/RCy0tgaomX3VHb0u58Fk" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hatsprotocol.xyz/using-hats/connecting-hats-w-permissions-and-authorities/connecting-hats-to-token-gates.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
