getSlipHistory
The getSlipHistory
method provides developers with a comprehensive way to retrieve a bettor's historical betting slips. It enables tracking all previous bets along with detailed information such as bet IDs, odds, amounts, payouts, and their current statuses.
This method is ideal for applications aiming to display a bettor's complete betting history, analyze trends, or audit past transactions.
The pageCount parameter facilitates paginated results, ensuring smooth performance even when dealing with large datasets. It returns structured data and error details to help developers integrate it seamlessly into user interfaces or reporting tools.
Usage
import kohin from "./kohinInstance";
const slipHistoryParams = {
bettor: "0x670EEBd1eFdf8D576e1FE554F3D8e905f28cc5a9", // Address of the bettor whose history is being fetched
pageCount: 1, // Pagination parameter to specify which page of history to retrieve
};
const slipHistory = await kohin.getSlipHistory(slipHistoryParams);
console.log("Slip History:", slipHistory);
Parameters
Parameter | Type | Description |
---|---|---|
bettor | string | The wallet address of the bettor whose slip history is being fetched. |
pageCount | number | Pagination parameter for fetching slip history (default: 1 ). |
Return Value
Returns a Promise
resolving to an object with the following structure:
{
success: boolean; // Indicates whether the call was successful
data?: { // Slip history object (present if successful)
slipHistory:
Array<{
amount: string;
rawAmount: string;
betId: string;
odds: string;
premium: string;
coverStatus: string;
coverId: string;
timestamp: string;
transactionHash: string;
user: string;
id: string;
claimableAmount: string;
claimableAt: string;
claimedAmount: string;
claimedAt: string;
betType: number;
blockNumber: string;
blockTimestamp: string;
depositId: string;
bettor: string;
status: string;
result: string;
type: string;
imageUrl: string;
potentialPayout: string;
_subBetsCount: number;
createdBlockTimestamp: string;
_wonSubBetsCount: number;
_lostSubBetsCount: number;
_updatedAt: string;
_games: Game[];
_conditions: Condition[];
selections: Selection[];
}>
};
error?: string; // Error message if the call fails
}
interface Game {
title: string;
league: League;
startsAt: string;
}
interface League {
name: string;
}
interface Condition {
conditionId: string;
coreAddress: string;
game: Game;
}
interface Selection {
_outcomeId: string;
odds: string;
}
Error Handling
Handle potential errors gracefully by checking the response or using a try-catch
block:
try {
const slipHistory = await kohin.getSlipHistory({
bettor: "0x670EEBd1eFdf8D576e1FE554F3D8e905f28cc5a9",
pageCount: 1,
});
if (!slipHistory.success) {
console.error("Error:", slipHistory.error);
// Display the error message to the user
toastify(slipHistory.error, "error");
} else {
console.log("Slip History:", slipHistory.data);
}
} catch (error) {
console.error("Unexpected error:", error.message);
// Display a fallback error message
toastify("Failed to fetch slip history. Please try again.", "error");
}
Example Response
Success Response:
{
"success": true,
"data": {
"slipHistory": [
{
"amount": "100",
"rawAmount": "100000000",
"betId": "186",
"odds": "8.262097711591",
"premium": "60225255",
"coverStatus": "Claimed",
"coverId": "82",
"timestamp": "1734602011",
"transactionHash": "0xf614779c8e7b7bcf3b218d6449501dded590cc3e52e450179a69b49d28b18fe5",
"user": "0x670eebd1efdf8d576e1fe554f3d8e905f28cc5a9",
"id": "0x471dac1052248602fdf05377ef99b5b7b3a769a1_186",
"claimableAmount": "100000000",
"claimableAt": "1734708605",
"claimedAmount": "100000000",
"claimedAt": "1735796161",
"betType": 1,
"blockNumber": "15791505",
"blockTimestamp": "1734602011",
"depositId": "1099511627873",
"bettor": "0x670eebd1efdf8d576e1fe554f3d8e905f28cc5a9",
"status": "Resolved",
"result": "Lost",
"type": "Express",
"potentialPayout": "826.209771",
"_subBetsCount": 3,
"createdBlockTimestamp": "1734601953",
"_wonSubBetsCount": 2,
"_lostSubBetsCount": 1,
"_updatedAt": "1734707193",
"_games": [
{
"title": "South United – Kickstart FC",
"league": {
"name": "Bangalore Super Division"
},
"startsAt": "1734602400"
},
{
"title": "Trinity Starlets (Wom) – Vihiga Queens FC (W)",
"league": {
"name": "Premier League (W)"
},
"startsAt": "1734601967"
},
{
"title": "NorthEast United FC (Reserves) – Red Bee Inc",
"league": {
"name": "Guwahati Premier League"
},
"startsAt": "1734604200"
}
],
"_conditions": [
{
"conditionId": "100610060000000000262034120000000000000098899013",
"coreAddress": "0x87ebffe283be8ded47c3c87451d1b89c8a2c441a",
"game": {
"league": {
"name": "Bangalore Super Division"
},
"title": "South United – Kickstart FC",
"startsAt": "1734602400"
}
},
{
"conditionId": "100610060000000000262063700000000000000097359467",
"coreAddress": "0x87ebffe283be8ded47c3c87451d1b89c8a2c441a",
"game": {
"league": {
"name": "Premier League (W)"
},
"title": "Trinity Starlets (Wom) – Vihiga Queens FC (W)",
"startsAt": "1734601967"
}
},
{
"conditionId": "100610060000000000262080490000000000000098738796",
"coreAddress": "0x87ebffe283be8ded47c3c87451d1b89c8a2c441a",
"game": {
"league": {
"name": "Guwahati Premier League"
},
"title": "NorthEast United FC (Reserves) – Red Bee Inc",
"startsAt": "1734604200"
}
}
],
"selections": [
{
"_outcomeId": "31",
"odds": "2.21237294804"
},
{
"_outcomeId": "31",
"odds": "1.86093432046"
},
{
"_outcomeId": "174",
"odds": "2.006785442397"
}
]
}
]
}
}
Error Response:
{
"success": false,
"error": "Bettor address not found"
}