project screenshot 1
project screenshot 2
project screenshot 3

Decl Prediction Mrkt

A very simply prediction market implementation on using Essential's declarative smart contracts.

Decl Prediction Mrkt

Created At

ETHGlobal San Francisco

Project Description

Essential smart contracts are declarative, meaning that you only define the constraints that state transitions must satisfy rather than the details of how those state transitions are accomplished. This project defines a system with Users, Oracles, and Markets. Each User is controlled by its creator and has a balance and can bet on Markets. An Oracle is controlled by its creator, starts unresolved, and can become resolved as true or false at any time (but stays resolved once resolved). A Market is not controlled by anyone, but is linked to an Oracle upon creation. When the Market is unresolved, then any user can bet on either the true or false outcome of the Market. When the Oracle resolves, then the Market resolves, and the money bet on the Market is distributed only to the winning bettors. All of this happens only within the contracts system, so no actual tokens are being transferred (that would be for future work). I also made a simplifying assumption that only two bettors (one for true and one for false) can bet on a Market. I was able to model the entire system in the Pint smart contract, but I was not able to finish writing all of the Rust interactions for testing it.

How it's Made

Please note that I forked the Essential example integrations repository, and my contributions are only in the apps/prediction-market sub-directory.

I used the basic setup that Essential recommends -- the contracts are written in Pint, and the interactions are written in Rust using the setup demonstrated in the essential-integration/apps examples. In particular, the Rust implements two things: the library for reflecting interactions with the contract, and a test suite that uses the library to test scripted sequences of interactions.

background image mobile

Join the mailing list

Get the latest news and updates