> 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/for-developers/hats-modules/building-hats-modules/inside-a-hats-module/module-setup.md).

# Module Setup

Each module instance is initialized at creation time by the public [setUp](https://github.com/Hats-Protocol/hats-module/blob/5a69da357e70cc2e3727d6ec02097711439ec32b/src/HatsModule.sol#L65) function, which is triggered by the [`createHatsModule`](/for-developers/hats-modules/building-hats-modules/how-module-instances-are-deployed.md#create-new-instance)  function in [HatsModuleFactory](/for-developers/hats-modules/building-hats-modules/how-module-instances-are-deployed.md). This is where custom initial (mutable) variables and other configurations are set.

That custom logic can be implemented in the virtual [\_setUp](https://github.com/Hats-Protocol/hats-module/blob/5a69da357e70cc2e3727d6ec02097711439ec32b/src/HatsModule.sol#L70) function, which the module implementation should override.

```solidity
function _setUp(bytes calldata _initData) internal virtual { }
```

*Parameters:*

* `_initData` - abi-encoded initialization data.

{% hint style="info" %}
The `setUp` function is modified by OpenZeppelin's [initializable](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/utils/Initializable.sol), which prevents any future calls that could re-initialize the instance. `setUp` will be called even if `_setUp` is empty, ensuring that all instances are properly initialized.
{% endhint %}


---

# 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/for-developers/hats-modules/building-hats-modules/inside-a-hats-module/module-setup.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.
