Coding for NXT Crypto Platform #2

Coding for NXT Crypto Platform #2: First Steps

About Nxt

Did you ever want to participate in a financial field with your Software without taking big risks and have an easy and anonymous access to? Have you tried to access monetary systems and get transparent data from Asset Exchanges, Marketplaces, Data clouds? Nxt is a peer-to-peer Blockchain Software that allows a global financial service that you can use on your server or computer. No registration, no bureaucracy.

What does the Nxt Blockchain bring to the table that is new?

In traditional banking systems you encounter ‘trusted’ banks which manage your money and holdings for you as a service. But when you want to access your money they do not make it easy for you. Especially as a developer, there is no chance you can retrieve the data of holdings or have access to the historical Wall Street data for free.

With the peer-to-peer blockchain system Nxt has started to build a whole ecosystem around secure and transparent data handling. You can start your own services, create currencies, create assets and trade them, a built-in marketplace, data cloud and much more!

Getting started

With the following lines of code I would like to demonstrate how to get a first access to Nxt data and then show you how to write on the blockchain and get some data ready for your homepage.

From there you could start building everything you can imagine around the Blockchain, Account Ledger and featured tools.

If you have not installed it yet, see here how to install and configure Nxt to start developing.

“Hello World”

In this example, we are choosing the most basic setup which lets you display data from the Blockchain on your website.

We will use JQuery to simplify the API call but you can achieve the same results with other frameworks or a bit more code.

Let us create the first html file, we call it transaction.html and insert the following code into it.

<div id="result"></div>
<script src=""></script>
      $.getJSON('http://localhost:7876/nxt', {"requestType": "getTransaction", "transaction": "8520011591947303971"}, function(request) 

Nxt has a very helpful API documentation that is addressable on http://localhost:7876/test. We are using the getTransaction call in this example, which you can also test on the API page.

When running the script above, you should see the following response in your Browser:

Hello World
Congratulations! You have received the first data from the blockchain

But what happened here?

First, we have used the API call “getTransaction” which allows us to have a detailed look at information of any transaction that is on the Blockchain. Have a look at your browser console to see the whole transaction information.

In the above code, we have accessed the market output of the JSON response the Nxt API gave us. Here you can see the whole object returned from the API.

                            "senderPublicKey": "7969c2ec61af9bedd3260c9b2cd4a292ba01ecbc2901a86851fa6c68208b0766",
                            "signature": "d13ad29034e56ae58b7f1eee4979cd6dffff38a7a26094c86103e431faf0bd06084be1e42534efd8e76b8a59c12630b52d851c571a25bc54af9ebdb56ca6df14",
                            "feeNQT": "100000000",
                            "requestProcessingTime": 0,
                            "type": 0,
                            "fullHash": "23bc3ae466293d7690b426173445e5b87423ea798b1d9c2913feda5d0d52a5b6",
                            "version": 1,
                            "phased": false,
                            "ecBlockId": "15499194118663359315",
                            "signatureHash": "9ea43451798a0144bd6cea58cbbba479c24ed7cdc29a4077a9aeb49a063498a7",
                            "attachment": {
                                "version.Message": 1,
                                "messageIsText": true,
                                "message": "Hello World",
                                "version.OrdinaryPayment": 0
                            "senderRS": "NXT-5RB8-KJD3-BT3B-E2QWW",
                            "subtype": 0,
                            "amountNQT": "10000000000",
                            "sender": "14876164227056393510",
                            "recipientRS": "NXT-P439-YVBD-VUEQ-A3S2T",
                            "recipient": "10124938546868029479",
                            "ecBlockHeight": 614717,
                            "deadline": 1440,
                            "transaction": "8520011591947303971",
                            "timestamp": 67508752,
                            "height": 2147483647

Why use getJSON?

As we have been using the getJSON function of Jquery, we do not need to parse the JSON anymore and can directly access JSON the Nxt API returns. When using an ajax call or get method of Jquery, you might need to JSON.parse(request) in order to access the object.

The transaction 8520011591947303971 we have accessed in the code, was a transaction I have previously sent. Every transaction within Nxt is transparent and for everybody to see. Have a look at the returned JSON from the Nxt API and with your script at hand you can already display all the information you are interested in from any transaction.

Replace the request.attachment.message (with for example request.accountRS) to display the account ID and continue with adding a nice view to the information.

In the following articles, I will show you how to submit the first data on the blockchain. How to retrieve data from Assets, calculate prices and see running orders.

Reaching for the stars

Nxt supports you in creating computer Software that allows trading on a global space in a peer-to-peer network where every participant is equal in power. Start building awesome things with Nxt.

Read the next article in this series > …

More in this series:
Coding for NXT Crypto Platform #1: Configuration

Also see:

2 thoughts on “Coding for NXT Crypto Platform #2

  1. Read the next article in this series > …

    this link is incorrect.
    the same with other articles of this series.
    you forgot to change these when moved from the original resource

Leave a Comment