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 = `
${hash}
+ ${hash}
${blockNumber}
+ ${tx.from}
+
+ ${tx.to || "Contract Creation"}
+ ${tx.to ? `` : ''}
${gasUsed}
+