Static Type Safety for DApps without JavaScript

DApps, starting professionally…

You might not be aware, but despite its similarities to JavaScript, Solidity is actually a statically, strongly typed language, more similar to Java than to JavaScript.

solidity
static type check in browsersolidity

…and ending in frontend-chaos

Sadly, for a long time, there has only be one interface to Ethereum nodes, web3.js (besides JSON/RPC), which is, as its name implies, written in JavaScript.

Though providing this API in a web-native language is really a brilliant idea in terms of fast development, seperation of concerns and ease of use, it is a nightmare for professional, multi-developer, multi-year, enterprise products.

You may not agree with me here, but as there are currently no 10 year old 1.000.000 LoC enterprise projects in node.js/JavaScript out there, you should at least consider that such projects are nearly impossible to maintain with a dynamically, weakly typed language like JavaScript (JS).

So, we have this situation, where JS defines the lowest common denominator (dynamically, weakly typed

JavaScript_1 (2)

when we really would like to have this situation, where Java (C#, Haskell) defines the lowest common denominator (statically, strongly typed)

JavaScript_2 (2)

Removing chaos

The problem is was, that up to now only web3.js existed. However, today there is also a web3.py (which is Python and therefore at least strongly typed, but still dynamically) and, brandnew, web3j.

With the latter, we can easily model the call chain above, where we only use statically, strongly typed Java and omit JavaScript altogether. Welcome to hassle-free integration into existing Java/JEE-environments without workarounds. Finally: using the Ethereum Blockchain with Java.

If you want to actually get deeper and use Java with no RPC at all, you can also switch to EthereumJ, which is a Ethereum Node implemented in Java, like Eth (C++), Geth (Go), PyEthApp (Python) or Parity (Rust). It is crucial to understand the difference between web3j and EthereumJ. If you just want to use some Ethereum Node from a Java application, web3j is your choice, you are limited to the Web DApp API then, which should be enough for all “Ethereum user” use cases.

We will not explain in detail how to use web3j, it should be familiar to any Java developer how this library can be used just by adding Maven-dependencies to your project.

Fixing the front-end

We could stop here, since using JavaScript for the frontend is not really problematic and a common use today.

However, if you use JavaScript in your frontend, it might really make more sense to stay with web3.js. So, we want to go further: how are we going to create the GUI if we want to have no JavaScript at all?

This is just a PoC, but if you think of any other client to the Ethereum Blockchain other than a web site (let’s say: Batchjobs, Web Services, Message Queues, Databases, other proprietary software with Java adapters (there are some!)), this should make sense to you – you really wouldn’t want to use them from web3.js (hopefully).

Using templates: Thymeleaf and Spring Boot for slim enterprisy software

We will do a step-by-step guide for creating a No-JS-Dapp. Even without any Java experience, you will be able to follow without problems. Java is not that complicated anymore!

  • Get an infura.io account and key, so you don’t have to mess around with starting your own Ethereum node
  • Clone this repo: https://hellokoding.com/spring-boot-hello-world-example-with-thymeleaf/
  • Install Maven
  • Edit these files:

    pom.xml (add these dependency to section dependencies and add the repo, beware that web3j is a fast moving target, check for new versions)

    <dependency>
    <groupId>org.web3j</groupId>
    <artifactId>core</artifactId>
    <version>0.2.0</version>
    </dependency>

 

<repositories>
<repository>
<id>oss.jfrog.org</id>
<url>http://dl.bintray.com/web3j/maven</url>
</repository>
</repositories>

src/main/resources/templates/hello.html (change name to balance.html)

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8"/>
<title>Your Static Strongly Typed Wallet</title>
</head>
<body>
<p th:text="'The balance of account ' + ${address} + ' is ' + ${balance}" />
</body>
</html>

src/main/java/com/hellokoding/springboot/HelloController.java (change name to EthereumController.java)

@Controller
public class EthereumController {

@RequestMapping("/balance")
public String balance(Model model, @RequestParam(value="address", required=false, defaultValue="0xe1f0a3D696031E1F8ae7823581BB38C600aFF2BE") String address) throws IOException {
Web3j web3 = Web3j.build(new HttpService("https://consensysnet.infura.io/{YOUR_INFURA_KEY}"));
EthGetBalance web3ClientVersion = web3.ethGetBalance(address, DefaultBlockParameter.valueOf("latest")).send();
String balance = web3ClientVersion.getBalance().toString();
model.addAttribute("address", address);
model.addAttribute("balance", balance);
return "balance";
}

}

…that’s it. Start with mvn spring-boot:run

If you encounter an connection/handshake error, you may have to import the infura certificate into your local Java keystore (I didn’t have to)

$JAVA_HOME/Contents/Home/jre/bin/keytool -import -noprompt -trustcacerts -alias morden.infura.io -file ~/Downloads/morden.infura.io -keystore $JAVA_HOME/Contents/Home/jre/lib/security/cacerts -storepass changeit

Look Ma! Displaying the wallet balance with no JavaScript!

You can call the spring-boot web application with http://localhost:8080/balance (then the defined default argument is used) or with your address (in the consensys testnet) as parameter address= 

walletOf course, you can change the Ethereum net like you want in file EthereumController to morden or mainnet, just read the welcome mail from infura.io. Or you can just use a local Ethereum node like geth with RPC enabled (geth –rpc) and http://localhost:8545 as the constructor for HttpService of the Web3j-Factory in EthereumController.

Have fun, with or without JavaScript!

Steem – community building and social interaction with cryptocurrency rewards

This week I came across Steem and I instantly got sucked into it. In this post am trying to summarize what I learned about it so far. 

You can think of Steem as a Facebook-like platform where authors and curators can earn cryptocurrency rewards by writing posts, up-voting posts, commenting on posts and up-voting comments.

To understand how this process works, first of all we need to understand the currencies circulating in this process. According to the whitepaper we have:

Steem – the fundamental unit of account on the Steem blockchain. All other tokens derive their value from the value of STEEM. Generally speaking STEEM should be held for short periods of time when liquidity is needed. Someone looking to enter or exit the Steem platform will have to buy or sell STEEM. Once STEEM has been purchased it should be converted into Steem Power (SP) or Steem Dollar (SMD) to mitigate the impact of dilution over the long-term (100% inflation annually). 

Steem Power (SP) – Steem can be instantly converted to Steem Power. It is a long-term investment and can only be converted back to Steem via 104 weekly payments over a period of 2 years. This long-term commitment gives the owner two advantages:

  1. the user can participate on the platform by voting or posting articles/comments. This is rewarded by more Steem Power (SP) and Steem Dollars (SMD). How much everyone gets, depends on his Steem Power and the voting algorithm.
  2. The inflation is not 100% anymore like with Steem, but only ~10% per year because for every 1 Steem generated as reward, 9 new Steem are distributed among Steem Power holders. If the platform grows faster than the inflation, investors make a win, otherwise they’ll be losing money.
 

Steem Dollar (SMD) – represents a number of Steem tokens having a value of ~1 USD. It can be used to trade goods/services with the stability of the USD. SMD pays holders interest (currently 10% per year). The interest rate is set by the same people who publish the price feed so that it can adapt to changing market conditions.

The two main reward mechanisms in Steem are curation and author rewards. Both are equally important in Steem.

Author Rewards are gained by posting articles that are upvoted by others. Curation Awards are gained by early upvoting articles that grow popular later. The rewards are payed out in Steem Power and Steem Dollars. In general the more Steem Power someone holds, the more weight his vote has. If one of developers is upvoting a post, it can instantly bring more than $100 value to the post. A new account on the other side with ~3 Steem Power will only bring a fraction of a cent. The final value of a post is distributed among the author and curators depending on how early they participated in the voting process and how much Steem Power their accounts hold.

The money for the reward pool is coming from the inflation. Instead of taking a tax on existing accounts for generating the reward pools, the protocol generates continuously new Steem where 1 is going to the reward pool and  9 are redistributed to Steem Power holders. This basically results in a ~10% inflation annually.

Lot of people are asking the question if this model is sustainable. One could expect that the model can only be profitable as long as more investors are jumping in. At the moment where supply gets greater than demand the whole system could break together like a Ponzi-Schema. This could be very painful for late-adoptors because of the 2 year payout mechanism. One of the main critical voices claiming that Steem is actually scam is Tone Vays.

My personal impression so far is that this could be the first DLT application with good user experience and the potential to go viral. It reminds me a little bit on 2007 and the gold rush with the AppStore. At the time of writing this post, the platform has around 70k accounts.

Try it yourself at https://steemit.com or read more about it at https://steem.io. Currently every new account gets Steem Power worth ~$4 for free.

Further reading:

 

KW 33 – Weekly Blockchainers Recap

The number of blockchain news post is growing exponentially. Nearly every company or government does some research projects based on blockchain and DLT technologies. Let’s try to filter the stuff wich could be interesting for us blockchainers.  

Last year I saw a well written paper from the world economy forum about fintechs. This year they published “The future of financial infrastructure” witch focused on blockchain. The paper describes in detail a set of financial use  cases and how they can be improved using blockchain tech. It’s one of the best papers we have seen so far. 

The next big thing is Raiden from Heiko Hees. See also International Business Timer. Every time you discuss the opportunities of blockchain and smart contracts with business people, very soon they come up with the scalability issue. Based on my IT project experience, I can tell that there is always a solution for every performance issue. Heiko’s Raiden is the solution for Ethereum.

Finally we have to mention Steem – a blockchain database that supports community building and social interaction with cryptocurrency rewards. You can think of it as Facebook/Reddit like Plattform where content contributors and content curators are monetary rewarded for their work. It is questionable if the model is sustainable or not, anyway it’s the first application of the DLT tech with a nice front-end and with the potential to go viral. 

Create your own Oracle with Ethereum Studio and oraclize.it

This is a follow-up post to Gambling with Oracles and describes the technical part for the implementation of an Oracle with oraclize.it

People told us last time that we had not really created an binary option. This might be true and to not confuse the reader and also to introduce just another cool use case and link to current events, we are going to bet on the winner of the EURO 2016 soccer championship.

As you see from the posting date, the championship is already finished and the winner is well known, it is Portugal.

So we can just create a static Oracle to make things easier, we will define the Oracle call in our betting contract and on calling update(), the winner will be determined, which is the static json {“winner”: “portugal”}.

You can call bet(winner) with exactly 1 ETH and on calling claim() you will get nothing or (loseBets + winBets) / (numberOfParticipantsWhoBetOnWinner), eg. 3+2/2 = 2.5

BettingOracle1

Prerequisites

You will need to sign up for the ether.camp Studio and check out the corresponding github project in the terminal, follow the instructions in the README.

Starting the Oracle

After starting the web server, you can access the “Oracle” with https://yourid.by.ether.camp:8080/web/euro2016winner.json which redirects to the file web/eu2016winner.json in your project.

You can test the data retrieval in the Studio, just choose the Oraclize tab, Test query, “URL” and put json(…).winner around the URL.

oracle1

That’s it, by clicking “Test” you should get the result “portugal”. So now the Oracle Smart Contract can call your Oracle datasource and submit the result via callback to your contract.

oraclizeObviously, a real Oracle should be a little more dynamic, but for testing purposes this Oracle is enough. You can change the answer by stopping the web server, changing the file manually and restarting the server.

To avoid duplicating information here, please consult the documentation for the ether.camp Studio IDE for actual usage of the sandbox. Remember to give enough value (at least 0.1 Ether in Wei: 100000000000000000) for the update() call, but also 1 Ether in Wei (1000000000000000000) for the bet()-calls, otherwise it will not work.

Deploying the betting contract to Morden

The contract.sol contains the complete contract, it imports some helper classes and the oraclize-API, which, depending on the deployed environment, is instantiated with the corresponding contract address.

In the README you will see the local environment sample, but also the Morden example. To deploy the contract to the testnet Morden, you will have to get Ether first, which is really simple in Morden

Note: you have to set the networkID to Morden in the constructor of the contract before deploying:

 function FinalWinner() {
oraclize_setNetwork(networkID_morden);
}

send2morden

After deploying, you can click on the Transaction-Hash in the Transaction-Tab, which automatically opens the deployed contract in morden.ether.camp.

To be able to invoke the contract in ether.camp, you will have to upload the sources of the contract, however, there is a problem with inline assembly at the time of writing this post. Therefore we added a special file (for-upload-to-ether-camp-morden-as-source-only.sol-not.executable) for uploading in the root of the github-project, this contract is just for this purpose and is not executable.

In Morden, each call should be done with value 1 Ether, the bet-calls will throw; otherwise and the update call needs some for the call of Oraclize, which costs Ether for each call (consult pricing on oraclize.it).

Distributing Business Processes using Finite State Machines in the Blockchain

Having disctinct, even competing organisations with a common goal and no shared technical infrastructure represent a perfect use case pattern for blockchain usage.

The quest for the holy business use case

As many blockchain enthusiasts we are constantly searching for use cases for establishing Distributed Ledger Technology (DLT) or even real blockchain technology in enterprises as solutions for common business problems.

21666276190_40647d8327_z
[Business *]

This turns out to be difficult, since each single aspect of this technology is already solved by several – established and well known – products. 

In this post we will present a use case, or even a use case pattern, which we think is ubiquitous and can best be solved by blockchain technology.

For these type of use cases the other technologies, even though being more mature, seem themselves like workarounds for the natural technological solution, which is blockchain-based.

Our definition is the use case pattern is:

Several distinct, competing organisations have a common goal and don't share technical infrastructure.

distinct, even competing organisations

Distinct organisations are not related to each other and therefore have no existing technical or organisational processes. To pursue a common goal, these processes would have to be established first, which is costly and time-consuming.

5882566863_ce0ccf745d_z
[Competing teams *]

The second aspect, competition, implies that there is no mutual trust. Obviously, this aspect is a crucial one. Blockchain technology might even make sense if just the other aspects of the pattern match, but it only is a perfect fit if this aspect is important, since the blockchain itself is inherently trust-less.

common goal

This is the fundamental requirement, if there is no common goal, there is no need to establish any collaboration. It is important to note, that the common goal is most likely not related to the core competence of the organisations, but to some crosscutting concerns, which have to be addressed by all organisations, but are just cost factors.

no existing shared technical infrastructure

To put it contrary: if there already exists a shared technical infrastructure, also organisational processes exist to establish new technology. Given this, there are several great technology products which implement each aspect of the blockchain technology (namely distributed data storage, immutability, security), and most likely even more performant, more mature, with less maintenance and evident responsibilities.

Ok, this is quite abstract and complex, let’s find an easy example.

…want a securities account with your new account?

There is one universal retail bank, FriendlyBank, which wants people to open accounts. And there are three deposit banks, FriendlyDeposit, EasyDeposit and NiceDeposit. There is also the Regulator, who must be able to audit all transactions between the parties.

Requirement

common goal: make money

The common goal of universal and deposit banks is to open accounts. The universal bank can be intermediary to deposit account opening, so you can open a securities account at one of the three deposit banks with your new account at FriendlyBank. This way, it is a win-win-situation for both parties, the intermediary gets commissions, the deposit banks get new customers.

FriendlyBank and FriendlyDeposit are related to each other, they have the same ownership structure, but are separated entities. Since the deposit banks are in competition with each other, the other deposit banks besides FriendlyBank want to be sure that not very valuable customers are transferred to FriendlyDeposit or the deposit account opening is “accidentally forgotten”, if not FriendlyDeposit is chosen.
Since the parties do not really trust each other, a trust-less (ie. no trust necessary) solution is needed.

the wonderful world of finance IT today

As we said, the depicted scenario exists quite often. Also, technical “solutions” for these scenarios exist.

They look similar to this one:

Flatfilesolution_crop

We wan’t go in detail what all this means, but to become trust-less, as well as assure that the data is in sync in each organisation, a lot has to be implemented and still, shortcomings of these solutions are quite common:

  • reconciliation processes are always necessary, but still, due to missing transaction support in flat file exchange, which is almost always chosen as the “simplest” integration pattern, errors occur.
  • adapters have to be built for each party, so there will soon exist a many-to-many problem.
  • special adapters have to be built for regulators.
  • crosscutting concerns have to be implemented: security, authentication, auditing, transaction support

Compared to a natural solution in the blockchain

Below is the blockchain solution, it fits naturally and implements all requirements.bcsample

Abstracting from the use case

Why is this solution matching so well, what is the pattern “behind”?

Different actors change the state of a business process on some event in a transactional way.

2645030_8e2b2269
[Old cigarette machine *]

You certainly know this pattern, it is describing a finite state machine, more exactly a distributed, secured by cryptoeconomics finite state machine, which events are transactions.

After all, the blockchain itself is a state transition system, it somes quite naturally to implement a simple state machine on the Ethereum EVM, it even is mentioned as a common pattern in the Solidity docs.

 

Approaching the finite state machine

How would the organisations collaborate? This could look like this informally:

 

process_v1

or like this (more) formally:

Blockchainsolution_FSM

so we actually can built this state machine and its transitions really easy using the blockchain, here in pseudo-Solidity, derived from the common pattern in the Solidity docs:

contract AccountDepositStateMachine {
enum Stages { Init, AccountOpened, DepositOpened, DepositConfirmed, AccountConfirmed } Stages public stage = Stages.Init; modifier atStage(Stages _stage) { if (stage != _stage) throw; _ } function nextStage() internal { stage = Stages(uint(stage) + 1); } // Order of the modifiers matters here! function openAccount() atStage(Stages.Init)
transitionNext
{ if (msg.sender != FRIENDLY_BANK) throw; } function openDeposit() atStage(Stages.AccountOpened)
transitionNext
{
if (msg.sender != FRIENDLY_BANK) throw;
}
function confirmDeposit()
atStage(Stages.DepositOpened)
transitionNext
{
if (msg.sender != DEPOSIT_BANK) throw;
}
modifier transitionNext() { _ nextStage(); } }

Great, so that’s it, we can build any business process using the blockchain, QED.

Leaving the ivory tower

As you might guess, it is not that simple. Let’s review the actual process:

  1. Account is opened 
  2. Deposit Account is opened
  3. Deposit Confirmed
  4. Account Confirmed

Ever saw an IT-process in real life? Exactly, it’s not like this, not even close. Let’s see a more real life example:

  1. Account is opened
  2. An Email is send to whoever feels responsible
  3. The Product Owner’s Excel has to be updated
  4. The new reporting engine must have its data updated, it is runnig with MongoDB, which has to be updated
  5. Revision wants to have it’s auditing data in their Oracle DB (must use 2PC)
  6. … (ok, you got it already…)

None of the tasks in bold red can be accomplished from the Ethereum blockchain, since calls from “inside” to “outside” are prohibited. Let’s hope this will never change, the separation of “inside” and “outside” is essential for the stability and security of the Ethereum blockchain

We could use Oracles for this, but it would be a kind of usage which is highly inappropriate for this type of external information retrieval.

Teaser: “Mastering the Flow: Blending Reality with the Blockchain”

This post is way too long already, so here comes a teaser for two posts next to come: “Mastering the Flow: Blending Reality with the Blockchain”

The idea is really simple: let’s just recentralize the business process (we are in eager anticipation for the comments to come…)

But we think this can make sense. Look at the sample above, illustrated as a flow:

nodered

The flow was created with Node-RED, an excellent and highly undervalued tool of IBM Emerging Technologies for flows in IoT. It could be very easily adapted to Ethereum with smart contract access by usage of web3.js, which itself can be integrated in node.js, which is the basis of Node-RED, hence the name.

We make the following assertion:

More than 80% of all use cases can be realized by a centralized business process engine as a first layer, eg. implemented in Node-RED, and a state machine implemented in the blockchain as a second layer

The business process engine is the glue between the transactional blockchain state transitions and the secondary business processes.

What do you think of it? Please let us know in the comments, we really appreciate feedback, positive or negative.

And stay tuned for the next episode, we will get to the nitty-gritty there.

images:
[Business] Business by Christophe BENOIT under CC
[Competing teams] Competing teams by Denis De Mesmaeker under CC
[Old cigarette machine] Old cigarette machine by Walter Baxter under CC

The Golden Private Blockchain Use Case 

During the last months we have seen a lot of press releases about blockchain projects everywhere, but only few of them are more then just experiments. We also saw many notes about private blockchains as a solution for enterprises. Private blockchains are a good story for consultant companies and their skin deep powerpoint writers with expensive cufflinks. However, we haven’t seen good use cases yet in all these power point slides, just repeating arguments and sales stories. So where is the real private blockchain killer application? More or less every problem addressed by private blockchains can be solved with already existing technologies and software architecture patterns. 
 
Most IT system in enterprises follow the centralized architecture paradigm, e.g.: 
a) MDM (Master Data Management), data from different sources will be collected and consolidated in central databases, then the data will be processed, checked etc. with some algorithms or human interactions and at the end the data will be distributed to different target business applications.
b) Central BPM (Business Process Management) systems will be triggered by an event, it pulls some data from other sources, process them, generate reports, trigger new events etc. 
 

centralsystems.001

  
We can continue and continue to all the different other centralized systems and architecture pattern. We build centralized solutions, because we learned centralized architectures are good, however, in decentralized or silo organizations it is difficult to establish such structures. In this kind of organizational structure, we find very often poorly organized data exchanged via Excel and emails. BPM solutions perform poorly too due to the fact that it is difficult to establish and enforce exactly specified business processes. 
 
Central systems also ignore circumstances of local data aspects, not all data has the same importance for all business applications, very often you need individual data and data rules for single data consuming business app. 
 
How DLT (distributed ledger technologies) and smart contracts instead could help to integrate applications in a decentralized/silo organization where centralized architectures break on the organizational structure?
 
In a DLT-based solution there is no central system. Every business application is equal and can participate in the P2P network by contributing or consuming data from the distributed ledger. How an application contributes or how it consumes data is a local decision of the application itself. For instance, if it needs a specific frontend, it can be implemented in the context of the specific application in need of it.  
central systems2.002
 
This is a new software architecture paradigm which could lead to better scalability, less redundancies and lightweight integration of applications in technologically and organizationally decentralized environments. 
 
Relevant Articles:
 

KW 25 – Weekly Blockchainers Recap

Swenden Land Registry
One of the first serious ideas to use blockchains and smart contracts was the land registry use case. We heard about projects in Greece and Honduras. Now Sweden do some research, it has high potential to show the applicability of this approach. 

more projects
During the last weeks we saw more and more interesting Blockchain activities.
Polish Gouvernance 
Dutch Central Bank 
Kazakhstan Central Bank 
– ……
It seems more or less every institution works on this technology. 

KW 24 – Weekly Blockchainers Recap

The DAO under attack 
Today it was a really importand day for the DAO and Ethereum. The DAO was hacked and everything looks a little bit like the Mt.Gox horror. The positiv view of this event is, the community works fast and constructive on this exception. At the moment not all facts are on the table, but it looks like the situation is under control. 

IMG_2016-06-17 21:08:48

See also the reddit thread for this event. 
Ethereum is not the DOA, but the trust in Ether as a currency was reduced.  

Allianz Blockchain experiments 
The German Insurance bets on blockchain for catastrophe bond trading. It sounds macabre and logical. It should only be used with institutional customers, nothing for retail customers. 

 

 

 

 

Gambling with Oracles

[casino kurhaus*]
[casino kurhaus*]

 

How to create a provably-fair high risk financial product with live data feeds provided by oracles.

Introducing Binary Options

This time, we gonna gamble. We will construct a financial product, more specifcally: a binary option, European style, cash-or-nothing.

[binary*]

Binary options are “a type of option in which the payoff is structured to be either a fixed amount of compensation if the option expires in the money, or nothing at all if the option expires out of the money” [1], therefore cash-or-nothing. European style means the option “can only be exercised at the end of its life, at its maturity” [2].

This is a high risk product which is “most likely traded over the Internet on platforms existing outside of regulations” [1], so “the customer is betting against the broker, who is acting as a bucket shop.” [3]

In general, this means that “because these platforms operate outside of regulations, investors are at greater risk of fraud” [1] and “manipulation of price data to cause customers to lose is common” [1].

BinaryOption (3)So, in contrast to common regulated financial products we have a really comprehensible option, which is mostly valued as high-risk, because there is a real clash of interests if the broker also evaluates the stock against the strike price and thus is highly motivated to manipulate this evaluation.

Smart Contracts to the Rescue

So, can smart contracts help here? You bet! The blockchain is trust-less, so you just don’t have to trust anyone, be it broker or bucket shop or both, but you can just prove if everything’s ok.

If a smart contract guarantees you that you will get 195% if you predict correctly and 0% if not, this rule has to be implemented in the contract.

Meeting the Oracle

Given that we can trust the contract, it should be easy to implement a binary option like this:

After deploying the contract, you have 1 hour to invest Ether on calls or puts on the contracts conditions (eg. DAX is above the strike price in 1 hour). After the 1 hour offering period, it's rien ne va plus, no purchase of calls or puts are possible. At this point of time, the current value of the DAX is stored. After exactly 1 hour the DAX is evaluated against the stored DAX value.
  • if the value is above or equal to the stored value, all calls are returned 195% of their investment, all puts lose all invested money
  • if the value is below the stored value, all puts are returned 195% of their investment, all calls lose all invested money

Sounds simple? It is!

[oracle*]
[oracle*]

You can easily prove that the contract actually implements the described rules, but there are two problems: how does the contract know the DAX spot? Contracts in Ethereum intentionally cannot connect to the outside world, therefore the outside world has to call the contract and provide the necessary data. Who tells the contract the exact time it has to retrieve the DAX spot? There must be some callback mechanism, since Ethereum smart contracts are not able to call themselves, have a Daemon, Threading etc.

Let’s gonna oraclize.it

There is a startup solving this problems in a elegant way: oraclize.it

You should look up and understand how oraclize.it works and helps us to solve our problems. In short, callbacks are used by oraclize.it and you can determine the exact data feed of the data which oraclize.it will provide at a certain point of time to our contract.BinaryOptionOrale (1)Here the two problems are addressed:

  1. The contract has to provide a callback for the oracle to call. The data feed is configured when the callback is provided, as well as the time interval.
  2. The oracle facilitates a scheduling to call the provided smart contract callback at the configured time interval.

Both solutions require the user and the contract owner to actually trust the “trusted datasource” (the contract’s user can decide if he trusts this datasource) and the oracle itself to have a working scheduling and not to manipulate the data. In contrast to the “broker” above, the oracle has no interest in manipulating the data.

However, oraclize.it not only offers a service, but even more defines a protocol, so there will most likely be more than one oracle to choose from to offer redundancy in the future.

Building Binary Options in Ethereum Studio

…in the next post.

Realizing how long this post already is, we decided to split the tutorial and the theoretical part. The tutorial will follow soon! Please let us know in the comments if you’d like to have this tutorial and what you expect of it.

Meanwhile, try out this ether.camp tutorial which describes the integration of oraclize.it into Ethereum Studio.

images:
[casino kurhaus] Kurhaus Casino by fr4dd under CC
[binary] binary by christine592 under CC
[
oracle] Oracle by Bob Doran under CC

icons:
icons made by Freepik from www.flaticon.com 

KW 22 – Weekly Blockchainers Recap

R3 Ethereum Review 
R3 published an Ethereum review, written by Vitalik Buterin. In the managed summary written by the R3 CTO, he highlights the challenges of Ethereum for financial marked requirements. From our perspective it just emphasizes the fact that one blockchain concept doesn’t fit all requirements. Ethereum has the first mover advantage for smart contracts development and DApps, like Bitcoin for crypto currencies, both is unstoppable.

Santander Introduce Blockchain Technology for International Payments
Most institutes still discuss the Blockchain like the car industry the electric engines. Santander UK starts with international payment based on blockchain. The Santander solution works with Ripple (!!!), it works well for this kind of use cases. During the last months, with everybody looking at Ethereum, it’s a good idea to look little bit more left and right.

First salary offers for Blockchain developers
As there are almost all institutes of the financial service industry, but also companies from health care, real estate and music, evaluating the blockchain and starting first proof-of-concepts, it becomes obvious that there is a huge demand meeting a real scarcity of developers, with probably “…less than 100 true blockchain experts in the world”.
Obviously, this mismatch raises the salary offers, and the first official offers are about $250.000 at Wall Street (free German Jaxenter-Post).
So, if the blockchain still doesn’t impress you, here’s one argument more for dealing with it more closely in the future.