> For the complete documentation index, see [llms.txt](https://docs.firm.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.firm.org/firm-protocol-v1/supporting-components/firm-factory.md).

# Firm Factory

<figure><img src="/files/7G2oXmRVuUv7BF6ndyoG" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
Source code: <https://github.com/firm-org/firm-protocol/blob/master/src/factory/FirmFactory.sol>
{% endhint %}

## Overview

Firm Factory manages the creation and setup of new Firm organizations. The has been built to allow a one-transaction setup after which the organization can be fully functional in the desired initial state.

For v1, Firm Factory allows creating a new organization with one instance of all the modules that Firm protocol v1 offers.

Since at the core of every Firm there’s a Safe which represents the board of directors of the company, either Firm is installed into a pre-existing Safe (via a Safe multisig transaction) or Firm Factory creates one for the user by using Safe’s own factory.

## Entrypoints

### Create Firm

The `createFirm()` entry point allows users to create a new organization from scratch with a brand new Safe and one instance of all the modules that Firm protocol v1 offers. This entry point takes in two parameters, a `SafeConfig` and a `FirmConfig`:

* The `SafeConfig` is used to configure the Safe which acts as the board of directors of the organization. It contains details such as the owners of the Safe and the number of confirmations required for Safe transactions.
* The `FirmConfig` is used to configure the Firm-specific modules. It contains details such as the Budget, Roles, Captable and Voting configuration of the organization (Budget and Roles are compulsory, but Captable and Voting are optional based on the `withCaptableAndVoting` boolean).
  * The `budgetConfig` parameter contains an array of `AllowanceCreationInput` objects which specify the initial allowances to be created for the organization.
  * The `rolesConfig` parameter contains an array of `RoleCreationInput` objects which specify the roles to be created along with their associated grantees.
  * The `captableConfig` parameter contains the name of the captable and an array of `ClassCreationInput` and `ShareIssuanceInput` objects which specify the details of the Captable classes and share issuances.
  * Finally, the `votingConfig` parameter contains details about the voting settings for the organization.

### Setup Firm

The `setupFirm()` entry point allows existing Safes to install the modules associated with Firm protocol v1. This entry point takes in a `FirmConfig` as its configuration parameter, and is used to configure the Firm-specific modules.

In order to use it, existing Safe’s must perform a `delegatecall` to `setupFirm()`. It is the same function which gets internally used in a new Safe when `createFirm` is used

## Appendix: modules factory

`UpgradeableModuleProxyFactory` is used for keeping a versioning registry of different modules, deploying them, and initializing proxies.

The `register()` function allows the owner of the system to register an implementation of a module with a specific version number. This function can only be called by the owner of the contract, and it ensures that an implementation of the same version is not registered twice.

The `deployUpgradeableModule()` function allows users to deploy a proxy for a given module. This function has two overloads; one which takes in a `moduleId` and version number and the other which takes in the address of the implementation contract directly. When specifying the version number, there’s a special flag `type(uint256).max` which can be passed to request the latest available version the module.


---

# 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.firm.org/firm-protocol-v1/supporting-components/firm-factory.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.
