Lisk Elements
Lisk Elements is a JavaScript library containing several separately installable NPM packages, each encompassing fundemental components of Lisk related functionalities.
Package list
Name | NPM | Specification |
---|---|---|
API client |
||
BFT |
||
Chain |
||
Client |
||
Constants |
||
Cryptography |
||
DPoS |
||
P2P |
||
Passphrase |
||
Transaction pool |
||
Transactions |
||
Validator |
Setup
Pre-installation
Lisk Elements requires Node.js as the underlying engine for code execution. This document describes how to install Node.js and NPM for installation via NPM.
Install node
Follow the instructions for your operating system on the Node.js downloads page.
NPM is automatically installed along with Node.js. |
Installation
This section details how to install Lisk Elements for a given distribution.
As all packages in Lisk Elements are independent from each other, they can be installed seperately. |
Installation via NPM
To install the latest version of Lisk Elements for use as a dependency in a Node.js project, please proceed with the following:
Complete library:
npm install lisk-elements@4.0.0
Specific package:
npm install @liskhq/<package-name> (1)
1 | <package-name> can be any of the packages in Lisk Elements. |
Upon successful completion, NPM will add the Lisk Elements package to your package.json
file.
Load via CDN
Include the script below using the following HTML. The lisk
variable will be exposed.
Client library:
<script src="https://js.lisk.io/lisk-client-4.0.0.js"></script>
Or minified:
<script src="https://js.lisk.io/lisk-client-4.0.0.min.js"></script>
To include other packages of Lisk Elements, replace lisk-client
with any of the packages of Lisk Elements.
Usage
Node.js
Simply import (or require), the package and access its functionality according to the relevant namespace.
Example with the client package:
import lisk from '@liskhq/lisk-client';
//or
const lisk = require('@liskhq/lisk-client');
const transaction = new lisk.transaction.TransferTransaction({
asset: {
amount: '100000000',
recipientId: '15434119221255134066L',
},
fee: '25000000',
nonce: 3
});
Example with the sub packages:
const transactions = require('@liskhq/lisk-transactions');
const tx = new transactions.TransferTransaction({
asset: {
amount: '1',
recipientId: '1L',
},
fee: '25000000',
nonce: 3
});
Browser
Load the Lisk Elements script via the CDN.
For example, to load the minified version 3.0.2 of Lisk Elements, include the following script which will then expose the lisk
variable:
<script src="https://js.lisk.io/lisk-client-4.0.0.min.js"></script>
<script>
const transaction = lisk.transaction.transfer({
asset:{
amount: '100000000',
recipientId: '15434119221255134066L'
},
networkIdentifier: '11a254dc30db5eb1ce4001acde35fd5a14d62584f886d30df161e4e883220eb7',
});
</script>