Prerequisites
Dependencies
The following dependencies must be installed in order to run applications created with the Lisk SDK:
Dependencies | Version |
---|---|
Node.js |
v10 (LTS) |
PostgreSQL |
10+ |
Redis (optional) |
5+ |
Python |
2 |
Ports
Mandatory: Always open the WebSocket port of your desired network, to enable communication with other peer nodes. Optional: Open the corresponding HTTP port for your network, to ensure your node’s API is reachable. For more information, please see the diagram on the Interact with network page. |
To connect to the desired network with Lisk Core, please ensure that the corresponding ports are open:
Network | HTTP | WebSocket |
---|---|---|
Devnet |
4000 |
5000 |
These ports can be altered later in the configuration
file.
Prerequisites
Create a new user
To install the required prerequisites, it is necessary to have a user with sudo rights on the server.
The |
To run and manage a node in the future, please create a separate lisk
user.
Please execute the following command:
sudo adduser lisk
It is not mandatory to set up a lisk
user, especially when running a local instance for development purposes.
However, if it is required then it is recommended to create the user using the macOS GUI: https://support.apple.com/en-gb/guide/mac-help/mtusr001/mac
PostgreSQL
To install PostgreSQL please follow the instructions described below.
It is recommended using PostgreSQL with Docker for a quick and straight forward setup of PostgreSQL, and PostgreSQL system-wide for production environments. |
Please see the instructions for the MacOS listed below: |
Ubuntu
Firstly, install PostgreSQL on your machine by executing the following commands:
sudo apt-get purge -y postgres* (1)
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt update
sudo apt install postgresql-10
1 | Remove all previously installed postgres versions. |
After the installation is completed, it will be possible to see the PostgreSQL database cluster by running the following command:
pg_lsclusters
Drop the existing database cluster as shown below, and replace it with a cluster with the locale en_US.UTF-8
:
sudo pg_dropcluster --stop 10 main
sudo pg_createcluster --locale en_US.UTF-8 --start 10 main
Create a new database user called lisk
and grant it access rights to create databases.
Then create the database with the lisk
user as the owner.
Finally, define the password for the lisk
user by executing the following commands below:
If the following error occurs: |
sudo -u postgres -i createuser --createdb lisk
sudo -u postgres -i createdb lisk_dev --owner lisk
sudo -u postgres psql -d lisk_dev -c "alter user lisk with password 'password';"
Please change the password to a secure password of your choice.
In addition, do not forget to update this password in the Lisk SDK configuration later.
|
MacOS
To install the PostgreSQL version 10 execute the following command below:
brew install postgresql@10
Next, execute the following commands in order to have the PostgreSQL commands (e.g. psql
) in your PATH:
echo 'export PATH="/usr/local/opt/postgresql@10/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
Start the PostgreSQL, and create the lisk
user and the database by executing the following commands below:
pg_ctl -D /usr/local/var/postgresql@10 start
createuser lisk
createdb --owner=lisk lisk_dev
psql --dbname=lisk_dev --command="ALTER USER lisk WITH PASSWORD 'password';"
Please change the password to a secure password of your choice.
In addition, do not forget to update this password in the Lisk SDK configuration later.
|
Running PostgreSQL inside a Docker container will setup the correct version of PostgreSQL and containerize it away from any existing versions that may be present locally on your machine. Please choose this setup if unfamiliar with PostgreSQL, or if problematic issues with a previously installed version of PostgreSQL have occured.
Supported platforms: For further information please refer to the following link: https://docs.docker.com/engine/installation/#desktop
Install Docker
To install Docker please refer to the applicable link listed below for your operating system:
Mac OS X
Please refer to https://docs.docker.com/docker-for-mac/install/.
Please note that Docker for Mac already includes Docker Compose.
Install make
using XCode
Linux
Please refer to https://docs.docker.com/engine/installation/#server
Start the Docker container.
If you have other versions of PostgreSQL installed on your machine, please ensure to stop them before starting the docker container. |
docker run --name lisk_db -p 5432:5432 -e POSTGRES_USER=lisk -e POSTGRES_PASSWORD=password -e POSTGRES_DB=lisk_dev -d postgres:10
This will install PostgreSQL version 10 (postgres:10
) in a container with name lisk_db
and binds the port 5432
of the container with the same port of the machine.
As environment variables we expose POSTGRES_USER=lisk
to create the lisk user and POSTGRES_PASSWORD=password
to set the password for the lisk user.
Finally the environment variable POSTGRES_DB
creates the database lisk_dev
with the lisk
user as owner.
The above should be enough to set up the database ready to use with the Lisk SDK. To manage the Docker container, use the following commands listed below:
docker stop lisk_db (1)
docker start lisk_db (2)
docker restart lisk_db (3)
docker rm lisk_db (4)
1 | Stop the container. |
2 | Start the container. |
3 | Restart the container. |
4 | Remove the container. |
In order to access PostgreSQL inside the container via the CLI, please execute the following command:
docker exec --tty --interactive lisk_db psql -h localhost -U lisk -d postgres
Node.js
Node.js serves as the underlying engine for code execution. There are several different ways and version managers to install Node.JS on your system. It is recommended to use one of the following two listed below:
Change to the
|
It is recommended to use a Node version manager, such as NVM. NVM is a bash script which enables the management of multiple active Node.js versions.
-
To install nvm, please follow these instructions.
-
To install the correct version of Node.js using NVM, execute the command listed below:
nvm install 10.17.0
Alternatively, instead of using the NVM or other package managers, the Node package can be installed globally by executing the following commands listed below:
Ubuntu
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
MacOS
brew install node@10.17.0
PM2 (optional)
Install PM2 for managing the start/stop process of the application in the background by executing the following command:
npm install pm2 -g
Installation
To install the NPM package lisk-sdk, please execute the following command:
npm install lisk-sdk@2.3.9