diff --git a/index.html b/index.html index bd52f8b..d989a1e 100644 --- a/index.html +++ b/index.html @@ -1458,19 +1458,34 @@ "Invalid transaction hash format. Hash should be 0x followed by 64 hexadecimal characters." ); } + const AVAX_RPC_URL = "https://api.avax.network/ext/bc/C/rpc"; + // Fetch transaction details from AVAX RPC + const provider = new ethers.providers.JsonRpcProvider(AVAX_RPC_URL); + const tx = await provider.getTransaction(hash); + const receipt = await provider.getTransactionReceipt(hash); + + if (!tx) { + throw new Error("Transaction not found on the blockchain."); + } // Generate SnowTrace explorer URL const explorerUrl = `https://snowtrace.io/tx/${hash}`; - // Display hash lookup result + const value = ethers.utils.formatEther(tx.value || "0"); + const gasUsed = receipt ? receipt.gasUsed.toString() : "Pending"; + const status = receipt + ? (receipt.status === 1 ? 'Confirmed' : 'Failed') + : 'Pending'; + const blockNumber = tx.blockNumber || "Pending"; + output.innerHTML = `
- +
-

Transaction Hash Found

-

View the transaction details on SnowTrace explorer.

+

Transaction Found

+

Transaction details retrieved successfully.

@@ -1483,32 +1498,71 @@
- ${hash} + ${hash}
+ +
+ +
+ ${status} +
+
+ +
+ +
+ ${blockNumber} +
+
+ +
+ +
+ ${tx.from} + +
+
- +
- - View on SnowTrace Explorer - + ${tx.to || "Contract Creation"} + ${tx.to ? `` : ''}
-
+
+ +
+ ${value} AVAX +
+
+ +
+ +
+ ${gasUsed} +
+
+ +
`; - showNotification("Transaction hash found!", "success"); + showNotification("Transaction details loaded!", "success"); } catch (error) { output.innerHTML = `
@@ -1516,12 +1570,12 @@
-

Invalid Transaction Hash

+

Error Loading Transaction

${error.message}

`; - showNotification("Invalid transaction hash", "error"); + showNotification("Failed to load transaction", "error"); } finally { button.disabled = false; button.innerHTML = originalHTML;