From eac1457f0a06fdb26f7898954def57c38e56a8d4 Mon Sep 17 00:00:00 2001 From: void-57 Date: Mon, 8 Dec 2025 23:48:57 +0530 Subject: [PATCH] fix: ensure precise HBAR to Wei conversion by formatting numeric amounts as strings. --- hederaBlockchainAPI.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hederaBlockchainAPI.js b/hederaBlockchainAPI.js index e8f77b9..7518108 100644 --- a/hederaBlockchainAPI.js +++ b/hederaBlockchainAPI.js @@ -333,7 +333,9 @@ const nonce = await web3.eth.getTransactionCount(fromAddress, 'pending'); // Convert HBAR to Wei (1 HBAR = 10^18 Wei in EVM context) - const amountInWei = web3.utils.toWei(amount.toString(), 'ether'); + + const amountString = typeof amount === 'number' ? amount.toFixed(18) : amount.toString(); + const amountInWei = web3.utils.toWei(amountString, 'ether'); // Prepare transaction object for gas estimation let gasLimit = 21000; // Default for existing accounts