TREXFactory
TREXFactory deploys a complete token suite in one transaction: the token, its registry, its identity storage, its compliance and, unless one is supplied, its access manager. Every contract is a beacon proxy at a CREATE3 address derived from a salt. The concepts are in Deterministic deployment (CREATE3) and the operation in 01 Deploy a token suite.
At a glance
Source
contracts/factory/TREXFactory.sol
Interface
ITREXFactory
Deployed as
One contract per network, not upgradeable. Built with the implementation authority, the IdentityFactory, the TrustedGatewayRegistry and the platform access manager
Roles
Platform roles: ASSET_DEPLOYER to deploy suites, OWNER for the three setters
Limits at deployment
5 required claim topics, 5 trusted issuers, 25 compliance modules
Deploy a suite
deployTREXSuite(salt, tokenDetails, claimDetails)
ASSET_DEPLOYER
A suite behind the shared beacons of the implementation authority. It follows the versions the network publishes
deployTREXSuiteIsolated(salt, tokenDetails, claimDetails)
ASSET_DEPLOYER
A suite behind its own beacons, cloned from the active implementations. Later publish and upgrade calls on the authority do not reach it
TokenDetails
name, symbol
string
Not empty
decimals
uint8
0 to 18
irs
address
An existing IdentityRegistryStorage to reuse, or zero for a new one. A supplied storage must answer to the suite's access manager. The factory does not bind the new registry to it: the Issuer does. Must be zero for an isolated suite
ONCHAINID
address
The ONCHAINID of the token, or zero to have the factory create one of type ASSET through the IdentityFactory
complianceModules
address[]
The modules to bind to the compliance
complianceSettings
bytes[]
One setting call per module, by index. Modules without a setting go at the end of complianceModules
accessManager
address
An existing access manager, or zero to have the factory deploy a TREXAccessManager for the suite
accessManagerAdmin
address
The account that receives ADMIN_ROLE on the manager the factory deploys. Ignored when a manager is supplied
ClaimDetails
claimTopics
uint256[]
The required claim topics
issuers
address[]
The trusted Claim Issuers
issuerClaims
uint256[][]
For each issuer, by index, the topics it is trusted for
What a deployment does
With no access manager supplied. The factory deploys a
TREXAccessManager, creates a domain named after the token, assigns the token and its storage to it, maps every function of the suite to its role, commissions the suite and handsADMIN_ROLEtoaccessManagerAdmin. The suite is operable at once.With an access manager supplied. The factory never calls it. The suite is deployed with no role wiring and is not operable until the Issuer commissions it: see 25 Commission a suite and grant roles.
In both cases. The token is left paused, with no supply. The factory emits
Deployedfor each proxy, thenTREXSuiteDeployed, andIsolatedSuiteDeployedfor an isolated suite.Isolated suites. The beacons of the suite contracts are owned by the suite's access manager. The beacon of an access manager the factory deploys is owned by
accessManagerAdmin. Changing that administrator takes two steps: theADMIN_ROLEinside the manager, andtransferOwnershipon that beacon.
Reverts
TokenAlreadyDeployed
The salt was already used
MaxClaimTopicsReached, MaxClaimIssuersReached
More than 5 topics, more than 5 issuers
MaxModulesReached, InvalidCompliancePattern
More than 25 modules, more settings than modules
ZeroAddress, InvalidAccessManagerAdmin
accessManagerAdmin is zero, the factory itself, or the address the new manager is deployed at
AccessManagerNotAContract
A supplied manager has no code
StorageAuthorityMismatch
A supplied storage answers to another manager
IsolatedSuiteCannotReuseIRS
irs is not zero for an isolated suite
TokenIdentityAlreadyBound
The token address is already linked to another identity than the one supplied
The errors of each init
An empty name, decimals above 18, a duplicate topic or issuer
Settings and reads
setImplementationAuthority(implementationAuthorityAddress)
OWNER
ZeroAddress, InvalidImplementationAuthority. Emits ImplementationAuthoritySet
setIdFactory(idFactoryAddress)
OWNER
ZeroAddress. Emits IdFactorySet
setTrustedGatewayRegistry(trustedGatewayRegistryAddress)
OWNER
ZeroAddress. Emits TrustedGatewayRegistrySet
getToken(salt)
Anyone, read
The token deployed with a salt, or zero
getImplementationAuthority(), getIdFactory(), getTrustedGatewayRegistry()
Anyone, read
A setter changes what later deployments use. It does not touch the suites already deployed.
Events
TREXSuiteDeployed(address indexed token, address registry, address irs, address mc, string salt)
A suite is deployed
IsolatedSuiteDeployed(address indexed token, ITREXImplementationAuthority.SuiteBeacons beacons)
After it, for a suite with its own beacons
Deployed(address indexed addr)
Each proxy the factory deploys: access manager, storage, registry, compliance, token
ImplementationAuthoritySet(address implementationAuthority), IdFactorySet(address idFactory), TrustedGatewayRegistrySet(address trustedGatewayRegistry)
A pointer of the factory is set, at construction too
Last updated