Skip to main content

Set up a project

In this section, you'll set up a project to use FT4.

Rell setup

To set up a project using Rell, perform the following steps:

  1. Install Chromia CLI and set up PostgreSQL database.

  2. Create a project directory by executing the following command:

    mkdir ft4-demo && cd ft4-demo
  3. Create a Rell project using the chr command:

    chr create-rell-dapp && cd my-rell-dapp
  4. Generate an admin key pair that'll be used for registering accounts and assets:

    chr keygen --save .chromia/ft4-admin.keypair

    Note that we are saving the keypair file inside the .chromia folder, which is by default ignored by .gitignore. If you save the file somewhere else, add *.keypair to the correct .gitignore file!

  5. Configure the FT4 module arguments by adding the moduleArgs and libs sections to your chromia.yml file.

    module: main
    admin_pubkey: 03028A31DBA82E46DE26A608249147A6A1A88C62A1A65B640C9B4369D4CAD928BE

    path: rell/src/lib/ft4
    tagOrBranch: v0.7.0r
    rid: x"F7C207AA595ABD25FDE5C2C2E32ECD3768B480AD03D1F2341548FF4F37D9B7AF"
    insecure: false
    path: src/iccf
    tagOrBranch: 1.32.2
    rid: x"1D567580C717B91D2F188A4D786DB1D41501086B155A68303661D25364314A4D"

    rellVersion: 0.13.10 # Or your rell version if your is newer

    - test.arithmetic_test
    - test.data_test

    The ICCF dependency is mandatory to use cross-chain transfers in your dapp. The admin_pubkey definition is only required if you're using the admin module.

    These details are better discussed in the documentation for imports.

  6. Replace the admin_pubkey value with the generated admin public key in the ft-admin.keypair file. Additionally, you can configure the rate limiter settings. Refer to the rate limiter topic for more details on the configuration.

  7. Install the FT4 Rell library

    chr install
  8. Import some of the FT4 functionality into the main app module by adding these import statements to the main.rell file:

    import lib.ft4.accounts;
    import lib.ft4.assets;
    import lib.ft4.admin;

    There are better ways to import the library than this one, but it's the easiest to set up. To better understand the intricacies of imports, be sure to check out the relative documentation once you're familiar with FT4.

  9. Start the node to verify if the configuration file is set up correctly by running the command chr node start. You can call a query to check if the FT4 module is imported correctly, such as chr query ft4.get_config. By default, the output should look like this:


Client setup with TypeScript

This section discusses how to install and initialize clients.

Install the clients

To install the FT4 client, you can use npm (Node Package Manager) to download and install the required package into your existing npm project. Follow the steps below. To get started with npm, see the official guide.

  1. Open your terminal or command prompt.

  2. Run the following command:

    npm install @chromia/ft4

This command downloads and installs the @chromia/ft4 and postchain-client packages from the npm registry.

Initialize the clients

After installing the clients, you can initialize them in your JavaScript code to start interacting with the Postchain network. Here's an example of how to initialize the clients:

const { createClient } = require("postchain-client");
const { createConnection } = require("@chromia/ft4");

const url = "http://localhost:7740";
const client = await createClient({
nodeUrlPool: url,
blockchainIid: 0,

const connection = createConnection(client);

In the code snippet above, we import the necessary modules from the postchain-client and @chromia/ft4 packages. Next, we define the url of the Postchain network we want to connect to (in this case, "http://localhost:7740"). We then create an instance of the IClient using the specified URL and the internal ID of the chain, which by default is 0 on a local network.

With the client initialized, you can now utilize its capabilities to interact with the Postchain network and perform various operations, such as sending transactions and querying the blockchain.

We then pass the client to the createConnection method from FT4, allowing us to easily use all of the FT4 features.

To test that everything works, we can add a line that calls a function on the connection object that will trigger a backend call. For example:

const { createClient } = require("postchain-client");
const { createConnection } = require("@chromia/ft4");

async function main() {
const url = "http://localhost:7740";
const client = await createClient({
nodeUrlPool: url,
blockchainIid: 0,

const connection = createConnection(client);
console.log(await connection.getAllAssets()); // This line is new


We can run the above example with node index.js; the line will print all the assets registered from the blockchain. If you followed along in this example, the list of assets would be empty as we have yet to register any assets. Since the query is paginated (see the section about paginated entities to learn more), the response will look like this:

{ data: [], nextCursor: null }

In the following sections, we will cover how to register assets that will show up here.