Code Monkey home page Code Monkey logo

linkbet's Introduction

Link Betting Game

Major Topics Learned:

  • deployment to testnet (Rinkeby) -> network specific contract interaction
  • use Links pricefeed oracle to get ETH/USD price
  • use Links VRF contract to get a random number
  • ERC677 Token (LINK) -> makes working with oracles easier
  • callback interaction with another contract
  • commenting out unused variables to suppress warnings
  • use of mapping to allow multiple pending states (bets) to ensure proper payouts
  • using for loops in smart contracts for pending processes
  • dynamically adjusting account balances without refreshing the page
  • react -> "componentWillMount" removed & "componentDidMount" used

Resources:

NOTE: My code has been modified and updated to fix general use bugs present in the Dapp University tutorial. MetaMask and React have gone through some changes which I have updated along with making the code cleaner and easier to read (front-end).

Updates:

  • switch to componentWillMount (updated to react 17.0.1)
  • changed metamask connection to reflect their latest changes (use our web3.js)
  • dynamically update navbar account when we are not on the correct network
  • dynamically update account balance once transaction is sent to smart contract
  • allow user to bet again after account has updated (even with a pending result)
  • filter events so that only ones from the user account are shown (in the event of multiple users)
  • have metamask pop up to log in when page loads
  • clean up dead/redundant code

Design

Instructions

The front end will display the current connected account in the upper right hand corner along with the users balance in the lower right of the app. The user can place a bet for any amount between the min and max bet amounts. There is a 50/50 change of getting the outcome is either "high" or "low". There payout is 1-1 (ie. if you bet 1 eth and win, you receive 1 eth ).It takes a considerable amount of time to get a result back, roughly 1-2 min on the rinkeby network.

To play the game, please use the faucet below to get ETH and fund your smart contract with both ETH & LINK.

  • Use Rinkeby test network and get funds from faucet
  • Go to Link faucet and paste metaMask account

UI

linkbet's People

Contributors

guceri avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.