Introduction
Futurecast is an ethereum based decentralized prediction market where users can participate in different ways and earn rewards.
Users can participate in three ways:
- By creating a market — Market makers
- By staking on an outcome — Stakers/Voters
- By reporting on an outcome — Reporters/Validators
Any user can create a post where they can put the question description, options(from 2 to 5), start time, betting end time & event end time.
Phases
A market proceeds through 4 phases; these phases are explained as follows:
- Betting Phase: As the name suggests, people bet or stake on an outcome that they believe is true or most likely to occur. To facilitate change in opinion as time goes on due to changing circumstances, a participant who has already staked in this phase on a particular outcome can change his/her outcome.
- Inactive Phase: In this phase, all functions are disabled in a market. This phase occurs during the event time. For example, if a market for a particular football match exists, the inactive phase represents the match's duration.
- Reporting Phase: In this phase, people again stake on the right outcome after an event represented by a market concludes. There aren’t any fees associated with this phase. Hence this is a phase that can give maximum profit to the participants.
- Resolved Phase: When the reporting phase ends with a clear outcome, a market is said to be resolved. All funds locked in a market are available to be redeemed. The payouts of all the participants are determined by the payout formula (mentioned in the doc)
Smart contracts
We have a factory contract. As a user fills a form to post the question, a new Question contract is deployed, which holds all the information related to this specific market. The factory contract holds the deployed addresses of all questions, while the question contract decides the phases for each market and distributes rewards. As the question contracts hold the ETH, it stakes the money to increase all users' benefits.
Front-end
Following is our stack:
- React
- SASS for styling
- Web3 for connecting to Blockchain
- Matic for deploying our Smart Contracts
- Netlify for Continous Deployment
Challenges we faced
The ideation process:
After coming up with a decentralized prediction market, we studied the existing implementations and how they handle various problems. There were two main problems that we faced:
- The first of them was how to reach the correct answer to a particular question. We read that some decentralized markets have a centralized entity that is involved. As we focused on true decentralization, we decided to ask from our network and add a reporting phase in the timeline.
- The second major hurdle was deciding on an algorithm for distributing the rewards. We explored several formulas that Augur and other markets use to reward users. After spending so much time on it, we came up with a simple scheme. We added a platform fee that increases with time(more details in this document) and encourages users to participate early.
Integrating Decentology:
As we started the hackathon, we instantly tried to build something and test it. But we ran into several issues while using the Decentology’s Dappstarter application itself, so we quickly switched to a basic hardhat setup and started our dev process.
Time-based testing:
There are certain functionalities in our project that can only be tested when significant time has elapsed. As we were using ganache-CLI, we found necessary articles on medium to elapsed time. It took us some time to make a function that can elapse time for us.
Integrating with front-end:
As we were making our app compatible with different browsers, we faced minor issues. From the start, we integrated our application with Metamask, which was complicated, as we need to resolve some web3 instance issues in the browser. Portis integration was relatively easy and didn’t take much time.
Future possibilities
- Integrate external staking on Compound or AAVE or external staking managers
- Add a server to make the web application faster
- Store user info on IPFS
For more information:
- Github: https://github.com/codeDcode-2021
- Hackathon submission: https://devfolio.co/submissions/futurecast-212f
- Live deployment on Mumbai Matic: https://futureforecast.netlify.app/