Predicty McPredictionFace: Dapp, Dapper, Dappst! – Predicty McPredictionFace:Dapp,Dapper,Dappst!区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,Predicty McPredictionFace: Dapp, Dapper, Dappst! – Predicty McPredictionFace:Dapp,Dapper,Dappst!区块链毕设代写 是一篇很好的国外资料

Predicty McPredictionFace: Dapp, Dapper, Dappst!

This repo hosts my final project submission for the ConsenSys Blockchain Developer Online Bootcamp (2020 edition). Watch the screen recording walking through my Dapp here.

Predicty McPredictionFace: Dapp, Dapper, Dappst! - Predicty McPredictionFace:Dapp,Dapper,Dappst!

What is Predicty McPredictionFace?

Predicty McPredictionFace is a Solidity smart contract implementation of a prediction market that allows crypto and defi enthousiasts alike to predict the future USD value of ETH on an hourly time frame. The fundamental idea behind a prediction market is simple: it allows market participants to predict the outcome of an event and get rewarded if they are correct. When enough players participate, the prediction market can sum the opinions of the many and capture the “wisdom of the crowd”, which can provide accurate forecasts and information in social and economic matters such as (digital) asset prices, politics, sports, etc. In order to showcase this, the frontend of Predicty McPredictionFace will continually display the total bet distribution of all players in the prediction market at any point in time.

Why Predicty McPredictionFace?

Centralized prediction markets suffer a few drawbacks that reduce their overall effectiveness:

  • Trust: betting stakes are transferred to a central custodian and there is limited (if any) visibility on who else participated in the market, as well as their betting positions
  • Cost: high transaction fees are often charged on market entry and reward distribution

Predicty McPredictionFace instead aims to offer a fair, decentralized, and open finance prediction market for hourly ETH/USD price prediction, settlement and reward distribution:

  • On-chain decentralized prediction market by means of a deployed smart contract, instead of a central intermediary
  • Instant position staking, instead of low liquidity order books
  • Instant rewards and short market cycles (hourly) means that players do not need to lock in their funds for long durations and are able to claim their rewards, as soon as a prediction market result is out
  • A ChainLink oracle pricefeed for the ETH/USD price is leveraged to create and settle prediction markets automatically
  • Players are incentivized to perform new market creation and existing market settlement transactions to keep the prediction market cycle running and decentralized

Solution overview

Market creation

The contract owner creates the first prediction market round by deploying the smart contract. A new prediction market with a name like “What will be the price of ETH/USD at Mon, 23 Nov 2020 22:00:00 GMT ?” will be created, which allows players to stake ETH to predict the future USD value of ETH at the specified time. After the initial market has been settled, the market settlement page will display a button to create a new prediction market. While this market creation button is displayed, any willing player can sign the market creation transaction to create the next hourly prediction market. The player who clicked the button first, will be able to claim a market creation reward. Unlike other prediction markets, where markets are created by “market writers” or “option writers”, Predicty McPredictionFace disintermediates the need for such writers, by replacing them with a smart contract and player incentives.

Market length

  • Market start time = the time when a market becomes live and players can take positions in the prediction options that are offered.
  • Prediction expire time = the time when a market is no longer accepting predictions and is no longer live (awaiting closure to distribute rewards).
  • Market settlement time = the time when the market closes and the winning option can be declared based on the ChainLink oracle pricefeed input. The difference between the market start time and the prediction expire time is 1 hour, i.e. players can predict the market price for up to one hour, depending on the timestamp at which the market was created. The difference between the prediction expire time and the market settlment time is 1 hour.

Example:

  • Market name: What will be the price of ETH/USD at Mon, 23 Nov 2020 22:00:00 GMT ?
  • The market will become live at the earliest at 20:00:00 GMT on 23/11/2020 and begin accepting predictions (market start time).
  • The market will accept predictions until 21:00:00 GMT on 23/11/2020 and then will no longer be live (prediction expire time).
  • The market will close at 22:00:00 GMT on 23/11/2020 and any player can perform the market settlement transaction to determine the winning outcome based on the oracle price feed at this particular time (market settlement time). At any point in time, only 1 prediction market will be active for predictions.

Option calculation

The prediction market offers players 3 betting options to take positions in the market (bullish, neutral, or bearish, each corresponding to a different price range, based on input from the ChainLink oracle pricefeed). The player will be rewarded if the actual price at the market settlement time is within the price range mentioned by the selected option. The option price ranges are calculated by the smart contract, using a simple and transparent algorithm before creating a new prediction market.

By default, users can take a position in 3 different market options:

  • Option 1 (Bullish): this option represents all prices above the upper limit of the neutral range.
  • Option 2 (Neutral): this option represents a range of price values which are equally distributed around the market price when the market becomes live.
  • Option 3 (Bearish): this option represents all prices below the lower limit of the neutral range.

Option staking

Players can buy positions by staking an arbitrary amount of ETH (greater than 0 wei) on a specific betting option. Players can additionally stake on the same position if they want to take on more risk, or stake on other betting options in order to hedge their current bet, as long as the prediction market is live. By default, in case of an unsuccessful prediction, the player loses the full amount they staked to predict that outcome.

Players will be charged a fee for participation in the prediction market:

  • 1% of the transaction value when staking ETH on a betting option.
  • All of the fees collected this way are placed in the smart contract for complete transparency and security.
  • In order to create a new live market or to settle an existing market, a player needs to push the respective transaction on the ethereum blockchain. This will result in that player incurring the gas cost of the transaction.
  • The fees collected will be used to incentivize players to perform market creation and market settlement transactions to keep the prediction market cycle going.
  • The incentive is distributed in variable amounts (10% of the total fee pool). This is done so the incentives for prediction market creation and settlement scale together with the total number of players and betting amounts staked in the current and previous prediction markets. More players and higher bets mean better incentives.
  • The reward will be earmarked and claimable by the address (player) who signed the transaction.
  • Any left-over fees, apart from the market creator and market settlement incentives, are accrued in the smart contract.

Market settlement

After the prediction market expires, the market settlement page will display a countdown until market settlement together with a button to settle the market. When the market settlement time is reached, any willing player can sign the market settlement transaction to settle the running prediction market. The player who clicked the button first, will be able to claim a market settlement reward. Once triggered, the prediction market will be settled using the ETH/USD pricefeed taken from a decentralized Chainlink oracle and on-chain smart contract computation. This ensures zero manual intervention and automated transparent settlements, while preventing volatility and single points of failure. At market settlement time, the actual ETH/USD market price is noted via the resolution mechanism (oracle) and the correct option is declared based on where in the different option ranges the noted price lies.

Market reward claims

Once the prediction market has been settled, bet winnings are distributed from the market reward pool, which consists of all amounts staked in the losing options and will be distributed to among the players holding positions in the winning option, as their incentive for predicting accurately.

  • Reward computation for each player: reward pool * (amount staked by the player in the winning option / total amount staked by all players in the winning option)

In order to provide more security and optimize gas costs, rewards will stay in the smart contract, where they can be subsequently claimed by the winning players. The rewards are claimable as soon as the market has been settled and upon a successful claim, the reward is transferred to the user’s wallet.

Predicty McPredictionFace: Dapp, Dapper, Dappst! - Predicty McPredictionFace:Dapp,Dapper,Dappst!

Getting Started

These instructions will get you a copy of this wild project up and running on your local machine for development and testing purposes.

Requirements

Node >= 10.19.0 Truffle >= v5.1.48 - a development framework for Ethereum Ganache CLI >= v6.11.0 

Installing

Firstly, you need to clone this repo. You can do so by downloading the repo as a zip and unpacking or using the following git command

git clone https://github.com/knnlrts/predicty-mcpredictionface.git 

Now, It’s time to install the dependencies. Enter the predicty-mcpredictionface directory and use

npm install 

Similarly, enter the frontend subdirectory and install the dependencies using

npm install 

We need to compile the smart contracts before deploying.

truffle compile 

Now, You should start a private network on port 8545 using Truffle develop, ganache-cli or something similar in a separate terminal window.

ganache-cli 

If you want, you can run the test cases using

truffle test 

Then, you can deploy the Predicty McPredictionFace contracts using

truffle migrate 

Note: the test cases use time-shifting test the smart contract functionality, so if you have ran the test cases first, the development blockchain timestamps will display a future datetime.

The development server for the frontend can be started on your local machine (http://localhost:3000/) using

npm run start 

Note: the frontend may be buggy as I’m just starting out with React (tip: refresh a lot) and was only tested superficially with the Firefox web browser.

Deployed Addresses – Rinkeby

  • Predicty McPredictionFace smart contract: 0xF25eDE3d31e512ce5863874896771b3fBA27204e
  • Owner: 0x6fe0b112e10959C2B11154792113c980F2adbdd4
  • ChainLink ETH/USD oracle pricefeed: 0x8A753747A1Fa494EC906cE90E9f37563A8AF630e

We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products. Learn more.


Predicty McPredictionFace:Dapp,Dapper,Dappst!什么是Predicty McPredictionFace?

为什么选择Predicty McPredictionFace?

解决方案概述cookies始终活跃的,以及他们的投注头寸
  • 成本:通常通过部署的智能合约,而不是中央中介机构
  • 即时头寸下注,在市场进入和回报分配
  • 链上分散预测市场收取高额交易费用,即时奖励和短期市场周期(每小时)不是低流动性订单,而是意味着一旦市场预测结果出炉,玩家就不需要长期锁定资金,并能够申请奖励。
  • 利用ETH/USD价格的链接oracle pricefeed创建和结算预测市场会自动激励参与者进行新的市场创建和现有的市场结算交易,以保持预测市场周期的运行和分散
  • 市场开始时间=市场开始活跃的时间,玩家可以在预测选项中占据位置提供。
  • 预测到期时间=市场不再接受预测且不再活跃的时间(等待关闭以分配奖励)。
  • Market settlement time=根据链接oracle pricefeed输入,市场收盘和宣布中奖期权的时间。市场开始时间和预测到期时间之间的差异为1小时,即玩家可以根据市场创建的时间戳预测市场价格,最长为1小时。预测到期时间与市场结算时间相差1小时。
  • 市场名称:在2020年11月23日星期一22:00:00 GMT时,以太币/美元的价格是多少?
  • 市场最早将于2020年11月23日格林尼治标准时间20:00开始运行,并开始接受预测(市场开始时间)。
  • 市场将接受预测,直到2020年11月23日格林尼治标准时间21:00:00,然后将不再实时(预测到期时间)。
  • 市场将于2020年11月23日格林尼治标准时间22:00:00收盘,任何玩家都可以执行市场结算交易,根据此时的甲骨文价格反馈(市场结算时间)来确定赢家结果。在任何时间点,只有一个预测市场将活跃于预测。
  • 选项1(Bulli
  • 这次回购是我提交给ConsenSys区块链blockchain开发者在线训练营(2020年版)的最后一次项目提交。在我的Dapp上看屏幕录音。

    Predicty McPredictionFace: Dapp, Dapper, Dappst! - Predicty McPredictionFace:Dapp,Dapper,Dappst!

    为什么选择Predicty McPredictionFace?

    Predicty McPredictionFace: Dapp, Dapper, Dappst! - Predicty McPredictionFace:Dapp,Dapper,Dappst!

    解决方案概述cookies始终活跃的,以及他们的投注头寸
  • 成本:通常通过部署的智能合约,而不是中央中介机构
  • 即时头寸下注,在市场进入和回报分配
  • 链上分散预测市场收取高额交易费用,即时奖励和短期市场周期(每小时)不是低流动性订单,而是意味着一旦市场预测结果出炉,玩家就不需要长期锁定资金,并能够申请奖励。
  • 利用ETH/USD价格的链接oracle pricefeed创建和结算预测市场会自动激励参与者进行新的市场创建和现有的市场结算交易,以保持预测市场周期的运行和分散
  • 市场开始时间=市场开始活跃的时间,玩家可以在预测选项中占据位置提供。
  • 预测到期时间=市场不再接受预测且不再活跃的时间(等待关闭以分配奖励)。
  • Market settlement time=根据链接oracle pricefeed输入,市场收盘和宣布中奖期权的时间。市场开始时间和预测到期时间之间的差异为1小时,即玩家可以根据市场创建的时间戳预测市场价格,最长为1小时。预测到期时间与市场结算时间相差1小时。
  • 市场名称:在2020年11月23日星期一22:00:00 GMT时,以太币/美元的价格是多少?
  • 市场最早将于2020年11月23日格林尼治标准时间20:00开始运行,并开始接受预测(市场开始时间)。
  • 市场将接受预测,直到2020年11月23日格林尼治标准时间21:00:00,然后将不再实时(预测到期时间)。
  • 市场将于2020年11月23日格林尼治标准时间22:00:00收盘,任何玩家都可以执行市场结算交易,根据此时的甲骨文价格反馈(市场结算时间)来确定赢家结果。在任何时间点,只有一个预测市场将活跃于预测。
  • 选项1(Bulli
  • Predicty McPredictionFace是预测市场的可靠智能合约实现,允许加密和拒绝者以小时为单位预测以太币的未来美元价值。预测市场背后的基本思想很简单:它允许市场参与者预测事件的结果,如果预测正确,就可以获得奖励。当足够多的参与者参与时,预测市场可以综合多方意见,捕捉“大众智慧”,在(数字)资产价格、政治、体育等社会经济事务中提供准确的预测和信息,以展示这一点,Predicty McPredictionFace的前端将持续显示任何时间点预测市场中所有玩家的总赌注分布。

    • 成本:通常通过部署的智能合约,而不是中央中介机构
    • 即时头寸下注,在市场进入和回报分配

    集中式预测市场存在一些降低整体有效性的缺陷:

    • 链上分散预测市场收取高额交易费用,即时奖励和短期市场周期(每小时)不是低流动性订单,而是意味着一旦市场预测结果出炉,玩家就不需要长期锁定资金,并能够申请奖励。
    • 利用ETH/USD价格的链接oracle pricefeed创建和结算预测市场会自动激励参与者进行新的市场创建和现有的市场结算交易,以保持预测市场周期的运行和分散
    • 市场开始时间=市场开始活跃的时间,玩家可以在预测选项中占据位置提供。
    • 预测到期时间=市场不再接受预测且不再活跃的时间(等待关闭以分配奖励)。
    • Market settlement time=根据链接oracle pricefeed输入,市场收盘和宣布中奖期权的时间。市场开始时间和预测到期时间之间的差异为1小时,即玩家可以根据市场创建的时间戳预测市场价格,最长为1小时。预测到期时间与市场结算时间相差1小时。

    Solution overview

    Market creation

    Predicty McPredictionFace旨在为每小时ETH/USD价格预测提供一个公平、分散和开放的金融预测市场,结算和奖励分配:

    Market length

    • 市场名称:在2020年11月23日星期一22:00:00 GMT时,以太币/美元的价格是多少?
    • 市场最早将于2020年11月23日格林尼治标准时间20:00开始运行,并开始接受预测(市场开始时间)。
    • 市场将接受预测,直到2020年11月23日格林尼治标准时间21:00:00,然后将不再实时(预测到期时间)。

    合约所有者通过部署智能合约创建第一轮预测市场。一个名为“2020年11月23日星期一22:00:00 GMT时以太币/美元的价格是多少?”将被创建,允许玩家以ETH为赌注来预测ETH在指定时间的未来美元价值。初始市场结算后,市场结算页面将显示一个创建新预测市场的按钮。当这个市场创建按钮显示时,任何愿意的玩家都可以签署市场创建交易,以创建下一个小时预测市场。首先点击该按钮的玩家将能够获得市场创造奖励。与其他预测市场不同的是,市场是由“市场创造者”或“期权创造者”创造的,Predicty McPredictionFace通过用智能合约和玩家激励机制取代它们,消除了对此类编剧的需求。

    • 市场将于2020年11月23日格林尼治标准时间22:00:00收盘,任何玩家都可以执行市场结算交易,根据此时的甲骨文价格反馈(市场结算时间)来确定赢家结果。在任何时间点,只有一个预测市场将活跃于预测。
    • 选项1(Bulli
    • The market will accept predictions until 21:00:00 GMT on 23/11/2020 and then will no longer be live (prediction expire time).
    • The market will close at 22:00:00 GMT on 23/11/2020 and any player can perform the market settlement transaction to determine the winning outcome based on the oracle price feed at this particular time (market settlement time). At any point in time, only 1 prediction market will be active for predictions.

    Option calculation

    示例:

    预测市场为玩家提供了3种在市场中持仓的投注选项(看涨、中性或看跌,每种都对应于不同的价格范围,这取决于链接甲骨文pricefeed的输入)。如果市场结算时的实际价格在所选选项所述的价格范围内,玩家将获得奖励。在创建新的预测市场之前,智能合约使用简单透明的算法计算期权价格范围。

    • Option 1 (Bullish): this option represents all prices above the upper limit of the neutral range.
    • Option 2 (Neutral): this option represents a range of price values which are equally distributed around the market price when the market becomes live.
    • Option 3 (Bearish): this option represents all prices below the lower limit of the neutral range.

    Option staking

    默认情况下,用户可以在3种不同的市场选项中持仓:

    玩家可以通过在特定的投注选项上下注任意数量的ETH(大于0 wei)来购买头寸。如果玩家想承担更大的风险,他们可以另外在同一个位置上赌注,或者在其他投注选项上赌注,以对冲他们当前的赌注,只要预测市场是实时的。在默认情况下,如果预测不成功,玩家将损失他们为预测结果所赌的全部金额。

    • 1% of the transaction value when staking ETH on a betting option.
    • All of the fees collected this way are placed in the smart contract for complete transparency and security.
    • In order to create a new live market or to settle an existing market, a player needs to push the respective transaction on the ethereum blockchain. This will result in that player incurring the gas cost of the transaction.
    • The fees collected will be used to incentivize players to perform market creation and market settlement transactions to keep the prediction market cycle going.
    • The incentive is distributed in variable amounts (10% of the total fee pool). This is done so the incentives for prediction market creation and settlement scale together with the total number of players and betting amounts staked in the current and previous prediction markets. More players and higher bets mean better incentives.
    • The reward will be earmarked and claimable by the address (player) who signed the transaction.
    • Any left-over fees, apart from the market creator and market settlement incentives, are accrued in the smart contract.

    Market settlement

    玩家参与预测市场将收取费用:

    Market reward claims

    预测市场到期后,市场结算页面将显示一个倒计时,直到市场结算,并有一个按钮来结算市场。当市场结算时间到了,任何有意愿的参与者都可以签署市场结算交易,结算正在运行的预测市场。首先点击该按钮的玩家可以申请市场结算奖励。一旦触发,预测市场将使用来自分散式链甲骨文和链上智能合约计算的以太币/美元价格饲料结算。这确保了零人工干预和自动化透明结算,同时防止波动和单点故障。在市场结算时,通过解析机制(oracle)记录实际ETH/USD市场价格,并根据所述价格在不同期权范围内的位置来声明正确的期权。

    • Reward computation for each player: reward pool * (amount staked by the player in the winning option / total amount staked by all players in the winning option)

    一旦预测市场已经结算,赌注赢款将从市场奖励池中分配,市场奖励池包括输掉期权的所有金额,并将分配给持有赢家期权头寸的玩家,作为他们准确预测的激励。

    为了提供更高的安全性和优化天然气成本,奖励将保留在智能合约中,赢家可以在该合约中申请奖励。一旦市场结算完毕,就可以申请奖励,一旦成功申领,奖励就会转移到用户的钱包中。

    Getting Started

    These instructions will get you a copy of this wild project up and running on your local machine for development and testing purposes.

    Requirements

    Node >= 10.19.0 Truffle >= v5.1.48 - a development framework for Ethereum Ganache CLI >= v6.11.0 

    Installing

    Predicty McPredictionFace: Dapp, Dapper, Dappst! - Predicty McPredictionFace:Dapp,Dapper,Dappst!

    git clone https://github.com/knnlrts/predicty-mcpredictionface.git 

    这些说明将为您提供这个wild项目的副本,并在本地计算机上运行,以用于开发和测试。

    npm install 

    首先,您需要克隆此repo。您可以通过将repo作为zip文件下载并解包,或者使用以下git命令来实现这一点

    npm install 

    现在,是时候安装依赖项了。进入predicty mcpredictionface目录并使用

    truffle compile 

    类似地,输入frontend子目录并使用

    ganache-cli 

    安装依赖项我们需要在部署之前编译智能合约。

    truffle test 

    现在,您应该在一个单独的终端窗口中使用Truffle develope、ganache cli或类似的工具在端口8545上启动一个专用网络。

    truffle migrate 

    如果需要,可以使用

    运行测试用例,然后可以使用

    npm run start 

    部署Predicty McPredictionFace合约。注意:测试用例使用时移测试智能合约功能,因此,如果您先运行了测试用例,开发区块链blockchain时间戳将显示未来的日期时间。

    Deployed Addresses – Rinkeby

    • Predicty McPredictionFace smart contract: 0xF25eDE3d31e512ce5863874896771b3fBA27204e
    • Owner: 0x6fe0b112e10959C2B11154792113c980F2adbdd4
    • ChainLink ETH/USD oracle pricefeed: 0x8A753747A1Fa494EC906cE90E9f37563A8AF630e

    可以在本地计算机上启动前端开发服务器(http://localhost:3000/)使用

    部分转自网络,侵权联系删除区块链源码网

    www.interchains.cc

    https://www.interchains.cc/18823.html

    区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 !
    区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » Predicty McPredictionFace: Dapp, Dapper, Dappst! – Predicty McPredictionFace:Dapp,Dapper,Dappst!区块链毕设代写

    提供最优质的资源集合

    立即查看 了解详情