Setting up your workstation

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

We will be using the test network, which uses the same technology and features of the future main public network. You can use the testnet to experiment with the offered Catapult’s transaction set in a live network without the loss of valuable assets.

Creating an account

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

  1. Install NEM2-CLI.
npm install --global nem2-cli

Note

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

  1. Generate a new account and save it as a profile.
nem2-cli account generate

Introduce network type (MIJIN_TEST, MIJIN, MAIN_NET, TEST_NET): TEST_NET
Do you want to save the account? [y/n]: y
Introduce NEM 2 Node URL. (Example: http://localhost:3000): http://api-harvest-20.us-west-1.nemtech.network:3000
Insert the profile name: testnet
Do you want to set the account as the default profile? [y/n]: y

Note

If the test network node is not working, you can use another node url from this list. You can also run your testnet node by following this guide.

  1. You should see the account credentials in your terminal.
Profile stored correctly
┌─────────────┬──────────────────────────────────────────────────────────────────┐
│ Property    │ Value                                                            │
├─────────────┼──────────────────────────────────────────────────────────────────┤
│ Address     │ TCVQ2R-XKJQKH-4RJZWG-DARWJ6-V4J4W7-F4DGH6-ZFAB                   │
├─────────────┼──────────────────────────────────────────────────────────────────┤
│ Public Key  │ 203...C0A                                                        │
├─────────────┼──────────────────────────────────────────────────────────────────┤
│ Private Key │ AAA...AAA                                                        │
└─────────────┴──────────────────────────────────────────────────────────────────┘

Getting test currency

To announce a transaction, the sender should pay a fee to provide an incentive to those who validate and secure the network and run the infrastructure. This cost is paid in nem.xem mosaics, the default network currency of the public network.

Now that you have created your first account, try to request nem.xem units from the testnet faucet. Navigate here, indicate the amount of nem.xem you want to receive and the address, and click “CLAIM!”.

../_images/faucet.png

Note

If the default faucet is empty, try this other alternative faucet.

After the transaction gets confirmed, check if the account has received nem.xem using the command-line tool.

nem2-cli account info  --profile testnet

Balance Information
┌──────────────────┬─────────────────┬─────────────────┬───────────────────┐
│ Mosaic Id        │ Relative Amount │ Absolute Amount │ Expiration Height │
├──────────────────┼─────────────────┼─────────────────┼───────────────────┤
│ 75AF035421401EF0 │ 750.0           │ 750000000       | Never             │
└──────────────────┴─────────────────┴─────────────────┴───────────────────┘

Note

The faucet has a limited amount of nem.xem and must be replenished before it dries. If you don’t need your test nem.xem units anymore, please send them back to the account TAPEQM-ZKSSHR-S36JCZ-KBCIB2-QM6QZT-BGWDJZ-GNQW.

Creating a project

Now that you have your account filled with nem.xem 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 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 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.16.0"
}
  1. Execute gradle build and gradle run to run your program.

Continue: Writing your first application.