Developer tutorial 1: Installing Moracle and testing a resolver.

Jackson
Moracle Network
Published in
3 min readNov 26, 2019

If you have any trouble following this tutorial or have feedback, feel free to reach out to me on Discord: Jax#4739

In this article, you will learn how to install Moracle on your local machine and run a Lisk custom app that uses it. We’ll be working with this repo:

This tutorial assumes you’re using a UNIX-like environment. These commands should be familiar to anyone using macOS or a Linux distribution. If you’re on Windows 10 and are interested in Lisk SDK development I highly recommend you install and use Windows Subsystem for Linux.

Additionally, you must have everything required to run the Lisk SDK installed (node, Postgres, etc.). I recommend following Lisk’s “Hello World Tutorial” to get set up with the dependencies: https://lisk.io/documentation/lisk-sdk/tutorials/hello-world.html

Step 1: Cloning the installing dependencies.

Once you have node and postgres installed, run the following from the directory of your choice:

git clone https://github.com/MoracleNetwork/Moracle-Lisk
cd moracle && npm i
cd ..
cd lisksdk-test && npm i

Step 2: Compiling Moracle’s TypeScript and setting up the database

Open a new terminal, and cd into Moracle-Lisk/moracle and run

tsc -w

And let this run in the background.

Then, run the following query against the PostgreSQL database you set up during Lisk’s Hello World Tutorial.

drop database moracle; create database moracle;
drop database lisk_dev; create database lisk_dev;

Update Moracle-Lisk/moracle/ormconfig.js with your database’s information.

Now, install TypeORM globally and create Moracle’s database tables.

npm i -g typeorm
typeorm migration:run

Make sure you run the second command from the Moracle-Lisk/moracle folder. You should see output that looks like this:

Step 3: Running the app!

You should now have 3 terminals: one for the TypeScript compiler in watch mode, and two that are currently doing nothing.

In the first free terminal, cd into Moracle-Lisk/moracle and run:

node built/resolver-processing/test.js

and you should see the output saved to db.

Now, you can run Moracle itself:

node built/index --localhost

and you should see:

Moracle HTTP API listening on 127.0.0.1:7892!

Now, you can start the Lisk SDK custom app:

cd Moracle-Lisk/lisksdk-test/src
node index | npx bunyan -o short

Step 4: Testing a resolver.

cd Moracle-Lisk/lisksdk-test/src/testing-clientsnode client.js | tee >(curl -X POST -H "Content-Type: application/json" -d @- localhost:4000/api/transactions)

This will generate and send a WeatherTransaction which takes a latitude and longitude, and then stores the current temperature at the time of the transaction in an account’s assets.

Now, navigate to http://localhost:4000/api/accounts?address=16313739661670634666L.

If you see the currentTemp has been added to asset, it means Moracle is working! Try playing around with client.js and different latitudes/longitudes to see it in action.

COMING SOON: Developer tutorial 2: Creating your own Moracle resolver.

--

--