Prediction markets as a modular framework¶
Our modular framework aims to provide the foundational protocol upon which projects using prediction markets can grow. In this section we describe the different layers that compose the prediction markets framework.
Discovering data in ethereum is complex or potentially even impossible depending on the use case. The “standard way” to query bulk data in ethereum is through filters this is very convenient for discovering ERC20 tx’s during a certain period, or the creation of a Multisig contract through a certain factory, but imagine you want something more complex. For instance, what if you wanted to obtain all markets created by a certain ethereum address that use a specific token. To get this information, you will need to get all MarketCreation events and then query all the relations: Market -> Event -> Oracle -> IPFS
In practice this is
O(n^4) and with many P2P network connections, it might work with a few values. But as soon as you create markets, it will be unusable.
For this reason we have created an Ethereum Indexer called TradingDB. It’s a micro-service Python project that queries ethereum nodes and allows powerful queries to be run in milliseconds.
This is the basic architecture:
pm-js is the middleware between the Smart Contracts and your program. It abstracts away some of the logic related to prediction markets and adds some useful features like validation.
You can directly use the contracts with web3, and it could be more intuitive for you but will be harder to perform buy and sell operations. Also, web3 won’t validate your parameters. So it is important to exercise caution with the values you use or there will be many failing transactions.
The Smart Contracts are designed in a modular manner in order to make it easy to integrate with different Ethereum projects and extend their functionality. For example, you could use Gnosis Smart Contracts for all trading functionalities and use Augur as an Oracle by extending the Oracle interface and build a Smart Contract Adapter.
The main components are described in this blog post.