Setting up your workstation

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

Running a private test network

To run the network, we are going to use the package Catapult Service Bootstrap. This software suite contains the necessary setup scripts to quickly build your own test network.

Note

Catapult’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.

Environment requirements

Installation

  1. Use this link to download the latest release of the package, or clone the repository directly using Git.
git clone https://github.com/tech-bureau/catapult-service-bootstrap.git --branch 0.9.0.1
  1. Open the catapult-service-bootstrap folder.
cd catapult-service-bootstrap
  1. Run the network.
./cmds/start-all

Note

To run the docker containers in the background of your terminal, you can run the service in detached mode using the option --detach or -d.

Verify that the node is running by opening a new browser tab with the following URL: localhost:3000/chain/height.

To stop the process, press Ctrl+C.

Getting a test account

An account is a deposit box where you can hold mosaics (tokens) and interact with them by announcing transactions.

After running the catapult-service-bootstrap tool for the first time, the available currency supply is distributed between a generated set of accounts. To keep one of these accounts quickly retrievable, we are going to store one of them using a command-line tool to conveniently perform the most commonly used actions i.e. interact with the blockchain, setting up an account, sending funds, etc.

  1. Install NEM2-CLI.
npm install --global nem2-cli@0.14.0
  1. Open a new terminal window. Then, go to the directory where the bootstrap tool has generated the addresses.
cd  build/generated-addresses/
  1. Display the content of the addresses.yaml file.
cat addresses.yaml
  1. Under the section nemesis_addresses, you will find the key pairs which contain cat.currency. Copy the private key of the first account.
  2. Type the command nem2-cli profile create using the key obtained in the previous step.
nem2-cli profile create

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

Note

Use NEM2-CLI only for testing and development purposes, as the private keys stored are not encrypted.

You should see the account credentials in your terminal.

Profile stored correctly
┌─────────────┬──────────────────────────────────────────────────────────────────┐
│ Property    │ Value                                                            │
├─────────────┼──────────────────────────────────────────────────────────────────┤
│ Address     │ SCVG35-ZSPMYP-L2POZQ-JGSVEG-RYOJ3V-BNIU3U-N2E6                   │
├─────────────┼──────────────────────────────────────────────────────────────────┤
│ Public Key  │ 654***321                                                        │
├─────────────┼──────────────────────────────────────────────────────────────────┤
│ Private Key │ 123***456                                                        │
└─────────────┴──────────────────────────────────────────────────────────────────┘

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. On the other hand, you can share securely the public and address of your account with other participants of the network to receive transactions from them.

Creating a project

Now that you have your account filled with cat.currency units, it is the time to choose a programming language. Pick the one you feel most comfortable with, or follow your project requirements.

Then, create a folder for your new project and run the instructions for the selected language. If none of the languages fits your project, you can always query the blockchain directly using the REST gateway.

  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@0.15.0 rxjs
  1. We recommend to use TypeScript instead of JavaScript when building applications for Catapult.

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@0.15.0 rxjs
  1. Open a new Java gradle project. The minimum JDK version is JDK 8. Use your favourite IDE or create a project from the command line.
gradle init --type java-application
  1. Edit build.gradle to use Maven central repository.
repositories {
    mavenCentral()
}
  1. Add nem2-sdk as a dependency.
dependencies {
    compile "compile 'io.nem:sdk-vertx-client:0.14.2"
}
  1. Execute gradle build and gradle run to run your program.

Continue: Writing your first application.