# Identity Registry Storage Interface

The Identity Registry Storage interface defines the set of functions and events used to manage and store identity data within the T-REX protocol. Below is a detailed breakdown of each function and event, explaining its purpose, source, and functionality.

**`IdentityStored`**

**Event**

**Description**: Emitted when an identity is registered into the storage contract.

```solidity
event IdentityStored(address indexed investorAddress, IIdentity indexed identity);
```

***

**`IdentityUnstored`**

**Event**

**Description**: Emitted when an identity is removed from the storage contract.

```solidity
event IdentityUnstored(address indexed investorAddress, IIdentity indexed identity);
```

***

**`IdentityModified`**

**Event**

**Description**: Emitted when an identity has been updated in the storage contract.

```solidity
event IdentityModified(IIdentity indexed oldIdentity, IIdentity indexed newIdentity);
```

***

**`CountryModified`**

**Event**

**Description**: Emitted when an identity's country has been updated in the storage contract.

```solidity
event CountryModified(address indexed investorAddress, uint16 indexed country);
```

***

**`IdentityRegistryBound`**

**Event**

**Description**: Emitted when an Identity Registry is bound to the storage contract.

```solidity
event IdentityRegistryBound(address indexed identityRegistry);
```

***

**`IdentityRegistryUnbound`**

**Event**

**Description**: Emitted when an Identity Registry is unbound from the storage contract.

```solidity
event IdentityRegistryUnbound(address indexed identityRegistry);
```

***

**`addIdentityToStorage`**

**Source**: `IIdentityRegistryStorage`

**Description**: Adds an identity contract corresponding to a user address in the storage. Only callable by an agent of the contract.

```solidity
function addIdentityToStorage(
    address _userAddress,
    IIdentity _identity,
    uint16 _country
) external;
```

***

**`removeIdentityFromStorage`**

**Source**: `IIdentityRegistryStorage`

**Description**: Removes a user from the storage. Only callable by an agent of the contract.

```solidity
function removeIdentityFromStorage(address _userAddress) external;
```

***

**`modifyStoredInvestorCountry`**

**Source**: `IIdentityRegistryStorage`

**Description**: Updates the country corresponding to a user address. Only callable by an agent of the contract.

```solidity
function modifyStoredInvestorCountry(address _userAddress, uint16 _country) external;
```

***

**`modifyStoredIdentity`**

**Source**: `IIdentityRegistryStorage`

**Description**: Updates an identity contract corresponding to a user address. Only callable by an agent of the contract.

```solidity
function modifyStoredIdentity(address _userAddress, IIdentity _identity) external;
```

***

**`bindIdentityRegistry`**

**Source**: `IIdentityRegistryStorage`

**Description**: Adds an identity registry as an agent of the Identity Registry Storage Contract. Only callable by the owner of the contract.

```solidity
function bindIdentityRegistry(address _identityRegistry) external;
```

***

**`unbindIdentityRegistry`**

**Source**: `IIdentityRegistryStorage`

**Description**: Removes an identity registry from being an agent of the Identity Registry Storage Contract. Only callable by the owner of the contract.

```solidity
function unbindIdentityRegistry(address _identityRegistry) external;
```

***

**`linkedIdentityRegistries`**

**Source**: `IIdentityRegistryStorage`

**Description**: Returns the identity registries linked to the storage contract.

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

***

**`storedIdentity`**

**Source**: `IIdentityRegistryStorage`

**Description**: Returns the ONCHAINID of an investor based on their wallet address.

```solidity
function storedIdentity(address _userAddress) external view returns (IIdentity);
```

***

**`storedInvestorCountry`**

**Source**: `IIdentityRegistryStorage`

**Description**: Returns the country code of an investor based on their wallet address.

```solidity
function storedInvestorCountry(address _userAddress) external view returns (uint16);
```


---

# Agent Instructions: 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.erc3643.org/erc-3643/smart-contracts-library/onchain-identities/identity-registry-storage/identity-registry-storage-interface.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.
