diff --git a/src/main.js b/src/main.js index 0af2d65..9848903 100644 --- a/src/main.js +++ b/src/main.js @@ -674,13 +674,17 @@ async function searchTransactions(page = 1) { const date = tx.timestamp ? new Date(typeof tx.timestamp === 'string' ? tx.timestamp : tx.timestamp * 1000).toLocaleString() : 'Unknown Date'; const fees = tx.fees ? (Number(tx.fees) / 1000000).toFixed(6) : 'N/A'; - // Calculate total output amount (approximate value transferred) + // Calculate amounts const totalOutput = tx.outputs ? tx.outputs.reduce((acc, out) => acc + BigInt(out.value), 0n) : 0n; - const amountAda = (Number(totalOutput) / 1000000).toFixed(6); + const totalOutputAda = (Number(totalOutput) / 1000000).toFixed(6); + + // Get first output amount + const firstOutput = tx.outputs && tx.outputs.length > 0 ? tx.outputs[0] : null; + const firstOutputAda = firstOutput ? (Number(BigInt(firstOutput.value)) / 1000000).toFixed(6) : '0.000000'; // Get From/To (first ones for simplicity) let fromAddr = tx.inputs && tx.inputs.length > 0 ? tx.inputs[0].address : 'Unknown'; - let toAddr = tx.outputs && tx.outputs.length > 0 ? tx.outputs[0].address : 'Unknown'; + let toAddr = firstOutput ? firstOutput.address : 'Unknown'; // Convert hex to bech32 if (fromAddr !== 'Unknown') fromAddr = cardanoAPI.hexToAddress(fromAddr); @@ -704,7 +708,7 @@ async function searchTransactions(page = 1) {

Transaction Details

-
${amountAda} ADA
+
${firstOutputAda} ADA
@@ -725,12 +729,16 @@ async function searchTransactions(page = 1) { ${fromAddr}
- To: + To (Primary): ${toAddr}
- Amount: - ${amountAda} ADA + Amount Sent: + ${firstOutputAda} ADA +
+
+ Total Output: + ${totalOutputAda} ADA
Gas Used: