Do-It-Yourself Real-Time Prediction Market With Streamr

What is the most powerful prediction engine in the world? A crystal ball? A deep neural network? The human brain? The collective brainpower of mankind?

The collective wisdom of the crowd (including algorithms too) can produce unbeatable future estimates of asset values, sports outcomes, and presidential elections. Prediction markets attempt to capture this wisdom by creating a mechanism in which probabilities emerge as a result of collective betting. This is similar to how company valuations emerge on the stock market as the result of collective bidding. Both phenomena are based on the efficient-market hypothesis. For an entertaining exploration of the ideas, “The Wisdom of Crowds” by James Surowiecki is very much worth reading.

To realize the relationship between betting and prediction markets, consider a simple betting game with only two possible outcomes: “up” or “down”. Say, you witness a situation where many bets have already been placed, and 90% of the bets are on “up” and only 10% on “down”. Which would you consider the much more likely outcome?

In the blockchain space, projects such as Augur and Gnosis are building decentralized prediction markets based on Ethereum. Inspired by these, we wanted to build a real-time version which leverages our data platform and the visual editor. The demo is based on the streaming real-time ETH/USD price feed from GDAX, an Ethereum smart contract to hold bets and handle payouts, and a Streamr canvas which keeps track of the prediction rounds. It also acts as an oracle, calculating the correct outcome and reporting it to the smart contract.

In the demo, participants can predict ETH/USD price changes 5 minutes into the future. This is a simple game where the binary outcome is either “up” or “down”. Submitting predictions for a round closes 5 minutes before the resolution. To incentivize correct predictions and disincentivize incorrect ones, players place bets in ether to back their predictions. Bets placed on the incorrect outcome are distributed to the winners in proportion of the bets.

Obviously, the distribution of bets will only give meaningful predictions on a market with enough liquidity (players), which our little demo may not have at all times. 🙂

This example works in the Rinkeby testnet. The chart below, embedded from the Streamr canvas, shows the recent ETH/USD price and the outcomes of the most recent 5 min prediction rounds. The demo is live and interactive. Enter your bet in ETH, and press either the “up” or “down” button to lay your (crypto)money down!

In case the betting controls are not visible, your browser is not blockchain-enabled. Try the Metamask plugin for Chrome, or Mist, and get some test ETH from the Rinkeby faucet or by asking someone on our Slack.

In order to interact with this demo, you need a blockchain-enabled browser. Install the Metamask Chrome Extension or download Mist.

Please change to the Rinkeby testnet to interact with this demo.

Time remaining to place bets:

Predict Up
 Predict Down

You bet {{amount}} on {{guess}}.
 Resolves in .
 Outcome was: {{outcome}}

Confirmed bets

UP: mining..

 DOWN: mining..

You received {{amount}} ETH!

The payout logic is coded to this smart contract which is called by the Streamr canvas that calculates the correct outcomes and drives the above chart. An embedded view of the canvas is shown below (open it in full screen or in the editor).

Questions and comments about this post and Streamr in general are appreciated! Join us on Slack, and of course feel free to follow us on Twitter as well.

Stay up to date

Get the latest Streamr news and articles delivered to your inbox