Prediction and betting dApp of token price by using amberdata.io and chainlink

mmm2mmm
4 min readMar 15, 2020

--

I build dApp by using https://amberdata.io and chainlink oracle this time.

In this article, I will introduce how to use this dApp.

Introduction of Prediction and Betting dApp of Token Price

  • Prediction and Betting dApp of Token Price is a decentrailized application which is created by https://amberdata.io and Chainlink Oracle.
  • In this dApp, users predict token price of MKR token.

In addition that

Development tools I used

API of Amberdata.io for getting “Historical Token Price”

・ChainLink for getting external data as oracle(Amberdata Chainlink (Testnet))
https://docs.chain.link/docs/amberdata-chainlink-testnet

Amberdata Chainlink (Testnet)

Introduce how to use this dApp

On the premise that users will predict token price of MKR of tomorrow whether MKR exceed 220 USD or not in this dApp.

First of All,

users bets either “220 USD or more” or “Less than 220 USD” by paying with ETH.

  • When users bets, they push either button which users want to bet.
Bet 0.1ETH on “220 USD or more”
Bet 0.2ETH on “Less than 220 USD”

Second,

Users request result of for checking their prediction is true or false.

  • When users request result, they push a button of “Request Result”).
  • On the premise that users need to wait to push a button of “Request Result” until day after 0:00AM (GMT).
Push a button of “Request Result”

(However, users can push a button of “Request Result” soon right now in order to be able to check behavior of function)

  • Result of request is below:
    ・At that time, result of request was “1MKR=229.18USD”
    ・In this case Winners are users who predicted “Less than 220 USD”

Third,

Users who win their prediction (who called “Winners”) can withdraw betted ETH which include betted ETH by users who lost their prediction.

  • When users who win their prediction want to withdraw, they push a button of “Withdraw Winnings”
Push a button of “Withdraw Winnings”

・Reward which include betted ETH by users who lost their prediction below.

Reward is distributed from SmartContract to Winners

In general, users who are winner receive betted amount themself plus amounts which is divided betted amounts by loser by number of winners.
(In this case, 1 user predicted for test. Therefore, 1 user received all of rewards)

Conclusion

It has been a good experience for me to build dApp which is created by https://amberdata.io and chainlink.

This time I use historical token price of API of amberdata.io.
https://docs.amberdata.io/reference#get-historical-token-price

I knew that amberdata.io has not only API above, but also many kind of API of blockchain.

It mean developers can use not only token price, but also data related to gas price and contracts as API of amberdata.io.

That’s why I have felt amberdata.io is very useful and fit with chainlink integration.

Next time I want to try to build more interesting dApp by using API data of gas price and contracts via https://amberdata.io and chainlink.

--

--