router.post(
"/balance-check",
body("assetId").notEmpty(),
body("vaultId").notEmpty(),
body("amount").notEmpty(),
async (req, res) => {
try {
const { vaultId, assetId, amount } = req.body;
// Retrieve asset balance from Fireblocks
const assetBalance = await fireblocks.getVaultAccountAsset(
vaultId,
assetId,
);
// Check if the asset balance is greater than or equal to the required amount
if (assetBalance.available < amount) {
return res.status(400).json({
status: "Error",
error: "Your balance has been updated. Please redo the transcation. ",
data: assetBalance,
messages: [],
});
}
// Return success response
return res.status(200).json({
status: "Success",
data: assetBalance,
messages: [],
});
} catch (error) {
console.error(error);
return res.status(500).json({
id: null,
error: error.message,
messages: "Something went wrong!!",
});
}
},
);
This is my response from the API
with this parameter
{
"vaultId": "437",
"assetId": "USDT_BSC",
"amount": "11609"
}
{
“status”: “Success”,
“data”: {
“id”: “USDT_BSC”,
“total”: “11609.70291”,
“balance”: “11609.70291”,
“lockedAmount”: “0”,
“available”: “11609.70291”,
“pending”: “0”,
“frozen”: “0”,
“staked”: “0”,
“blockHeight”: “36988178”,
“blockHash”: “0x930e2d5bdb3037cebbb409f9033f882eb2d17bb5a10518a9f9789530169cbaef”
},
“messages”:
}
if i call my endpoint more than 1000 it throws error please redo the transaction
why this is happening?