A TypeScript/JavaScript library for interacting with the Trustlines Network Protocol.
We publish the trustlines-clientlib to npm as a ES6 module.
$ npm i trustlines-clientlib$ yarn add trustlines-clientlibIf you want to build the library from source run
git clone git@github.com:trustlines-protocol/clientlib.git
cd clientlib
yarn && yarn buildThis will create three different builds:
- ES6 module in
./lib-esm - CommonJS module in
./lib - Bundled JS injectable into browser in
./_bundles
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: 'relay0.testnet.trustlines.network',
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'
// ...
})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
# All tests
yarn test
# Unit tests
yarn test:unit
# Integration tests
yarn test:integration
# end2end tests
yarn test:e2eYou have to have all components of the trustlines protocol running. A convenient way to achieve this is by using our end2end setup.
You can find the documentation for the trustlines-clientlib here.
The underlying markdown files of the documentation can be found in this repository under the ./docs directory.
To generate the typedoc API reference documentation for this library run yarn doc.
To run the example make sure to have MetaMask installed and connected to a JSON RPC.
yarn serveThis serves the injected web3 example app on http://127.0.0.1:8080. You can find the app under ./examples/injected-web3.
See CHANGELOG