The T-REX Factory is a pivotal smart contract in the T-REX protocol, deployed at the same address on every EVM-compatible chain where the ERC-3643 association has implemented the protocol. It enables users to deploy the entire T-REX suite (Token, Identity Registry, Identity Registry Storage, Claim Topics Registry, Trusted Issuers Registry, and Compliance) in a single transaction, streamlining the setup process and ensuring consistency across multiple blockchains.
Efficiency and Consistency:
The single transaction deployment process ensures that all components of the T-REX suite are deployed consistently and efficiently. This reduces the complexity and potential errors associated with manual deployments.
Future-Proof Design:
The use of upgradeable proxies ensures that deployed contracts can be updated without needing redeployment. This future-proof design allows the T-REX protocol to adapt to new standards and requirements seamlessly.
Enhanced Interoperability:
The cross-chain consistency provided by the T-REX Factory enhances the interoperability of the T-REX ecosystem. It ensures that claims and credentials can be used across different networks, reducing the need for redundant verification processes.
Single Transaction Deployment:
The T-REX Factory allows the deployment of the entire T-REX suite in one transaction. This includes the Token, Identity Registry (IR), Identity Registry Storage (IRS), Claim Topics Registry (CTR), Trusted Issuers Registry (TIR), and Compliance contracts.
Predefined Settings:
Users can predefine a wide range of settings in the deployment transaction, including defining agents for the Token and IR, required claim topics, trusted issuers, and more. This feature ensures that all necessary configurations are set up during deployment.
Reuse of Existing IRS:
The T-REX Factory can reuse an existing IRS if it needs to be shared with other tokens. If not, it will create a new IRS. This flexibility allows for efficient use of resources and better integration with existing infrastructure.
Upgradeable Proxies:
All contracts deployed by the T-REX Factory are implemented as upgradeable proxies (beacon proxies). This design ensures that contracts can be updated without requiring redeployment, providing a future-proof solution.
Cross-Chain Consistency:
Using the CREATE2 opcode, the T-REX Factory ensures that contracts can be deployed at the same address across different EVM chains. This consistency is crucial for cross-chain interoperability and seamless integration.
Linked to IdFactory:
The T-REX Factory is linked to the IdFactory, which it uses to deploy ONCHAINID contracts. When deploying a T-REX suite, the factory generates an AssetID (the onchain identity of the tokenized asset), ensuring that each tokenized asset has a unique and verifiable identity.
Deployment Process:
The T-REX Factory deploys a new T-REX token and sets all the parameters as required. It handles the deployment of the Token, IR, IRS (if not provided), CTR, TIR, and Compliance contracts, setting owners, agents, required claims, and trusted issuers in a single transaction.
Predefined Configurations:
During deployment, users can define various settings such as token details, agents, compliance modules, and claim details. This comprehensive setup ensures that the deployed contracts are fully configured and ready for use.
Cross-Chain Deployment:
By leveraging the CREATE2 opcode, the T-REX Factory deploys contracts at predetermined addresses, ensuring that the same address can be used across different EVM chains. This feature supports the seamless use of claims and credentials across multiple networks.
Integration with Other Components:
The T-REX Factory integrates with the IdFactory to deploy ONCHAINIDs, generating unique identities for tokenized assets. It also interacts with implementation authority contracts to ensure that the correct contract versions are used.
The T-REX Gateway interface defines the set of functions and events used to manage and control the deployment of T-REX tokens. This page provides a detailed breakdown of each function and event, explaining its purpose, source, and functionality. Additionally, the TokenDetails
, ClaimDetails
, and Fee
structs are defined to ensure a comprehensive understanding of how to interact with the T-REX Gateway contract.
Structs
TokenDetails
Description: Holds all necessary details for deploying a new T-REX token and its associated contracts.
ClaimDetails
Description: Holds all necessary details regarding the claims and claim issuers.
Fee
Description: Holds the details for deployment fees.
FactorySet
Event
Description: Emitted when the factory variable is set or modified.
PublicDeploymentStatusSet
Event
Description: Emitted when the public deployment status is set or modified.
DeploymentFeeSet
Event
Description: Emitted when the deployment fees details are set or modified.
DeploymentFeeEnabled
Event
Description: Emitted when the deployment fees are enabled or disabled.
DeployerAdded
Event
Description: Emitted when an address is flagged as a deployer.
DeployerRemoved
Event
Description: Emitted when a deployer address loses deployment privileges.
FeeDiscountApplied
Event
Description: Emitted when a discount on deployment fees is granted for an address.
GatewaySuiteDeploymentProcessed
Event
Description: Emitted whenever a TREX token has been deployed by the TREX factory through the use of the Gateway.
setFactory
Description: Sets the factory contract address used for deploying TREX smart contracts. Only the owner can call this method. Emits a FactorySet
event upon successful execution.
setPublicDeploymentStatus
Description: Sets the status for public deployments of TREX contracts. Enables or disables public deployments. Only the owner can call this method. Emits a PublicDeploymentStatusSet
event upon successful execution.
transferFactoryOwnership
Description: Transfers the ownership of the Factory contract. Only the owner can call this method.
enableDeploymentFee
Description: Toggles the deployment fee status for TREX contracts. Enables or disables the deployment fees. Only the owner can call this method. Emits a DeploymentFeeEnabled
event upon successful execution.
setDeploymentFee
Description: Sets the deployment fee details for TREX contracts. Establishes the amount, token type, and collector address for the deployment fee. Only the owner can call this method. Emits a DeploymentFeeSet
event upon successful execution.
addDeployer
Description: Adds an address to the list of approved deployers. Only an admin (owner or agent) can call this method. Emits a DeployerAdded
event upon successful addition.
batchAddDeployer
Description: Adds multiple addresses to the list of approved deployers in a single transaction. Only an admin (owner or agent) can call this method. Emits a DeployerAdded
event for each successfully added deployer.
removeDeployer
Description: Removes an address from the list of approved deployers. Only an admin (owner or agent) can call this method. Emits a DeployerRemoved
event upon successful removal.
batchRemoveDeployer
Description: Removes multiple addresses from the list of approved deployers in a single transaction. Only an admin (owner or agent) can call this method. Emits a DeployerRemoved
event for each successfully removed deployer.
applyFeeDiscount
Description: Applies a fee discount to a specific deployer's address. Only an admin (owner or agent) can call this method. The fee discount is expressed per 10,000 (10000 = 100%, 1000 = 10%, etc.). Emits a FeeDiscountApplied
event upon successful application.
batchApplyFeeDiscount
Description: Applies fee discounts to multiple deployers in a single transaction. Only an admin (owner or agent) can call this method. Emits a FeeDiscountApplied
event for each successfully applied discount.
deployTREXSuite
Description: Deploys a TREX suite of contracts using provided token and claim details. If public deployments are disabled, only approved deployers can execute this function. If public deployments are enabled, an external entity can deploy only on its behalf and not for other addresses unless it's an approved deployer. If deployment fees are enabled and applicable (after considering any discounts for the deployer), the fee is collected from the deployer's address. Emits a GatewaySuiteDeploymentProcessed
event upon successful deployment.
batchDeployTREXSuite
Description: Deploys multiple TREX suites of contracts in a single transaction using provided arrays of token and claim details. This batch function allows deploying up to 5 TREX suites at once. Performs the same checks as deployTREXSuite
for each suite. Emits a GatewaySuiteDeploymentProcessed
event for each deployed suite.
getPublicDeploymentStatus
Description: Retrieves the current public deployment status.
getFactory
Description:
Retrieves the address of the current Factory contract.
getDeploymentFee
Description: Retrieves the current deployment fee details.
isDeploymentFeeEnabled
Description: Checks if the deployment fee is currently enabled.
isDeployer
Description: Checks if the provided address is an approved deployer.
calculateFee
Description: Calculates the deployment fee for a given deployer after accounting for any discounts.
ERC-3643 T-REX factories are available on several blockchain networks
Ethereum
Polygon PoS
Amoy
Avalanche
Fuji
Telos
Kaia
IOTA EVM
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.
ClaimDetails
Description: This struct holds all the necessary details regarding the claims and claim issuers.
Deployed
Event
Description: Emitted whenever a single contract is deployed by the factory.
IdFactorySet
Event
Description: Emitted when the Identity Factory is set.
ImplementationAuthoritySet
Event
Description: Emitted when the implementation authority of the factory contract is set.
TREXSuiteDeployed
Event
Description: Emitted by the factory when a full suite of T-REX contracts is deployed.
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.
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.
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.
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.
getImplementationAuthority
Source: ITREXFactory
Description: Returns the address of the implementation authority contract.
getIdFactory
Source: ITREXFactory
Description: Returns the address of the identity factory contract.
getToken
Source: ITREXFactory
Description: Returns the address of the token corresponding to a given salt string.
The T-REX Gateway is an essential smart contract in the T-REX protocol, designed to provide flexible and secure access to the T-REX Factory. By acting as an intermediary, the T-REX Gateway manages who can deploy tokens, under what conditions, and with what specific rules. This architecture not only enhances security but also allows for dynamic access management without modifying the factory itself.
Flexibility and Control:
By managing access and deployment rules, the Gateway provides a flexible and secure way to control token deployment without modifying the T-REX Factory.
Enhanced Security:
The controlled generation of deployment salts and role-based access control prevent unauthorized deployments and mitigate cross-chain vulnerabilities.
Interoperability:
Deployed at the same address across multiple chains, the Gateway ensures consistent and seamless token deployment, enhancing interoperability within the T-REX ecosystem.
Access Management:
The T-REX Gateway acts as the owner of the T-REX Factory, granting it the ability to control token deployment. It defines multiple roles with different permissions, ensuring that only authorized entities can deploy tokens.
Role-Based Access Control:
The T-REX Gateway defines several roles:
Owner Role: Super admin with full control, including transferring ownership of the Factory to a new gateway.
Agent Role: Agents can add deployers, deploy tokens, and apply fee discounts. They can operate even when public deployments are disabled.
Deployer Role: Deployers can deploy tokens for token owners, subject to applicable fees and discounts.
Public Address: General users who can deploy tokens when public deployments are enabled. They must pay the required fees and can only deploy for themselves.
Fee Management:
The Gateway can define fees for deploying tokens, which must be paid in a specified utility token or stablecoin. It also allows for discounts to be applied by agents, making the deployment free if necessary.
Enhanced Security:
To prevent cross-chain vulnerabilities, the Gateway controls the salt used in deployments. By generating the salt from a hash of the token owner address and the token name, it ensures that tokens cannot be duplicated across different chains.
Cross-Chain Consistency:
Like the T-REX Factory, the Gateway is deployed at the same address on every EVM-compatible chain where the protocol is implemented. This consistency ensures seamless integration and interoperability across multiple networks.
Managing Deployment Access:
The Gateway sets the factory contract address, controls public deployment status, and manages deployment fees. It adds and removes deployers and agents, ensuring that only authorized addresses can deploy tokens.
Defining Deployment Rules:
The Gateway allows the owner to set detailed rules for deployment, including enabling or disabling public deployments, setting deployment fees, and applying discounts. This flexibility ensures that deployment conditions can be tailored to meet specific requirements.
Deploying Tokens:
When a deployment request is made, the Gateway checks the caller's permissions, calculates any applicable fees, and processes the deployment through the T-REX Factory. The salt used for deployment is derived to ensure unique and secure token addresses.
T-REX Factory: The Gateway acts as the owner of the Factory, controlling who can deploy tokens and under what conditions.
Utility Token: The Gateway manages the payment of deployment fees in a specified utility token or stablecoin, ensuring a standardized process for all deployments.