Getting Started

We are going to explain the minimum steps to have a prediction market deployed on a testnet and be able to interact with it through our trading interface.

Create the market

git clone
cd pm-scripts
npm i

You need to modify conf/config.json and use an ethereum account you own which has ether. check the rinkeby faucet

You can use this config:

   "accountCredential":"man math near range escape holiday monitor fat general legend garden resist",

Please note that we are using a TEST ACCOUNT in the example above. Don’t use this account specified above with real funds or in production. Create another account for yourself with metamask, ganache-cli or any available ethereum wallet provider

You can use the example market pm-scripts/examples/categoricalMarket.json or modify its content. Be careful with the date format. Otherwise it won’t be indexed by the backend service.

Run the creation command:

npm run deploy -- -m examples/categoricalMarket.json -w 1e18

This will create all the contracts related to a prediction market, wrap ether for you and fund the market with the WETH.

Follow the instructions that pm-script prompts in the console until the end.

Run the Ethereum Indexer

There are many ways to run our ethereum indexer (trading-db) but let’s start with the basic one.

Download the project:

git clone
cd pm-trading-db
docker-compose up

This will install all the dependencies and orchestrate the different docker containers declared in docker-compose.yml

It will take a few minutes to complete, depending on your network connection and computer resources.

Finally you will have the service running and a web server listening on http://localhost:8000/ , you can see here the documentation of the different endpoints that our trading interface uses.

By default the indexer points to the rinkeby network through Infura nodes. Indexing a full chain can take a few hours consuming all nodes resources, but we don’t need to index all of the blockchain. We just need the indexing to start since the block which includes our prediction market contracts.

If you created the market just now, you can substract a few blocks from the current block. Go to etherscan substract 100 blocks (that’s around 20min of blocks) and execute:

docker-compose run web python setup --start-block-number <your-block-number>

This will start the indexing of the rinkeby chain and should take a few seconds. You should now see your market indexed in http://localhost:8000/api/markets/

Note: the default configuration points to infura and is very light in terms of performance so the service is not rate limited. For production settings, use DJANGO_SETTINGS_MODULE=config.settings.production

Setup the interface

The trading-ui interface offers a generic interface to interact with prediction markets and is intended to be used as the starting point which can be extended for your use case. Let’s start downloading and installing the project:

git clone
cd pm-trading-ui
docker-compose build --force-rm

Now the interface is already functional, but we need to configure it with our ethereum account as a whitelisted account, in order to show the markets in the interface. Let’s build the config template:

docker-compose run web npm run build-config

open the file dist/config.json with your favourite text editor and change whiteslist: {} for something like this:

whitelist: {
    "operator": "<your-ethereum-address>"

Now everything is set, you can run the interface and start buying shares on your first prediction market! run docker-compose up and open your browser at http://localhost:5000