Getting Started with Convector


  • Node 8.11.0 (other versions might work, but this is the one we use for development)
  • Docker

Using Convector CLI

Since Convector CLI was released, we recommend using it to provision your Chaincode projects. It makes it easier, faster, and less prone to errors.

To start a new chaincode project follow these steps.

npm i -g @worldsibu/convector-cli

# Create a new project with a default chaincode package


npm i

# Bring up a development blockchain in your computer
npm run env:restart

# Install the chaincode to the blockchain
npm run cc:start -- CHAINCODE-NAME 1

# Apply all the changes you want to the project.
# When you need to upgrade your chaincode in the blockchain, you can simply do
npm run cc:upgrade -- CHAINCODE-NAME 2

Doing things manually

Convector CLI has been recently released to the public. It makes it even easier to onboard Convector, but if you still want to things manually, you can follow this instructive.

In your NodeJS project

Internally we use Lerna for our projects, and we advice you to do the same, since you'll be working with different npm modules in the same project, although this is totally optional.

We also recommend the use of npx to avoid global dependencies. So this will be your only global dependency. Try npm i -g npx.


Create a folder and cd into it. Run npx lerna init. Lerna will create the following structure.


Inside that packages folder, create your a folder with your chaincode's name.


There you will put all of your chaincode's code. Start a new npm project inside that folder npm init. Fill the blanks.

Add some basic dependencies so you can get started:

npm install -SE @worldsibu/convector-core-{model,controller} && npm i -SE reflect-metadata yup

Folder Structure

Inside your chaincode folder you can create the folder structure of your preferences. We suggest the following.


Just mkdir src && mkdir tests.

Code your smart contracts

Create the Controllers and Models necessary for your application, checkout each guide to learn how to do so and more details.

Some basic structure can look like.


import {
} from '@worldsibu/convector-core-controller';

import { Test } from './test.model';

export class TestController extends ConvectorController {
  public async create(
    test: Test
  ) {


import * as yup from 'yup';
import {
} from '@worldsibu/convector-core-model';

export class Test extends ConvectorModel<Test> {
  public readonly type = 'io.worldsibu.test';

  public name: string;

  public created: number;

  public modified: number;

Bootstrap this structure with touch ./packages/<chaincode-name>/src/<chaincode-name>.model.ts && touch ./packages/<chaincode-name>/src/<chaincode-name>.controller.ts.

Unit Tests

We strongly suggest you create a unit tests for your controllers, since it's the easiest way to test their logic. Refer to the guides to learn more about unit testing.

During development you don't really need a blockchain. The logic you put in your chaincodes is no more than simple programming logic, so you can mock things up (we help with this) and define unit tests that execute in a virtual environment instead of an actual blockchain.

Take your code to the blockchain

When you're ready to test on a real chaincode, you can add our Convector Tools. dev-env will create a development blockchain in your computer. Make sure to do it at the root project folder, not inside ./packages/<chaincode-name>.

npm install -D @worldsibu/convector-{adapter-mock,tool-{dev-env,chaincode-manager}} fabric-client@1.1.2 fabric-ca-client@1.1.2

This Convector Tool setups a development environment for you to easily run the chaincodes. All the following scripts can be invoked from the path ./node_modules/@worldsibu/convector-tool-dev-env/scripts/*:

To make it easier for you, add in your root package.json the following scripts. Make sure to do it at the root project folder, NOT inside ./packages/<chaincode-name>/package.json.

    "env:restart": "./node_modules/@worldsibu/convector-tool-dev-env/scripts/",
    "env:clean": "./node_modules/@worldsibu/convector-tool-dev-env/scripts/"

Now you can manage your development blockchain straight from simple commands. Try running npm run env:restart to kickstart a blockchain in your comnputer.

Let's break this commands down.

Command What it does
env:clean Cleans everything up
env:restart Install a whole blockchain from scratch, it will create a folder in the root .convector-dev-env with all of the crypto materials you will need, as well it will start a set of containers you can explore by doing docker ps.

The basic setup is explained in Development-Environment.

After having your blockchain setup you will need to do some tasks with your chaincode, like installing it.

Chaincode manipulation

By using the chaincode manager you can install and upgrade chaincodes in the blockchain. Refer to the Chaincode-Manager guide since you will need to first bootstrap some blockchain profiles to define some details about the topology of your blockchain and your chaincode.

Relevant references

Convector CLI has been recently released! Get familiar with the new way to create Enterprise Smart Contract Systems.

Issues Newsletter Discord

npm License

Star Follow