If you’ve been craving to start playing with some blockchain stuff right away, NEM has made it possible. Without slow synchronizations, smart contracts and complex transactions processing, NEM steps out from the old blockchain designs and provides a new blockchain engine out of the box.

NEM’s vision is based on the idea: keep the application logic in your enterprise systems and just store the immutable state on the blockchain. Businesses show great interest in this idea because they can keep their old systems and just execute the results on the NEM blockchain. There is no need for reprogramming the same logic into smart contracts for the blockchain to run. Also, the logic is the part that changes and upgrades. NEM figures out that putting that code on the blockchain is not really a benefit. What should not be alerted are the final results. The current asset state, the values, the supply and the transfers are just some examples that should go in the NEM blockchain.

Everything on NEM is API based. So how do we integrate it and what do we use? The core feature of the NEM blockchain are little pieces called smart assets. They are transferable and configurable. Using the smart assets feature we can model our real world assets in the blockchain. Then we can plug the model into our existing systems and use the API calls to work with blockchain values about these assets.

NEM has many other features and built-in services that help the execution. We will talk about some of them, presenting a simple case of creating a Logistic application that transfers parcels from a manufacturer to a shipping company. This application will be modeled in NanoWallet, but the same calls can be used in your custom web or mobile application.

Creating test accounts

First, we’ll create a few simple wallet accounts on the NEM’s Testnet using NanoWallet. The wallet application can be downloaded here. NanoWallet generates your pair of private and public key. After entering the password for the account, you will get a yourwallet.wlt file which contains your private key. The file is encrypted with your password. If you want to use your account on another computer you will have to import wallet file there. For the example we show, we have created the following addresses:

Ben: TDU2WHFROXKHDNN7KC7JJPCZGOZBEHK3BMMX73QG

Alice: TAWBDV2SYFB2FKINCSLADX4KEL4JHRXMZVVE7NGI

Tom: TDWSWXMPHQGM7CHN3OYGIF6WBSG5WJGD2JGPNZBJ

ShipmentCompany: TD3ABMAHLE5IGUT2AAF7XXPVVPRZ62VU3BUHC4IP

Note that on the Testnet addresses start with “T”. There is also the Mainnet which is the real NEM network. Addresses there start with ’N’. We won’t be using that one for now.

The second wallet type: “A private key wallet” can only be created if you already have a private key for a previously created NEM address.

Getting test XEMs

XEM is the native currency of the NEM public blockchain. It is used to pay for transactions on NEM’s public blockchain for incentivizing the nodes. Because we are working on the test network, we have to obtain some test XEMs in order to do any kind of transaction. There are a couple of faucet websites that usually can be drained. The best way that worked for us was applying to this forum.

Namespaces and mosaics

The namespace is the root of all asset types we are going to create. One namespace can also be seen as one domain name of the application we manage on the blockchain. Namespaces give rise to a unique naming convention, like defining a class and subclasses. The subclasses, in this case are, are the subnamespaces. To create a namespace we need to pay 100 XEM for the root namespace and 10 XEM for every subnamespace. Namespaces are unique and each belongs to one user. The creator of the namespace can create as many subdomains as she wants. The conventions is that they are separated by a dot: “namespace.subnamespace”.

Mosaics, on the other hand, represent the smart assets. They can be seen as real objects that belong to a specific namespace or subnamespace. They have quantity, description and can be transferred between the users on the network.

Creating and transferring smart assets

Let’s say that Alice, Bob, and Tom are manufacturers that transfer parcels to a shipping company. Using Alice’s account we create a namespace called “parcel”. The root namespace is usually the first thing you must create. You will also notice that all transactions on the NEM blockchain require a small fee. The NanoWallet shows the fee and automatically adds it to the transaction.

When a new transaction is created and delivered to a node, the node puts the transaction into its unconfirmed transaction cache and broadcasts it to other nodes. NEM’s algorithm produces blocks with an average time of 60 seconds. Sometimes you will see the transaction getting confirmed in just a few seconds.

Next, we can create two subnamespaces called “ExpressDelivery” and “StandardDelivery”. The parent namespace should, of course, be the parcel.

Then we can continue to the mosaics. One mosaic can be called large-package. We set the initial supply to 30 and select the mutable supply checkbox. That means that the supply changes up and down in the future. We also allow divisibility, because the 30 packages can be split and sent in different period and shipping orders. In the end, the transferable option means the mosaic is transferableto another user and we set it on. There is a small additional fee for sending a message with our transaction. In our case the message shows the size of the large package.