Skip to content
prediction market on lotionjs with tendermint
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

prediction market

market phase

  1. open new market
  2. allow bet
  3. someone bets (record them)
  4. market closes (by time)

oracle phase

condition to enter phase: time

  1. get data from oracle
  2. determine the result and record it

condition to end phase: time

challenge phase

condition to enter phase: time, someone triggers it

  1. someone stake their coin and challenges

condition to end phase: time

vote phase

condition to enter phase: challenge phase completed

  1. anyone can stake their coin and vote

condition to end phase: time

distribute phase

condition to enter phase: time

  1. determine the final outcome
if (challenged)
  update the final outcome according to voting results
  distributed the staked coins in voting pool according to voting results.
distribute betting pool coins according to outcome

condition to end phase: when everything in the phase is executed


the time of the phase is indicated by block height. since we have finality, the phase start and stop block can be next to each other. in other ledger that lacks finality, we should reserve more time (several blocks) between each phase.


node app.js

test invocation:

it is possible to do test invocation using curl. however, you will need to supply signature yourself.
it is recommended to use test/testCommon.js complexSendTx(), which will handle the signature, public key (pubkey), and sequence.

for example of test invocation, please see test/testIntegrate2.js

if you need to if you need to send a transaction manually, you need to supply from.pubkey, from.signature, from.sequence, and to. the format is as follows.

curl -X POST http://localhost:3000/txs -d '{"type": "verifySig", "from": { "pubkey": "rewlkjrlw", "signature": "rewlkajrlewk", "sequence": 0 }, "to": {} }'

all of the tx will need from and to. however, for brevity purpose, they are omitted in the following calls:

curl -X POST http://localhost:3000/txs -d '{"type": "start", "marketId": "market2", "startInfo": ...}'

example startInfo:

  "startInfo": {
      "question": "Who will win FIFA 2018?",
      "outcomes": [
      "oracle": ["9x2yu6AzwWphm3j6h9pTaJh63h5ioG8RL","5wvwWgKP3Qfw1akQoXWg4NtKmzx5v4dTj"], // addresses of approved oracles
      // meta data about oracle.  eg. description
      "oracleMeta": "",

curl -X POST http://localhost:3000/txs -d '{"type": "bet", "marketId": "market2", "outcome": 1, "amount": 10, "user": "5wvwWgKP3Qfw1akQoXWg4NtKmzx5v4dTj"}'

curl -X POST http://localhost:3000/txs -d '{"type": "bet", "marketId": "market2", "outcome": 2, "amount": 10, "user": "9x2yu6AzwWphm3j6h9pTaJh63h5ioG8RL"}'

curl -X POST http://localhost:3000/txs -d '{"type": "oracle", "marketId": "market2", "outcome": 2}'

curl -X POST http://localhost:3000/txs -d '{"type": "challenge", "marketId": "market2", "user": "5wvwWgKP3Qfw1akQoXWg4NtKmzx5v4dTj", "amount": 100}'

curl -X POST http://localhost:3000/txs -d '{"type": "vote", "marketId": "market2", "user": "5wvwWgKP3Qfw1akQoXWg4NtKmzx5v4dTj", "amount": 1000, "outcome": 1}'

curl -X POST http://localhost:3000/txs -d '{"type": "vote", "marketId": "market2", "user": "9x2yu6AzwWphm3j6h9pTaJh63h5ioG8RL", "amount": 10, "outcome": 2}'

curl -X POST http://localhost:3000/txs -d '{"type": "vote", "marketId": "market2", "user": "9x2yu6AzwWphm3j6h9pTaJh63h5ioG8RL", "amount": 1000, "outcome": 1}'

curl -X POST http://localhost:3000/txs -d '{"type": "distribute", "marketId": "market2"}'

for example of sending token to another address, see test/testSend.js for example of tx format.


You can’t perform that action at this time.