> For the complete documentation index, see [llms.txt](https://docs.forgenie.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.forgenie.com/specification/diamond-foundry/facetregistry.md).

# FacetRegistry

[Git Source](https://github.com/Forgenie/diamond-foundry/blob/e69a7af04e0636b77b9dd15df62c58172ec045da/src/registry/FacetRegistry.sol)

**Inherits:** IFacetRegistry, FacetRegistryBase

## Functions

### addFacet

Registers a new facet.

```solidity
function addFacet(address facet, bytes4[] memory selectors) external;
```

**Parameters**

| Name        | Type       | Description                      |
| ----------- | ---------- | -------------------------------- |
| `facet`     | `address`  | Address of the facet to add.     |
| `selectors` | `bytes4[]` | Function selectors of the facet. |

### removeFacet

Removes a facet from the registry.

```solidity
function removeFacet(address facet) external;
```

**Parameters**

| Name    | Type      | Description                     |
| ------- | --------- | ------------------------------- |
| `facet` | `address` | Address of the facet to remove. |

### deployFacet

Deploys a new facet and registers it.

```solidity
function deployFacet(
    bytes32 salt,
    bytes memory creationCode,
    bytes4[] memory selectors
)
    external
    override
    returns (address facet);
```

**Parameters**

| Name           | Type       | Description                                       |
| -------------- | ---------- | ------------------------------------------------- |
| `salt`         | `bytes32`  | Salt used to create the address of the new facet. |
| `creationCode` | `bytes`    | Creation code of the new facet.                   |
| `selectors`    | `bytes4[]` | Function selectors of the new facet.              |

**Returns**

| Name    | Type      | Description               |
| ------- | --------- | ------------------------- |
| `facet` | `address` | Address of the new facet. |

### computeFacetAddress

Computes the address of a facet deployed with the given salt and creation code.

```solidity
function computeFacetAddress(bytes32 salt, bytes memory creationCode) external view override returns (address facet);
```

**Parameters**

| Name           | Type      | Description                                       |
| -------------- | --------- | ------------------------------------------------- |
| `salt`         | `bytes32` | Salt used to create the address of the new facet. |
| `creationCode` | `bytes`   | Creation code of the new facet.                   |

### facetSelectors

Returns the selectors of a registered facet.

```solidity
function facetSelectors(address facet) external view returns (bytes4[] memory);
```

**Parameters**

| Name    | Type      | Description               |
| ------- | --------- | ------------------------- |
| `facet` | `address` | The address of the facet. |

**Returns**

| Name     | Type       | Description                           |
| -------- | ---------- | ------------------------------------- |
| `<none>` | `bytes4[]` | selectors The selectors of the facet. |

### facetAddresses

Returns the addresses of all registered facets.

```solidity
function facetAddresses() external view returns (address[] memory);
```

**Returns**

| Name     | Type        | Description                                    |
| -------- | ----------- | ---------------------------------------------- |
| `<none>` | `address[]` | facets The addresses of all registered facets. |


---

# 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:

```
GET https://docs.forgenie.com/specification/diamond-foundry/facetregistry.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.
