Getting started

Contracts setup

When developing TokenF, a lot of attention was paid to making it easy to create projects based on it. The architecture may seem complicated at first glance, but once you understand it, it is easy enough to implement a project of any size.

In order to start developing a TokenF-based project, you need to add an npm package with the core contracts

npm install @tokenf/contracts

Regulatory token setup

Since you have chosen TokenF, the centrepiece of your protocol is likely to be the regulatory token itself. All you need to do is inherit the token contract from the TokenF or NFTF contract and add an init function. This completes the configuration of the base token.

Example of a basic EquityToken:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

import {TokenF} from "@tokenf/contracts/TokenF.sol";

contract EquityToken is TokenF {
    function __EquityToken_init(
        address regulatoryCompliance_,
        address kycCompliance_,
        bytes memory initRegulatory_,
        bytes memory initKYC_
    ) external initializer {
        __AccessControl_init();
        __ERC20_init("Equity Token", "ET");
        __AgentAccessControl_init();
        __TokenF_init(regulatoryCompliance_, kycCompliance_, initRegulatory_, initKYC_);
    }
}

Example of a basic LandNFT:

This contracts are easily customisable by overriding the virutal functions, so you can implement arbitrary logic.

Compliances setup

The next step is to create KYCCompliance and RegulatoryCompliance contracts. As with the token, in the basic version you only need to inherit from the required TokenF compliance contracts and add init functions.

Like all other contracts, compliance contracts can be easily customised to suit your needs. If the contracts cannot provide you with the functionality you need, you can implement the compliance contracts yourself, as long as the IKYCCompliance and IRegulatoryCompliance interfaces are implemented.

Example of basic compliance contracts for EquityToken or EquityNFT:

Modules setup

The last but not least part is module configuration. TokenF provides abstract contracts for KYC and Regulatory modules, which in most situations will be suitable for inheritance. In case they can't provide the necessary business logic, there is an AbstractModule contract that will definitely fit all situations.

To release your own modules, you need to inherit from the required abstract module or from already implemented modules, which TokenF also provides.

Example of a TokenF regulatory module for setting minimum and maximum transfer limits:

Example of a ready-to-use user module:

Deployment process

Deployment process depends quite a lot on the specific implementation of the project, but still there will be common parts. Let's look at the steps for deploying basic contracts from the examples above:

  1. Deployment of core contracts, including EquityToken, KYCComplianceFacet and RegulatoryComplianceFacet

  2. Initializing EquityToken contract

  3. Deployment of required modules

  4. Initializing modules

  5. Adding modules to EquityToken

A sample deploy script can be found in the examples folder in the TokenF repository:

Deployment process for the NFTF is quite similar to TokenF. A sample deploy script can be found in the same examples folder in the TokenF repository.

Last updated