Prediction Market architecture Part 2

Back-end and Front-end solution

In our Prediction Markets first part, we described solidity contracts structure. The full article can be found here: https://medium.com/aigang-network/prediction-market-architecture-part-1-40756bc358bb

In this part, I want to show all mechanics which will run under the hood of nice UI.

First of all, about used Domain language:

Prediction — is a statement about a future event. In prediction market are stored a lot of predictions with user forecasts.

Forecast — is a user selected outcome in prediction with tokens amount.

Outcomes — a list of outcomes available in prediction for users to choose.

Oracle — contract or API which will know prediction result at the end time.

Basic functionality for users who wants to forecast:

Prediction list and details
Forecast action

In this flow, a casual mechanic is happening. User sign into system, comes to prediction list, selects prediction, reads all details, choose what outcome he selects and submit selected amount for his forecast. Then our system tracks user transaction and updates statistics. As a returning user will get current prediction summary with some statistics.

Our newly introduced Aigang.TransactionListener service will work like this:

  • Listens to our database where user transactions will be stored
  • Monitors Ethereum blockchain to check transaction status
  • When status becomes successful service will take some actions by transaction type:
    If the transaction was ForecastAdd: updates user forecast and update prediction stats.
    Other transactions types will handle differently.

Users will be able to see all forecasts with statuses which they predicted and take some actions on them:

User withdraw flow

On new prediction Creation process:

New prediction creation

User decides prediction question, decides initial prediction prize, configures end and start dates, Oracle type with rules how to read result and predefine prediction outputs. We are planning to have few oracle types: Ethereum contracts stored value oracle, public API stored value. In the future, we will be able to have oracles which can take data from other blockchains.

After prediction is submitted and an initial balance is transferred in first PM version manual review will start, and if a prediction is configured correctly prediction will be submitted to blockchain and starts to accept forecasts. Later when we standardise oracle input configurations this procedure will be eliminated and predictions will be stored automatically.

Most important service will be Aigang.PredictionResolver:

Prediction resolver

Prediction resolver will listen to predictions database and at the end time request oracle for the result. After result will be known and set in our prediction market profit distribution for participants and member scores calculation will follow.

To serve prediction markets, User profile will be extended with user used wallets and transactions in all platform.

Wallets and Transactions history