diff --git a/chain.js b/chain.js index e2df305..5d2f3ac 100644 --- a/chain.js +++ b/chain.js @@ -262,6 +262,11 @@ function init(opts) { // We hand the wallet correct fees so the tx clears the floor: a priority tip at // or above the network suggestion (floored at 30 gwei for headroom) and a // maxFee that covers 2x base + tip so MetaMask never flags "max fee too low". +// eth_estimateGas for a prepared call, padded 30%: handed to the wallet as an explicit gas limit so wallets whose own +// estimation fails ('unable to get a gas fee', Marty 2026-10-08) can still sign. null when the call would revert. +async function estimateGas(tx) { + try { const g = BigInt(await rpc('eth_estimateGas', [tx])); return '0x' + (g + g * 30n / 100n).toString(16); } catch (e) { return null; } +} async function suggestedFees() { let tip = 0n, base = 0n; try { tip = BigInt(await rpc('eth_maxPriorityFeePerGas', [])); } catch (e) {} @@ -272,5 +277,5 @@ async function suggestedFees() { return { maxPriorityFeePerGas: '0x' + priority.toString(16), maxFeePerGas: '0x' + maxFee.toString(16) }; } -module.exports = { init, getConfig, reloadConfig, memberIdByAccount, memberCount, member, +module.exports = { init, getConfig, reloadConfig, memberIdByAccount, memberCount, member, estimateGas, product, productCount, quoteWei, creditBalance, catalog, recentEvents, totals, rpc, decodeLog, suggestedFees }; diff --git a/public/ads.html b/public/ads.html index 7fc6912..e091012 100644 --- a/public/ads.html +++ b/public/ads.html @@ -6,7 +6,7 @@