Binary setup

1. Pre-installation

1.1. Supported platforms

  • Ubuntu 20.04 (LTS) x86_64

  • Ubuntu 22.04 (LTS) x86_64

  • MacOS x86_64

  • MacOS ARM (Apple Silicon)

1.2. Hardware requirements

The following system requirements are recommended:

Memory
  • Machines with a minimum of 8 GB RAM for the Mainnet.

  • Machines with a minimum of 8 GB RAM for the Testnet.

Storage
  • Machines with a minimum of 40 GB HDD[1].

1.3. Open ports

Please ensure, that the necessary ports are open to run Klayr Core as intended.

For example, in case ufw is used on Ubuntu to manage the firewall settings, the respective ports can be opened as follows:

8778 and 7887 are the default ports. If you configured custom ports in the node config file, adjust the examples to these specific ports.
Node P2P communication
ufw allow 7887
Node API
ufw allow 8778

2. Installation

This section details how to install Klayr Core using pre-built application packages. Once completed, you will have a functioning node on the Klayr Network.

When using a MAC powered by Apple Silicon, please adhere to the following setup instructions:

2.1. Environment setup requirements (Apple Silicon processors only)

As a first step, please ensure to clean the old Node.js installations (with arm64 binaries).

rm -rf ~/.nvm

2.1.1. Install Rosetta (Intel x86 emulation layer)

Please execute the following command:

softwareupdate --install-rosetta

Add a new session and set the iTerm to open in the Intel mode. Now set a shortcut key (quick access), for opening the iTerm in the aforementioned mode. Following that, open a terminal in Intel mode. Optionally, to verify that the terminal is now running in Intel mode, execute the following command:

arch
Response
i386

2.1.2. Install Homebrew

Homebrew can be installed for either the ARM or Intel compatible binaries as mentioned below:

  • ARM compatible binaries

  • Intel compatible binaries

arch -arm64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Add Homebrew to your ~/.zshrc or .zsh_profile

if [[ $(arch) = arm64 ]];
then
    echo 'Detected Apple Silicon, ARM Homebrew has precedence'
    export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
else
    echo 'Detected Intel CPU architecture, Intel Homebrew has precedence'
    export PATH="/usr/local/bin:/opt/homebrew/bin:$PATH"

2.1.3. Install nvm

Node Version Manager can be installed for either the ARM or Intel compatible binaries as mentioned below:

  • ARM compatible binaries

  • Intel compatible binaries

arch -arm64 /bin/bash -c "wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash"
arch -x86_64 /bin/bash -c "wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash"

2.1.4. Install Node.js

To install Node.js execute the following command:

arch -x86_64 nvm install 18

2.1.5. Install Python

To install Python on a Mac powered by Apple Silicon, execute the following commands:

brew install pyenv
pyenv install 2.7.18
export PATH="$(pyenv root)/shims:${PATH}"
echo 'PATH=$(pyenv root)/shims:$PATH' >> ~/.zshrc
pyenv global 2.7.18

Please note, that some minimal housekeeping is required to ensure the right paths are included in the profile.

  • Apple Silicon (ARM) brew writes binaries to the following: /opt/homebrew/bin

  • Intel brew binaries are stored (as usual), in the following location: /usr/local/Homebrew/bin

  • Preference should be given to Apple Silicon binaries over Intel where possible.

Remember to export the nvm path, (this should be performed automatically by the script).

2.2. Download and extract the binary executable

Download Klayr Core.

  • Testnet

Linux:

curl -o klayr-core.tar.gz https://downloads.klayr.xyz/klayr/testnet/4.1.4/klayr-core-v4.1.4-linux-x64.tar.gz

MacOS:

curl -o klayr-core.tar.gz https://downloads.klayr.xyz/klayr/testnet/4.1.4/klayr-core-v4.1.4-darwin-x64.tar.gz

Extract and add the executable to the system path, in order to use it in the terminal:

tar -xf ./klayr-core.tar.gz
cd klayr-core
./bin/klayr-core

You can make the klayr-core command available in the PATH, e.g. by executing the following:

  • bash

  • zshrc

export PATH="$PATH:$HOME/klayr-core/bin"

To make klayr-core permanently available in the CLI, add the above snippet to ~/.bashrc.

To reload .bashrc, run the following command:

source ~/.bashrc
export PATH="$HOME/klayr-core/bin:$PATH"

To make klayr-core permanently available in the CLI, add the above snippet to ~/.zshrc.

To reload .zshrc, run the following command:

source ~/.zshrc

3. Verify successful installation

To verify that your Klayr node is up and running, execute the following command:

  • Mainnet

  • Testnet

  • Devnet

klayr-core start --network mainnet

The default log levels for Mainnet are:

"system": {
    "logLevel": "info",
},

When the node is started, the logs will be visible in the console. You can adjust the level of logging as per your preference. Supported log levels are: trace, debug, info, warn, error, and fatal. To reduce the number of logs, it is recommended to set the log levels to warn or higher.

Alternatively, start the node with the following flag:

klayr-core start --network mainnet --log=info
klayr-core start --network testnet
klayr-core start --network devnet
The passphrase for the genesis account(s) can be found here in the Klayr Core GitHub repository under the following path: config/devnet/passphrase.json.

4. Post-installation (optional)

4.1. Use pm2 to run Klayr Core in the background

It is recommended to use a process manager such as PM2 to run Klayr Core in the background.

4.2. Enable IPC & WS in the config

To make use of all the Klayr Core commands, enable IPC in the config.

Example: Enable IPC & WS via config.json
"rpc": {
    // Enable RPC communication over 'ipc' and 'ws'
    "modes": ["ipc", "ws"]

    // In case `modes` include `ws` then, the following port is used
    "port": 7887,

    // Change to 0.0.0.0 to connect from a remote server
    "host": "127.0.0.1"
},

Alternatively, start Klayr Core with the flag --api-ipc to enable IPC:

Example: Enable IPC via flag
klayr-core start --api-ipc
Please note that specifying any of the --api-ipc, --api-ws, or --api-http flags in the klayr-core start command overrides the rpc.modes settings in the config.json.

1. These recommendations are derived from the log level settings, in the event that the user needs to increase storage to prevent limited memory access and potential memory-related problems with a node. Furthermore, as more transactions are processed and added to the blockchain, the size of the blockchain increases over time and this directly affects the HDD storage requirements for a blockchain node. Hence, adhering to the above listed requirements is highly recommended.