From 3ba7b07d1e58b6b062ef5d122a4e0ae5522e2821 Mon Sep 17 00:00:00 2001 From: def Date: Sun, 15 Mar 2026 20:08:15 +0000 Subject: [PATCH] Add explicit from address for wallet transaction requests --- templates/portal_invoice_detail.html | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/templates/portal_invoice_detail.html b/templates/portal_invoice_detail.html index f907265..2191a1d 100644 --- a/templates/portal_invoice_detail.html +++ b/templates/portal_invoice_detail.html @@ -537,19 +537,32 @@ Reference: ${invoiceRef}`; const decimals = Number(walletButton.dataset.decimals || "18"); const tokenContract = walletButton.dataset.tokenContract || ""; - await window.ethereum.request({ method: "eth_requestAccounts" }); + const accounts = await window.ethereum.request({ method: "eth_requestAccounts" }); + const from = Array.isArray(accounts) && accounts.length ? accounts[0] : ""; + if (!from) { + throw new Error("Wallet did not return an account address."); + } + await switchChain(chainId); let txHash; if (assetType === "native") { txHash = await window.ethereum.request({ method: "eth_sendTransaction", - params: [{ to: to, value: toHexBigIntFromDecimal(amount, decimals) }] + params: [{ + from: from, + to: to, + value: toHexBigIntFromDecimal(amount, decimals) + }] }); } else { txHash = await window.ethereum.request({ method: "eth_sendTransaction", - params: [{ to: tokenContract, data: erc20TransferData(to, amount, decimals) }] + params: [{ + from: from, + to: tokenContract, + data: erc20TransferData(to, amount, decimals) + }] }); }