Mobile users first – Logical Application Architecture

1. User Interface (UI) has to be easy and straight forward, taking a mobile App for now.

  • The UI allows simple registration for services
  • Mobile App provides cryptocurrency and tokens for transactions

2. Cryptocurrencies and blockchains run in the background, it has to be mainstream and future proof at the same time.

  • With purchase and download of the mobile App the user is provisioned to use the backend services
  • User does not need to know about technical details

3. Transactions will be general purpose, starting with personal text messages. It can be anything in the future: e. g. appointments, contracts, receipts

  • First use case will be text messages
  • Text can be used to model anything
  • Words make contracts after all

4. Decentralisation promotes scalability and security, no central platform approach.

  • Only a minimum of central features will be used
  • Store personal data encrypted and / or on local device only

Consider the 4 headlines above you will get a secure Messaging App that allows anonymous and secure transactions at the same time. For any message or any transaction only the involved parties, e.g. sender and receiver or buyer and seller interact based on an encrypted protocol using local internet servers.

From a user’s point of view it is very similar to talking to someone and making a deal or purchase as part of the conversation. The main difference in the end is a simple smart contract using blockchain technology in order to  make a reliable transaction.

Of course, the App is also capable of interacting with internet connected devices. Once you send appropriate coins locks could open or prepaid services become available after you have identified with a matching digital signature.

To make it easy for starters: As part of the App download you get the first coins for transactions. A marketplace is part of the App to ensure some use cases for trying our services. Some critical mass is needed in your neighbourhood to have continuous value add:

  • Secure messaging with friends and people nearby
  • Easy cashless micropayment
  • Reliable transactions without central platforms being involved

That is worth recommending the App to a friend, is it not?

Ethereum application recipe

Ingredients for one application

1 Ethereum node

1 private Ethereum node

1 node-js server application

1 public web server

1 private web server

1 public Mapper contract

1 private Messaging contract

Preparation

Set up one server machine to run the two Ethereum nodes with two different users, one for the live blockchain and one for the private blockchain.

The blockchains allow remote procedure call (RPC) connections from localhost only. The node-js application and the private web server run on the same machine.

The node-js application uses RPC calls to interacts with the public and private Ethereum instances. Get the two smart contracts ready:

Prepare a public web server on another maschine to interconnect with the private web server. The latter is only a proxy to forward requests to the node-js application.

Cooking for a simple demo application, no scaling

Once payment is received by the Mapper contract on the live blockchain the paying Ethereum address can register with the public web server in order to get a messaging account on the private blockchain.

Methods are mapped from the public web server to the private web server, which can only be accessed by the public web server using either IP address restriction or a virtual private network (VPN).

For starters we offer the following services

/register
Parameters
address that paid to Mapper contract
Returns
address that is from now available on the private messaging Ethereum network

/send_message
Parameters
address that receives the message
text message to send
Returns
boolean

/get_inbox
Parameters
address of inbox
Returns
number of messages
text of latest message

/get_message
Parameters
address of inbox
number of message to get
Returns
text of message
address of sender

Find below the logical application architecture

ethereum

Message in an Ethereum nutshell

Simplicity and security

Find below a simple contract in order to implement a messaging service. There is no security implemented since this shall run with a private blockchain and optionally on a Virtual Private Network (VPN).  This way the contract remains simple, this is a proof of concept only anyway, and in times of Distributed Denial of Service (DDoS) with Internet of Things (IOT) devices  we would rather secure the transport layer.

So, with more and more devices connected to the internet a decentralization of networks makes sense.  We plan to use the public Ethereum blockchain only for registration and payment purposes. Once a token for usage has beed issued messaging users move on to a private backbone.

Messenger (Solidity contract)

you-have-a-message-2

You can run the contract as is. On creation a “Hello World” message is delivered to the contract owner. For every message sent an event is triggered.

contract messenger {
struct Message {
address sender;
string text;
}
struct Messages {
uint32 counter;
mapping (uint32 => Message) My_Messages;
}
mapping (address => Messages) All_Messages;
event Message_sent(address _receiver);
function messenger () {
All_Messages[msg.sender].counter= 1;
All_Messages[msg.sender].My_Messages[1].sender= msg.sender;
// send first message to creator
All_Messages[msg.sender].My_Messages[1].text= 'Hello World';
}
function get_latest_message(address _receiver) constant returns (string) {
uint32 counter= All_Messages[_receiver].counter;
return All_Messages[_receiver].My_Messages[counter].text;
}
function get_message(address _receiver, uint32 index) constant returns (string) {
return All_Messages[_receiver].My_Messages[index].text;
}
function get_sender(address _receiver, uint32 index) constant returns (address) {
return All_Messages[_receiver].My_Messages[index].sender;
}
function get_counter(address _receiver) constant returns (uint32) {
return All_Messages[_receiver].counter;
}
function send_message(address _receiver, string _text) returns (bool) {
if (All_Messages[_receiver].counter > 0)
All_Messages[_receiver].counter++;
else
All_Messages[_receiver].counter= 1;
uint32 counter= All_Messages[_receiver].counter;
All_Messages[_receiver].My_Messages[counter].text= _text;
All_Messages[_receiver].My_Messages[counter].sender= msg.sender;
Message_sent(_receiver);
return true;
}
}

Examples with geth console:


messenger.send_message.sendTransaction('0x53d6a48bb5374e611a497eebee146bd596c4c529','Hello! What is up?',{from: eth.accounts[2]});
...
messenger.get_counter('0x53d6a48bb5374e611a497eebee146bd596c4c529');
8
messenger.get_latest_message('0x53d6a48bb5374e611a497eebee146bd596c4c529');
"Hello! What is up?"

I am sure this can be improved (feel free to do so), but we want to keep it simple…

To be continued.