From a5ebc25567180a3d70f66351def09021dd20d4b2 Mon Sep 17 00:00:00 2001 From: void-57 Date: Tue, 13 Jan 2026 23:10:06 +0530 Subject: [PATCH] Calculate transaction fee and adjust transfer amount accordingly --- index.html | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 30cf3ef..39944a5 100644 --- a/index.html +++ b/index.html @@ -2453,17 +2453,20 @@ } console.log("Transaction details:", tx); - // Extract transaction information - const value = - tx.meta?.postBalances && tx.meta?.preBalances - ? Math.abs(tx.meta.postBalances[0] - tx.meta.preBalances[0]) / - solanaWeb3.LAMPORTS_PER_SOL - : 0; - + // Calculate fee first const fee = tx.meta?.fee ? tx.meta.fee / solanaWeb3.LAMPORTS_PER_SOL : 0; + // Extract transaction information + // Sender's balance change includes both transfer amount and fee + // So we subtract the fee to get just the transfer amount + const value = + tx.meta?.postBalances && tx.meta?.preBalances + ? (Math.abs(tx.meta.postBalances[0] - tx.meta.preBalances[0]) / + solanaWeb3.LAMPORTS_PER_SOL) - fee + : 0; + const timestamp = tx.blockTime ? getFormattedTime(tx.blockTime) : "Pending";