The 'Betting V1' Smart Contracts

Welcome to the 'Betting V1' smart contracts documentation .

『 BBETTER is a decentralized cryptocurrency price prediction platform. Through openly audited smart contracts, anyone can scrutinize the code online, providing users with an absolutely fair and transparent platform to participate in cryptocurrency price prediction activities. 』

'Betting V1' consist of 2 contracts :

  • BettingContract:

    'BettingContract' is the main contract for 'Price Prediction' activity, which is to provide you functions for activities of cryptocurrency price prediction and an improved mechanism for handling your betting, rewards and winnings .

  • BettingOracle_ChainLink:

    'BettingOracle_ChainLink' is to connect the oracle service (ChainLink) to provide a third-party price data to close betting at 'BettingContract' .

  • BettingContract:

    Main contract for 'Price Prediction' activities, functionalities includes 'Bettings', 'Bets', 'ReBets' and 'Claim Winning' .

    BettingOracle_ChainLink:

    Connect the 'ChainLink oracle' service to provide a third-party data for closing activity and determining winning at 'BettingContract'" .

    • fetch_closest_price_to_timestamp:

      To fetch the price from ChainLink price feed of specified timeStamp

                                  
                                      function fetch_closest_price_to_timestamp(
                                          address token_address,
                                          uint timeStamp,
                                          uint token_decimails
                                      ) public returns (uint256, uint80) 
                                  
                              

      token_address is the search target and need to be listed in ChainLink_Price_Feed_Contract_Addresses . timeStamp is the date in unix timestamp format . token_decimails is the decimails value for the token .

      Parameters:

      Name Type Description
      token_address address the search token in the oracle
      timeStamp uint the search date in the oracle
      token_decimails uint the decimails value for the search token

      Return Values:

      Name Type Description
      returned_target_price uint256 the token price of search result
      target_roundID uint80 the roundID in ChainLink
    • getHistoricalPrice:

      Returns historical price for a round id .

                                  
                                      function getHistoricalPrice(
                                          uint80 roundId
                                      ) public view returns (int256, uint)
                                  
                              

      roundId the data ID in ChainLink price feed

      Parameters:

      Name Type Description
      roundId uint80 the data index in the ChainLink price feed oracle

      Return Values:

      Name Type Description
      price int256 the token price of search result
      timeStamp uint the timeStamp of search result

    Contact BBETTER