Pay to get in

Now let’s make some coin!

Below you find a mapper contract to collect more than 0.49 ether in order to register the sender for a service. You can adjust the amount in function mapper(), of course. Once the minimum amount has been sent to the contract, the sender is registered for the service:

  • Contract accepts Ether using function() payable
  • The sender is registered by create_Member(address new_address)
  • You can send more than 0.5 ether (less is rejected and send back), but only one payment is accepted for each sender address.
  • The contract is owned
  • Only owner can get the money out with send_Ether_To_Owner()

This is very simple and Ethereum tokens offer more possibilities.

Our contract is here: 0x4f51b5bc96dc85226bd1e9510394f83a2d74bbb0

The registration will be a gateway to enter the messaging service on a private chain. You can either wait for the next blog post or send some coin already 😉


Mapper (Solidity contract)

pragma solidity ^0.4.4;
contract owned {
function owned() { owner = msg.sender; }
address owner;
modifier onlyOwner {
if (msg.sender != owner)
function kill() {
if (msg.sender == owner) suicide(owner);

contract mapper is owned {
uint32 counter;
uint256 private value;
uint256 private price;
mapping (address => address) members;
event CreateMember(address new_address);
function mapper() {
counter = 0;
value= 0;
price= 490000000000000000;
function() payable {
if ( msg.value > price && check_Address(msg.sender) == false ) {
value+= msg.value;
} else throw;
function create_Member(address new_address) private returns (bool) {
members[msg.sender]= new_address;
return true;
function send_Ether_To_Owner() onlyOwner returns (bool) {
value= 0;
return owner.send(this.balance);
function get_Counter() constant returns (uint32) {
return counter;
function get_Value() constant returns (uint256) {
return value;
function check_Address (address a) constant returns (bool) {
if (members[a] == a) return true; else return false;

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 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= 1;
uint32 counter= All_Messages[_receiver].counter;
All_Messages[_receiver].My_Messages[counter].text= _text;
All_Messages[_receiver].My_Messages[counter].sender= msg.sender;
return true;

Examples with geth console:

messenger.send_message.sendTransaction('0x53d6a48bb5374e611a497eebee146bd596c4c529','Hello! What is up?',{from: eth.accounts[2]});
"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.

Keep it simple and stupid: Digital life

One finding not only from the “theDAO” project is that complexity increases the risk of insecurity. Many lines of any code, no matter whether it is C++,  Javascript or a formal contract framework, tend to have bugs even after professional testing and auditing.

In other words: Writing code without errors or potential flaws is very hard to do. The more lines of code the harder. This is obvious you might say, but I wonder if we really take this serious enough in a world where software is part of everybody’s life and will be even more in the future. We might as well rely on big players in the market, so they will deliver e.g. secure self-driving cars and smart homes in the future as most people do today with smart phones and social media platforms.

But with more and more internet connected things to come a different approach is worth considering: Run rather decentralized digital ecosystems instead of depending on large platforms only.

While big players have plenty of resources and cash to minimize security risks, small businesses and individuals require a stable and easy to use framework where errors hardly occur and if so damage should be limited. Code and coded contracts have to be easy to unterstand and simple to use. Is this possible?


In theory:

1. Protocols and frameworks have to be robust and simple at the same time
2. A user does not need to know or understand the technology that is used but should understand the use case and the risks regarding privat assets, i. e. data and money
3. Single purpose devices and services increase security and protection of personal interest

More concrete:

1. Blockchains are solid backbones and easy uses cases like Bitcoins are proof of concept.
2. Have and easy interface: A simple Wallet App and passphrase can be handled by anyone.
3. Ideally for each purpose there are small and easy to use services operating independently. Couple them loosely and only when needed. Run private and decentralized networks.

Here is a simple use case:

– Ethereum messaging service with simple web based user interface
– Use public Blockchain for registration including setup fee
– Work with private APIs and networks for service operations

Services to add / attach:

– Location based messaging
– User management including nicknames and groups for semantic and local context
– Premium service concept

The initial idea has been published as part of a “theDAO” proposal:

Implementation is work in progress, update will follow…

Convert your DAO tokens back into ether

Here is a good explanation how to refund DAO tokens using geth, so you do not have to worry about latest mist version or post your key somewhere.

Make sure that you are running geth version 1.4.10 or later. And run your geth commands with the --support-dao-fork option so that you are on the hard-forked blockchain. By now the latest versions support hard-fork anyway. For example:
geth --support-dao-fork console

The --support-dao-fork setting is persisted between separate executions of geth, so you only have to specify this parameter once.

Confirm your geth version using
$ geth version
Version: 1.4.10-stable
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.5.1
OS: linux
geth --support-dao-fork --unlock {your account} console
Unlocking account {your account}
Passhrase: {enter your passphrase}

// Allow your blockchain to sync
> var account = "{your account}";
> var theDAOAddress = "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413";
> var theDAOWithdrawalAddress = "0xbf4ed7b27f1d666546e30d74d50d173d20bca754";
> var theDAOABIFragment = [{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"type":"function"}, {"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"type":"function"}];
> var theDAO = web3.eth.contract(theDAOABIFragment).at(theDAOAddress);
> var approve = theDAO.approve(theDAOWithdrawalAddress, theDAO.balanceOf(account), {from: account});
> eth.getTransaction(approve);

// Repeat the command above until you see that blockNumber is not null
// Wait a few blocks (~ 15 seconds each) for your approve transaction to get mined
> var theDAOWithdrawalABIFragment = [{"constant":false,"inputs":[],"name":"withdraw","outputs":[],"type":"function"}];
> var theDAOWithdrawal = web3.eth.contract(theDAOWithdrawalABIFragment).at(theDAOWithdrawalAddress);
> var withdrawal = theDAOWithdrawal.withdraw({from: account});


Run a private Ethereum testnet / blockchain

Create a Genesis file, i. e. your first block of the private chain, in your home directory e. g.
"nonce": "0x0000000000000042",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x0",
"gasLimit": "0x8000000",
"difficulty": "0x400",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333",
"alloc": {

Point geth to the  Genesis file and start your private net
geth init /home/ether_testuser/.ethereum/CustomGenesis.json
geth --identity MyPrivateNet --port 50303 --nodiscover --maxpeers 1 --networkid 925345

Now you can connect with geth attach on a different console, create a new account and start mining to get some ether
> personal.newAccount()
> miner.start()

More details regarding the geth parameters

nodiscover Use this to make sure that your node is not discoverable by people who do not manually add you. Otherwise, there is a chance that your node may be inadvertently added to a stranger’s node if they have the same genesis file and network id.
maxpeers Use maxpeers 0 if you do not want anyone else connecting to your test chain. Alternatively, you can adjust this number if you know exactly how many peers you want connecting to your private chain.


A custom name and number to identify your test network.
port Use a different port than the geth standard port in order to run a test and production net in parallel.

Connect to the testnet with the following command (insert key, ip address and port of the testnet):

geth --bootnodes enode://pubkey1@ip1:port1

See geth --help for all options.

Read More

Democratic Autonomous Organizations

When it comes to organizing issues without a clear hierachy or structure, chaos is around the corner. People cannot just make things better. They need easy to unterstand and easy to handle tools to do so. And even then not any community can improve to the greater good easily.

The big question is how a soft transformation can take place to achieve more privacy, security, democracy and usability in a digital future.

Read more: