Skip to main content

getMyDeposits

The getMyDeposits method allows you to access the deposit history of a specific wallet address, enabling users to track their deposits over time. This is particularly useful for monitoring deposit activities related to betting, insurance, or other financial transactions. The response includes a list of deposits, each containing relevant details such as the amount, deposit ID, and timestamp.

Usage

import kohin from "./kohinInstance";

const myDepositsParams = {
address: "0x670EEBd1eFdf8D576e1FE554F3D8e905f28cc5b9",
pageCount: 1,
};
const myDeposits = await kohin.getMyDeposits(myDepositsParams);
console.log("My Deposits:", myDeposits);

Parameters

ParameterTypeDescription
addressstringThe wallet address whose transaction history is being fetched.
pageCountnumberPagination parameter for fetching transaction history (default: 1).

Return Value

Returns a Promise resolving to an object with the following structure:

{
success: boolean; // Indicates whether the API call was successful
data?: { // Data containing the deposit details if successful
myDeposits?:
Array<{
account: string;
amount: number;
rawAmount: string;
depositId: string;
id: string;
timestamp: string;
}>;
};
error?: string; // Error message (if the call fails)
}

Error Handling

Handle potential errors gracefully by checking the response or using a try-catch block:

try {
const myDeposits = await kohin.getMyDeposits(myDepositsParams);
if (!myDeposits.success) {
console.error("Error:", myDeposits.error);
// Display the error message to the user
toastify(myDeposits.error, "error");
} else {
console.log("My Deposits:", myDeposits.data?.deposits);
}
} catch (error) {
console.error("Unexpected error:", error.message);
// Display a fallback error message
toastify("Failed to fetch deposits. Please try again.", "error");
}

Example Response

Success Response:

{
"success": true,
"data": {
"myDeposits": [
{
"account": "0x670eebd1efdf8d576e1fe554f3d8e905f28cc5a9",
"amount": "41.984148",
"rawAmount": "41984148",
"depositId": "1099511627894",
"id": "0x670eebd1efdf8d576e1fe554f3d8e905f28cc5a9-1099511627894",
"timestamp": "1736233511"
}
]
}
}

Error Response:

{
"success": false,
"error": "Unable to fetch deposits"
}