If every trade is done on the blockchain it comes with some significant limitations: block times up to 1 minute already can be unacceptable for live betting on a tennis match. Also if Ethereum gets widely adopted gas costs might increase. Already today transaction fees of 1-3 $ cents are a significant proportion of a bet value for some micro betting applications. An app where every "tap" is equal to 50 cent bet would already suffer from the transaction fee. Another reason for off chain trading might be anonymity.
Fortunately there is a solution to this problems that does not need to compromise with trading without counterparty risk.
The abstract idea of offchain interaction can be described as a few steps and components:
- two (or more) people lock up some tokens or any state description they totally control.
- this state can only be updated on the blockchain with a signed message of all group members
- the members of the group can internally do transactions by creating a new state and letting it sign by everyone. The new state also has a nonce (sequence number)
- if members of the group stop cooperating the latest state can always be written on the blockchain
- to write the state on the blockchain anyone can submit a signed state and a small security deposit - this will trigger a challenge period. During this period a newer state (higher nonce) can be submitted, in this case the first submitter would lose its deposit.
- If a state remains unchallenged it will be written on the regular blockchain
In the case of a (prediction) market likely only two members would form such a group. They both lock up money.
Lets take an exmaple:
Locked up 100 each.
The first state would be 100ETH /100ETH . Now there is this Hillary clinton to be president event. A new state could be: 96ETH ,10HillaryYES/ 94ETH,10HillaryNO.
Note that in a prediction market the tokens of all possible outcomes in one market always have the value of 1. So the contract can issue all outcome for 1. So the new state describes that user 1 bought 10 YES shares for 4 units and user 2 bought 10 NO shares for 6 units. If this state would be submitted the contract would take the locked 200ETH and buy 10 shares of all outcomes (yes and no) of the Hillary event and than distribute the remaining money and the shares according to the state.
However - it is not necessary to submit the state to the chain. The 2 participants could do more trades or even wait until the event is resolved. Since (e.g.) Hillary is the winner the both can agree to just update the state in a way that the yes shares become ETH and the no shares are removed: (106/94).
See the implementation here: https://github.com/ConsenSys/gnosis/blob/oracle_platform/contracts/solidity/trading.sol
(sorry - for now ConsenSys members only)