Skip to main content

Fetching Reserve Amount

The getReserve method fetches the reserve amount of funds that are available for transactions, claims, or other operations in the contract.

Usage

import kohin from "./kohinInstance";

const reserveAmount = await kohin.getReserve();

if (reserveAmount.success) {
console.log("Reserve Amount:", reserveAmount.reserveAmount);
} else {
console.error("Error fetching reserve amount:", reserveAmount.error);
}

Return Value

The getReserve method returns an object with the following structure:

{
success: boolean; // Indicates if the operation was successful
error?: string; // Error message if the operation failed
reserveAmount?: number; // The reserve amount value
}

Error Handling

Here's how you can handle errors while fetching the reserve amount:

try {
const res = await kohin.getReserve();

if (res.success) {
console.log("Reserve Amount:", res.reserveAmount);
} else {
console.error("Error fetching reserve amount:", res.error);
}
} catch (error: any) {
console.error("Unexpected error while fetching reserve amount:", error);
}

Example Response

Success Response:

{
"success": true,
"reserveAmount": 50000
}

Error Response:

{
"success": false,
"error": "Unable to fetch reserve amount."
}