diff --git a/scripts/sendTRX.js b/scripts/sendTRX.js index edb6ce7..cbdedeb 100644 --- a/scripts/sendTRX.js +++ b/scripts/sendTRX.js @@ -44,7 +44,16 @@ async function sendTrx() { // Broadcast transaction const receipt = await tronWeb.trx.sendRawTransaction(signedtxn); - + console.log(receipt); + if (receipt && receipt.result && receipt.result.code === "INSUFFICIENT_BALANCE") { + throw new Error("Insufficient balance to send transaction."); + } + if (receipt && receipt.code && receipt.code === 'CONTRACT_VALIDATE_ERROR') { + throw new Error("Insufficient balance to send transaction."); + } + if (receipt && !receipt.result) { + throw new Error("Transaction failed: " + (receipt.result.message || "Unknown error")); + } const status = receipt.result ? "✅ Success" : "❌ Failed"; const statusColor = receipt.result ? "green" : "red"; const txid = receipt.txid ? truncate(receipt.txid) : "N/A"; @@ -134,7 +143,13 @@ async function sendTrx() { `; return receipt; } catch (err) { - outputDiv.innerHTML = `
${err.message}
+