Skip to main content

Fetching Bet Limits

The getBetLimits method retrieves the minimum and maximum odds, as well as the minimum and maximum amounts allowed for Combo bets. By querying the blockchain, this method fetches the configuration values that define the limits for Combo bets, ensuring that users can only place bets within the allowed parameters.
This is particularly useful for ensuring compliance with system constraints and providing users with up-to-date bet limits before they place a Combo bet. The method ensures the integrity and validity of the betting process by enforcing these predefined limits.

Usage

import kohin from "./kohinInstance";

const betLimits = await kohin.getBetLimits({
betType: "Combo", // Type of bet: "Combo" for express bet, "Single" for ordinar bet
});

if (betLimits.success) {
console.log("Combo Bet Limits:", betLimits);
toastify(
`Combo Bet Limits:
Min Odds: ${betLimits.minOdds},
Max Odds: ${betLimits.maxOdds},
Min Amount: ${betLimits.minAmount} USDT,
Max Amount: ${betLimits.maxAmount} USDT`,
"autoSuccess" // Display success message in the toast notification
);
} else {
console.error("Error fetching Combo Bet Limits:", betLimits.error);
toastify(`Error: ${betLimits.error}`, "autoError"); // Display error message in the toast notification
}

Return Value

The getBetLimits method returns an object with the following structure:

{
success: boolean; // Indicates if the operation was successful
minOdds?: number; // Minimum odds allowed for Combo bets
maxOdds?: number; // Maximum odds allowed for Combo bets
minAmount?: number; // Minimum bet amount allowed
maxAmount?: number; // Maximum bet amount allowed
error?: string; // Error message if the operation failed
}

Error Handling

The following code demonstrates how to handle errors while calling getBetLimits:

try {
const betLimits = await kohin.getBetLimits({ betType: "Combo" });

if (betLimits.success) {
toastify(
`Combo Bet Limits:
Min Odds: ${betLimits.minOdds},
Max Odds: ${betLimits.maxOdds},
Min Amount: ${betLimits.minAmount} USDT,
Max Amount: ${betLimits.maxAmount} USDT`,
"autoSuccess"
);
} else {
if (betLimits.error) {
toastify(`Error: ${betLimits.error}`, "autoError");
}
}
} catch (err) {
toastify(
"Unexpected error fetching Combo Bet Limits. Please try again.",
"autoError"
);
console.error(err); // Log error for debugging
}

Example Response

Success Response:

{
"success": true,
"minOdds": 1,
"maxOdds": 100,
"minAmount": 1,
"maxAmount": 200
}

Error Response:

{
"success": false,
"error": "Contract not available."
}