> For the complete documentation index, see [llms.txt](https://docs.t-rex.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.t-rex.network/reference/token-suite/identityregistrystorage.md).

# IdentityRegistryStorage

`IdentityRegistryStorage` holds the registrations of an asset: the addresses its Registry Agents bound to an ONCHAINID for this asset. It is a separate contract so that several assets of one Issuer can share one set of registrations. When an address has no registration, the storage answers with the global link recorded by the `IdentityFactory`.

### At a glance

|                 |                                                                                                                        |
| --------------- | ---------------------------------------------------------------------------------------------------------------------- |
| **Source**      | `contracts/registry/implementation/IdentityRegistryStorage.sol`, on the standard base `ERC3643IdentityRegistryStorage` |
| **Interfaces**  | `IIdentityRegistryStorage`, `IERC3643IdentityRegistryStorage`                                                          |
| **Deployed as** | A beacon proxy. The factory deploys one with a suite, or wires the suite to an existing one                            |
| **Written by**  | The registries bound to it, which hold `IRS_WRITER` in the domain of the storage                                       |
| **Limit**       | 300 bound registries, returned by `MAX_BOUND_REGISTRIES()`                                                             |

### Reads

| View                                                                                                    | Returns                                                                                                                                                                                                                                                  |
| ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `storedIdentity(_userAddress)`                                                                          | The identity registered for the address. With no registration, the identity the address is globally linked to: the storage asks the `IdentityFactory` of each bound registry in turn and returns the first answer, or zero. A revoked link still answers |
| `isLocallyRegistered(userAddress)`                                                                      | Whether the address has a registration in this storage                                                                                                                                                                                                   |
| `isIdentityRegistryBound(identityRegistry)`                                                             | Whether a registry is bound                                                                                                                                                                                                                              |
| `linkedIdentityRegistries()`, `linkedIdentityRegistries(_start, _end)`, `linkedIdentityRegistryCount()` | The bound registries, whole or by range, and their number                                                                                                                                                                                                |
| `storedInvestorCountry(address)`                                                                        | 0: the storage keeps no country                                                                                                                                                                                                                          |

### Writes

| Function                                                  | Access       | Reverts with                                                                                                                                                                                                 |
| --------------------------------------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `addIdentityToStorage(_userAddress, _identity, _country)` | `IRS_WRITER` | `ZeroAddress`, `AddressAlreadyStored`. Emits `IdentityStored`, and `IdentityOverridden` when the identity differs from the global link of the address                                                        |
| `modifyStoredIdentity(_userAddress, _identity)`           | `IRS_WRITER` | `ZeroAddress`, `AddressNotYetStored`. Emits `IdentityModified` and `InvestorIdentityChanged`, and `IdentityOverridden` or `IdentityOverrideReleased` when the divergence from the global link starts or ends |
| `removeIdentityFromStorage(_userAddress)`                 | `IRS_WRITER` | `ZeroAddress`, `AddressNotYetStored`. Emits `IdentityUnstored`, and `IdentityOverrideReleased` when the registration differed from the global link                                                           |
| `modifyStoredInvestorCountry(address, uint16)`            |              | Reverts with `Deprecated`                                                                                                                                                                                    |

A registry calls these functions when a Registry Agent calls `registerIdentity`, `updateIdentity` or `deleteIdentity` on it. They are not called directly.

### Binding registries

| Function                                       | Access                                  | Reverts with                                                                                                                   |
| ---------------------------------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `bindIdentityRegistry(identityRegistry)`       | `IRS_BINDER`                            | `AuthorityMismatch` unless the registry answers to the same access manager, `MaxIRByIRSReached`. Emits `IdentityRegistryBound` |
| `unbindIdentityRegistry(_identityRegistry)`    | `OWNER`                                 | `ZeroAddress`, `IdentityRegistryNotStored`. Emits `IdentityRegistryUnbound`                                                    |
| `init(accessManagerAddress, initialIRAddress)` | Initializer, called once by the factory | `ZeroAddress`                                                                                                                  |

Binding lists the registry in the storage. The registry also needs `IRS_WRITER` in the domain of the storage to write, which the commissioning of a suite grants: see [25 Commission a suite and grant roles](/guides/issuer/25.-commission-a-suite-and-grant-roles.md).

> **A shared storage shares registrations.** Every registry bound to a storage reads the same registrations. An address registered through one asset resolves to the same identity for every asset wired to that storage. Each asset keeps its own required topics and trusted issuers.

### Events

| Event                                                                                                                   | Emitted when                                                              |
| ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| `IdentityStored(address indexed _investorAddress, IIdentity indexed _identity)`, `IdentityUnstored` (same arguments)    | A registration is written, deleted                                        |
| `IdentityModified(IIdentity indexed _oldIdentity, IIdentity indexed _newIdentity)`                                      | A registration names another identity                                     |
| `InvestorIdentityChanged(address indexed investor)`                                                                     | With `IdentityModified`: the address concerned                            |
| `IdentityOverridden(address indexed investor, IIdentity indexed globalIdentity, IIdentity indexed localIdentity)`       | A registration names another identity than the global link of the address |
| `IdentityOverrideReleased(address indexed investor, IIdentity indexed localIdentity, IIdentity indexed globalIdentity)` | That divergence ends                                                      |
| `IdentityRegistryBound(address indexed _identityRegistry)`, `IdentityRegistryUnbound` (same argument)                   | A registry is bound, unbound                                              |


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.t-rex.network/reference/token-suite/identityregistrystorage.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
