> For the complete documentation index, see [llms.txt](https://docs.hatsprotocol.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hatsprotocol.xyz/using-hats/connecting-hats-w-permissions-and-authorities/connecting-hats-to-token-gates.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
