TokenF Modules

Modules Architecture

Modules are the backbone of the TokenF framework regulatory mechanics. All rules, requirements, and compliance for KYC and various token transfers can be customized via modular plugin-based architecture.

In the vanilla TokenF version there are two main types of modules:

  1. KYC modules

  2. Regulatory modules

The KYC modules are responsible for any KYC-related compliance checks while Regulatory modules are used to perform conditional transfer limits / token balance obligations / operational limits / etc.

Modules represent quite a complex set of smart contracts that are related through inheritance and plugged in through composition to the aforementioned RegulatoryCompliance and KYCCompliance facets.

Pic. 2 TokenF modules architecture

The diagram depicts the relationships between contracts within the TokenF modules architecture. The bulk of the logic is implemented in the AbstractModule that AbstractKYCModule and AbstractRegulatoryModule extend. Certain modules will then inherit from AbstractKYCModule and AbstractRegulatoryModule contracts to define handlers, their relation to handler topics, context keys construction, and perform the required checks.

AbstractModule Contract

The AbstractModule contract is the basis for writing new modules for the TokenF framework. The contract implements the logic of handler topics management, the definition of handlers, and stores the “weak reference” to the AssetF token contract itself (for certain operations that should only be called by the token). Moreover, the AbstractModule contract defines an interface through which the TokenF managers will “speak” with the module.

AbstractKYCModule Contract

The AbstractKYCModule contract implements the AbstractModule interface and extends it by introducing the isKYCed function. This function is used by the KYCCompliance AssetF facet to authorize the user of the token. By default, the context key is keccak256(function selector).

AbstractRegulatoryModule Contract

The AbstractRegulatoryModule contract is very similar to the AbstractKYCModule in terms that it also implements the AbstractModule interface. However, two new functions are introduced: canTransfer and transferred. RegulatoryCompliance AssetF facet will call them to perform regulatory compliance checks. Similar to AbstractKYCModule, the default context key is keccak256(function selector).

Last updated