Setting up your workstation

This first guide will walk you through a step-by-step installation of the required tools to start developing on NEM.

Note

⚠️ NEM’s next core engine, code-named Catapult, is under development. This bootstrap setup is for learning and development purposes, and it should not power any production Catapult instances.

Running Catapult Service Bootstrap

You are going to run a private chain for learning purposes using Catapult Service Bootstrap. This service runs Catapult server instances and Catapult REST nodes locally.

  1. Make sure you have docker and docker-compose installed before running the following commands:
git clone https://github.com/tech-bureau/catapult-service-bootstrap.git
cd catapult-service-bootstrap
docker-compose up

Note

Is catapult service bootstrap not working? Check these troubleshooting tips.

  1. Check if you can get the first block information:
curl localhost:3000/block/1

Getting a test account

An account is a key pair (private and public key) associated to a mutable state stored in the NEM blockchain. In other words, you have a deposit box on the blockchain, which only you can modify with your key pair. As the name suggests, the private key has to be kept secret at all times. Anyone with access to the private key, ultimately has control over the account.

The public key is cryptographically derived from the private key. It would take millions of years to do the reverse process and therefore, the public key is safe to be shared.

Finally, the account address is generated with the public key, following the NEM blockchain protocol. Share this address instead of the public key, as it contains more information, such as a validity check or which network it uses (public, testnet or private).

NEM2-CLI conveniently allows you to perform the most commonly used commands from your terminal i.e. using it to interact with the blockchain, setting up an account, sending funds, etc.

  1. Install NEM2-CLI using npm.
sudo npm install --global nem2-cli
  1. Open a terminal, and go to the directory where you have download Catapult Bootstrap Service.
cd  build/generated-addresses/
cat addresses.yaml
  1. Under the section nemesis_addresses, you will find the key pairs which contain cat.currency. Every action on the blockchain costs cat.currency units, in order to provide an incentive for those who validate and secure the network.
  2. Load the first account as a profile in NEM2-CLI.
nem2-cli profile create

Introduce network type (MIJIN_TEST, MIJIN, MAIN_NET, TEST_NET): MIJIN_TEST
Introduce your private key: 41************************************************************FF
Introduce NEM 2 Node URL. (Example: http://localhost:3000): http://localhost:3000
Insert profile name (blank means default and it could overwrite the previous profile):

You should see the following lines in your terminal, containing the account credentials:

New Account:    SCVG35-ZSPMYP-L2POZQ-JGSVEG-RYOJ3V-BNIU3U-N2E6

Public Key:     33E0...6ED

Private Key:    41....FF

Setting up the development environment

It is time to choose a programming language. Pick the one you feel most comfortable with, or follow your project requirements.

Create a folder for your new project and run the instructions for the selected language.

  1. Create a package.json file. The minimum required Node.js version is 8.9.X.
npm init
  1. Install nem2-sdk and rxjs library.
npm install nem2-sdk rxjs
  1. nem2-sdk is built with TypeScript language. It is recommended to use TypeScript instead of JavaScript when building applications for NEM blockchain.

Make sure you have at least version 2.5.X installed.

sudo npm install --global typescript
typescript --version
  1. Use ts-node to execute TypeScript files with node.
sudo npm install --global ts-node
  1. Create a package.json file. The minimum required Node.js version is 8.9.X.
npm init
  1. Install nem2-sdk and rxjs library.
npm install nem2-sdk rxjs

Continue: Writing your first application.