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' 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' is to connect the oracle service (ChainLink) to provide a third-party price data to close betting at 'BettingContract' .
Addresses:
The latest version of @bbettercoin/Betting-V1/BettingContract_v1.sol and @bbettercoin/Betting-V1/BettingOracle_ChainLink_v3.sol are deployed at the addresses listed below.
Networks | Address |
---|---|
BSC Mainnet | 0x79fE2F3fe1e2C7242cB3057b6df6d1438467c1Ae |
Sepolia Testnet | 0x5d2B1C91DB08b313efA4C57cba77C1cfb8D71904 |
Networks | Address |
---|---|
BSC Mainnet | 0xCA6685EcFa3c367624Be5fF8513c30163F0692f1 |
Sepolia Testnet | 0x9530Cb27C3Ca02b09d74d042431ECedAe7930F84 |
BettingContract:
Main contract for 'Price Prediction' activities, functionalities includes 'Bettings', 'Bets', 'ReBets' and 'Claim Winning' .
- CreateBetting:
Creates a 'price prediction activity' for the given token and endTime
function CreateBetting( address token_address, uint256 endTime ) public returns (uint256)
token_address
is the predict target and need to be listed in SupportedToken .endTime
is the predict date of the token_address .Parameters:
Name Type Description token_address address the predict target of the price prediction activity endTime uint256 the predict date of the price prediction activity Return Values:
Name Type Description bettingCount uint256 the index number of this activity - CreateBet:
Join a price prediction activity for the token_address, betting_id of this activity, predictedPrice of the prediction token and spending amount
function CreateBet( address token_address, uint256 betting_id, uint256 predictedPrice, uint256 amount ) public returns (uint256)
token_address
is the address of the bet token which need to match with token_address in this activity.betting_id
is the id of the activity which user want to participate .predictedPrice
is the predicting price of the token for this activity .amount
is the bet amount the participant want to spend on this betParameters:
Name Type Description token_address address the token of the activity betting_id uint256 the activity id of the target price prediction activity predictedPrice uint256 the price which participant determine to predict amount uint256 the bet amount which participate want to spend Return Values:
Name Type Description betCount uint256 the bet id number of this bet - CloseBetting:
Close a activity by giving the betting_id of the price prediction activity
function CloseBetting(uint256 _betting_id) public
_betting_id
is the activity id the participant want to closeParameters:
Name Type Description _betting_id uint256 the index of the activity - WinningClaims:
Claim the Winning by giving token_address and the betting_id of the activity
function WinningClaims(address token_address, uint256 _bettingId) public
token_address
is the address of the bet token which need to match with token_address in this activity ,_betting_id
is the activity id the participant want to claim the winningParameters:
Name Type Description token_address address the predicting token of the bet and betting _betting_id uint256 the index of the activity - ReBet:
Re-bet the amount of the bet to new activity from original activity, by giving token_address, the _originalbetting_bettingId of the original activity, _newbetting_bettingId of the new activity and predictedPrice of the prediction token
function ReBet( address token_address, uint256 _originalbetting_bettingId, uint256 _newbetting_bettingId, uint256 predictedPrice ) public returns (bool)
token_address
is the address of the prediction token which need to match with token_address in this activity ",_betting_id
is the activity id the participant want to claim the winningParameters:
Name Type Description token_address address the prediciton token of the price prediction activity _originalbetting_bettingId uint256 the id of the original activity _newbetting_bettingId uint256 the index of the new activity predictedPrice uint256 the price which participant determine to predict Return Values:
Name Type Description ReBet bool the boolean value if 'ReBet' success or not
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 feedParameters:
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
Previus Addresses:
The previus version of @bbettercoin/Betting-V0/BettingContract.sol and @bbettercoin/Betting-V0/BettingOracle_ChainLink.sol are deployed at the addresses listed below.
Networks | Address | Version |
---|---|---|
BSC Mainnet | 0x044313b29bB667e929362cA48Eef63df427ac799 | V0 |
Ethereum Mainnet | 0x03eB7Fe6801893F6006127B5248809e8CFbdd89D | V0 |
Sepolia Testnet | 0x34f51DC4e03bC3F890D05F1b5516711D32dA684F | V0 |
Networks | Address | Version |
---|---|---|
BSC Mainnet | 0x62F20a5Db2bf22F36EFf3Df8e504A8054648c8cA | V0 |
Ethereum Mainnet | 0x361F35EDbe212107EcD63071D5255e477BB44e46 | V0 |
Sepolia Testnet | 0x3e05F982b2C85dD787b6f6d0652724a6791b87B0 | V0 |