getMySlips
The getMySlips
method enables developers to fetch a bettor's complete betting slip history. This includes detailed information about past bets, such as amounts, odds, premiums, statuses, and potential payouts.
It is particularly useful for applications where users need to review their betting history, track the outcomes of their bets, or manage ongoing wagers.
The method supports pagination through the pageCount parameter, making it suitable for handling large datasets efficiently. Developers can rely on this method for consistent and structured data, along with clear error messages when necessary, ensuring seamless integration into user-facing features.
Usage
import kohin from "./kohinInstance";
const mySlipsParams = {
bettor: "0x670EEBd1eFdf8D576e1FE554F3D8e905f28cc5a9", // Address of the bettor
pageCount: 1, // Pagination parameter for fetching slips
};
const mySlips = await kohin.getMySlips(mySlipsParams);
console.log("My Slips:", mySlips);
Parameters
Parameter | Type | Description |
---|---|---|
bettor | string | The wallet address of the bettor whose slips are being fetched. |
pageCount | number | Pagination value specifying which page of slips to retrieve (default: 1 ). |
Return Value
Returns a Promise
resolving to an object with the following structure:
{
success: boolean; // Indicates whether the call was successful
data?:
Array<{ // Betting slips object (present if successful)
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 mySlips = await kohin.getMySlips({
bettor: "0x670EEBd1eFdf8D576e1FE554F3D8e905f28cc5a9",
pageCount: 1,
});
if (!mySlips.success) {
console.error("Error:", mySlips.error);
// Display the error message to the user
toastify(mySlips.error, "error");
} else {
console.log("My Slips:", mySlips.data);
}
} catch (error) {
console.error("Unexpected error:", error.message);
// Display a fallback error message
toastify("Failed to fetch betting slips. Please try again.", "error");
}
Example Response
Success Response:
{
"success": true,
"code": 200,
"data": {
"activeSlips": [
{
"amount": "1",
"rawAmount": "1000000",
"betId": "813",
"odds": "6358759931439",
"premium": "835784",
"coverStatus": "Claimable",
"coverId": "99",
"timestamp": "1740570238",
"transactionHash": "0xa0c0f78abbe9d0eea23ab9dbf2ff8bfdfd41e6863c6a409e5e27d30fe2cf53b9",
"user": "0x34ca07db523c2ea867bd1d1dccc46de3eb6daae3",
"id": "0xa0c0f78abbe9d0eea23ab9dbf2ff8bfdfd41e6863c6a409e5e27d30fe2cf53b905000000",
"claimableAmount": "1000000",
"claimableAt": "1740781806",
"claimedAmount": "0",
"claimedAt": "0",
"betType": 0,
"blockNumber": "18546543",
"blockTimestamp": "1740570238",
"depositId": "1099511627829"
},
{
"amount": "1",
"rawAmount": "1000000",
"betId": "405",
"odds": "2.021694448858",
"premium": "535792",
"coverStatus": "Active",
"coverId": "164",
"timestamp": "1743762020",
"transactionHash": "0x302f1c03fa825d66040e3109afb919245516c50faa61c47fd01c8c9e3a937ecc",
"user": "0x34ca07db523c2ea867bd1d1dccc46de3eb6daae3",
"id": "0x471dac1052248602fdf05377ef99b5b7b3a769a1_405",
"claimableAmount": "0",
"claimableAt": "0",
"claimedAmount": "0",
"claimedAt": "0",
"betType": 1,
"blockNumber": "20034785",
"blockTimestamp": "1743762020",
"depositId": "1099511627838",
"bettor": "0x34ca07db523c2ea867bd1d1dccc46de3eb6daae3",
"status": "Accepted",
"result": null,
"type": "Express",
"potentialPayout": "2.021694",
"_subBetsCount": 2,
"createdBlockTimestamp": "1743761974",
"_wonSubBetsCount": 0,
"_lostSubBetsCount": 0,
"_updatedAt": "1743761974",
"_games": [
{
"title": "FC Augsburg – FC Bayern Munchen",
"league": {
"name": "Bundesliga"
},
"startsAt": "1743791400"
},
{
"title": "FSV Mainz 05 – Holstein Kiel",
"league": {
"name": "Bundesliga"
},
"startsAt": "1743859800"
}
],
"_conditions": [
{
"conditionId": "100610060000000000642348110000000000000928988958",
"coreAddress": "0x87ebffe283be8ded47c3c87451d1b89c8a2c441a",
"game": {
"league": {
"name": "Bundesliga"
},
"title": "FC Augsburg – FC Bayern Munchen",
"startsAt": "1743791400"
}
},
{
"conditionId": "100610060000000000645669270000000000000928989600",
"coreAddress": "0x87ebffe283be8ded47c3c87451d1b89c8a2c441a",
"game": {
"league": {
"name": "Bundesliga"
},
"title": "FSV Mainz 05 – Holstein Kiel",
"startsAt": "1743859800"
}
}
],
"selections": [
{
"_outcomeId": "31",
"odds": "1.387326654924"
},
{
"_outcomeId": "29",
"odds": "1.45725914058"
}
]
}
]
},
"message": "OK",
"detailMessage": null,
"error": ""
}
Error Response:
{
"success": false,
"error": "Bettor address not found"
}