# T-REX Factory Interface

The T-REX Factory interface defines the set of functions and events used to deploy and manage the T-REX suite of contracts. Below is a detailed breakdown of each function and event, explaining its purpose, source, and functionality. Additionally, the structs `TokenDetails` and `ClaimDetails` are defined to provide a comprehensive understanding of how to interact with the T-REX Factory contract.

**Structs**

**`TokenDetails`**

**Description**: This struct holds all the necessary details for deploying a new T-REX token and its associated contracts.

```solidity
struct TokenDetails {
    address owner;          // Address of the owner of all contracts
    string name;            // Name of the token
    string symbol;          // Symbol / ticker of the token
    uint8 decimals;         // Decimals of the token (can be between 0 and 18)
    address irs;            // Identity registry storage address
    address ONCHAINID;      // ONCHAINID of the token
    address[] irAgents;     // List of agents of the identity registry
    address[] tokenAgents;  // List of agents of the token
    address[] complianceModules; // Modules to bind to the compliance
    bytes[] complianceSettings;  // Settings calls for compliance modules
}
```

**`ClaimDetails`**

**Description**: This struct holds all the necessary details regarding the claims and claim issuers.

```solidity
struct ClaimDetails {
    uint256[] claimTopics;        // Claim topics required
    address[] issuers;            // Trusted issuers addresses
    uint256[][] issuerClaims;     // Claims that issuers are allowed to emit
}
```

**`Deployed`**

**Event**

**Description**: Emitted whenever a single contract is deployed by the factory.

```solidity
event Deployed(address indexed _addr);
```

***

**`IdFactorySet`**

**Event**

**Description**: Emitted when the Identity Factory is set.

```solidity
event IdFactorySet(address _idFactory);
```

***

**`ImplementationAuthoritySet`**

**Event**

**Description**: Emitted when the implementation authority of the factory contract is set.

```solidity
event ImplementationAuthoritySet(address _implementationAuthority);
```

***

**`TREXSuiteDeployed`**

**Event**

**Description**: Emitted by the factory when a full suite of T-REX contracts is deployed.

```solidity
event TREXSuiteDeployed(address indexed _token, address _ir, address _irs, address _tir, address _ctr, address _mc, string indexed _salt);
```

***

**`setImplementationAuthority`**

**Source**: `ITREXFactory`

**Description**: Sets the implementation authority contract address. This contract contains the addresses of all implementation contracts. The proxies created by the factory will use the different implementations available in the implementation authority contract. Only callable by the owner of the T-REX Factory contract. Emits an `ImplementationAuthoritySet` event.

```solidity
function setImplementationAuthority(address _implementationAuthority) external;
```

***

**`setIdFactory`**

**Source**: `ITREXFactory`

**Description**: Sets the identity factory contract address. The identity factory contract is used by the T-REX Factory to deploy the ONCHAINID of the token in case the ONCHAINID is not specified. Only callable by the owner of the T-REX Factory contract. Emits an `IdFactorySet` event.

```solidity
function setIdFactory(address _idFactory) external;
```

***

**`deployTREXSuite`**

**Source**: `ITREXFactory`

**Description**: Deploys a new T-REX token and sets all the parameters as required by the issuer paperwork. This function will deploy and set the Token, Identity Registry (IR), Identity Registry Storage (IRS), Claim Topics Registry (CTR), Trusted Issuers Registry (TIR), and Compliance contracts. All contracts are deployed using the CREATE2 opcode, ensuring that they are deployed at a predetermined address. Only callable by the owner of the T-REX Factory contract. Emits a `TREXSuiteDeployed` event.

```solidity
function deployTREXSuite(
    string memory _salt,
    TokenDetails calldata _tokenDetails,
    ClaimDetails calldata _claimDetails
) external;
```

***

**`recoverContractOwnership`**

**Source**: `ITREXFactory`

**Description**: Recovers the ownership of contracts owned by the factory. Typically used for IRS contracts owned by the factory. Only callable by the owner of the T-REX Factory contract.

```solidity
function recoverContractOwnership(address _contract, address _newOwner) external;
```

***

**`getImplementationAuthority`**

**Source**: `ITREXFactory`

**Description**: Returns the address of the implementation authority contract.

```solidity
function getImplementationAuthority() external view returns(address);
```

***

**`getIdFactory`**

**Source**: `ITREXFactory`

**Description**: Returns the address of the identity factory contract.

```solidity
function getIdFactory() external view returns(address);
```

***

**`getToken`**

**Source**: `ITREXFactory`

**Description**: Returns the address of the token corresponding to a given salt string.

```solidity
function getToken(string calldata _salt) external view returns(address);
```


---

# 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/tokens-factory/t-rex-factory-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.
