Version: 0.13.7

Client library introduction

A TypeScript/JavaScript library for interacting with the Trustlines Protocol.


Install via package manager#

We publish the trustlines-clientlib to npm as a ES6 module.

To install run the following command:

$ npm i trustlines-clientlib

Build from source#

If you want to build the library from source run

git clone
cd clientlib
yarn && yarn build

This will create three different builds:

  • ES6 module in ./lib-esm
  • CommonJS module in ./lib
  • Bundled JS injectable into browser in ./_bundles

Get started#

We assume the usage of the trustlines-clientlib ES6 module in the following.


To start using the trustlines-clientlib you first have to configure the relay server you want to connect to. You can either connect to a local develop relay server or use publicly available ones.

import { TLNetwork } from "trustlines-clientlib"
// Instance using a relay connected to the Laika Testnet
const laika = new TLNetwork({
protocol: "https",
wsProtocol: "wss",
host: "",
path: "/api/v1",
// ...
// Instance using a relay connected to the TLBC
const tlbc = new TLNetwork({
protocol: "https",
wsProtocol: "wss",
host: "<url>", // TODO There is no public TLBC relay yet
path: "/api/v1",
// ...

Example usage#

This library is a promise-based library. So every asynchronous call will return a native JavaScript promise. If an error occurs the library will throw it. The caller has to handle it appropriately.

try {
const networks = await laika.currencyNetwork.getAll()
} catch (error) {
console.log("Caught error:", error)

Read our documentation for more#

Run Tests#

# All tests
yarn test
# Unit tests
yarn test:unit
# Integration tests
yarn test:integration
# end2end tests
yarn test:e2e

Note on end2end tests#

You have to have all components of the trustlines protocol running. A convenient way to achieve this is by using our end2end setup.

Running injected web3 example#

To run the example make sure to have MetaMask installed and connected to a JSON RPC.

yarn serve

This serves the injected web3 example app on You can find the app under ./examples/injected-web3.

Change log#