Skip to content

fix(Simulator): use live gas price for send transaction fee#18005

Merged
pettinarip merged 2 commits into
devfrom
fix/simulator-live-gas-price
Apr 22, 2026
Merged

fix(Simulator): use live gas price for send transaction fee#18005
pettinarip merged 2 commits into
devfrom
fix/simulator-live-gas-price

Conversation

@pettinarip
Copy link
Copy Markdown
Member

@pettinarip pettinarip commented Apr 21, 2026

Summary

  • The simulator's network fee was hardcoded at 0.00042 ETH (21k gas × 20 gwei), which over-represents real costs by ~20× at today's ~1 gwei base fee. At the current fallback ETH price this shows as $0.42 when realistic values are closer to ~$0.05.
  • /api/gas-eth-price already returns gasPrice alongside ethPriceUSD; the simulator just wasn't consuming it.
  • Renamed useEthPriceuseGasEthPrice to return { ethPrice, gasPrice }, and derive the transfer fee in SendReceive as ETH_TRANSFER_GAS_UNITS * gasPrice * 1e-9.
  • Replaced ETH_TRANSFER_FEE constant with ETH_TRANSFER_GAS_UNITS = 21_000 and FALLBACK_GAS_PRICE_GWEI = 1 (reflects typical post-Pectra base fee, keeps Chromatic snapshots deterministic via the existing isChromatic() guard).

Test plan

  • On / homepage simulator, step through the send flow to step 5 ("You are sending") and verify network fee shows a realistic value (~0.000021 ETH at 1 gwei, with USD equivalent proportional to live ETH price)
  • Verify post-send balance on step 6 reflects the smaller fee deduction
  • Chromatic snapshot for SendReceive / SendSummary remains stable (uses 1 gwei fallback deterministically)
  • /wallets page wallet simulator still works end-to-end
  • Check that the ConnectWeb3 screen still renders the final wallet state correctly (hook signature changed)

The simulator's network fee was hardcoded at 0.00042 ETH (21k gas x 20
gwei), which roughly 20x over-represents real costs at today's ~1 gwei
base fee. The /api/gas-eth-price endpoint already returns gasPrice, so
this threads it through via a renamed useGasEthPrice hook and derives
the fee from ETH_TRANSFER_GAS_UNITS * gasPrice.
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 21, 2026

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit 2bc5786
🔍 Latest deploy log https://app.netlify.com/projects/ethereumorg/deploys/69e8fecf2e92e30008d39f13
😎 Deploy Preview https://deploy-preview-18005.ethereum.it
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 58 (no change from production)
Accessibility: 93 (no change from production)
Best Practices: 100 (no change from production)
SEO: 98 (🔴 down 1 from production)
PWA: 59 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the tooling 🔧 Changes related to tooling of the project label Apr 21, 2026
Copy link
Copy Markdown
Member

@wackerow wackerow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pettinarip Lgtm, thanks! Though the ConnectWeb3 phase goes back to the original "$50" balance—can't recall if this was the intended behavior or not, but also doesn't necessarily need to block this improvement

@pettinarip
Copy link
Copy Markdown
Member Author

the ConnectWeb3 phase goes back to the original "$50" balance—can't recall if this was the intended behavior or not

That's pre-existing behavior — each simulator phase (CreateAccount, SendReceive, ConnectWeb3) is a self-contained demonstration and doesn't thread balance state from the previous phase. ConnectWeb3 computes its ETH balance fresh from USD_RECEIVE_AMOUNT / ethPrice in src/components/Simulator/screens/ConnectWeb3/index.tsx. This PR only touches the gas-price-derived fee, so it doesn't change that. Worth revisiting separately if we want continuity across phases, but agreed it shouldn't block this fix.

@pettinarip pettinarip merged commit 81b5fbf into dev Apr 22, 2026
12 checks passed
@pettinarip pettinarip deleted the fix/simulator-live-gas-price branch April 22, 2026 17:34
@wackerow wackerow mentioned this pull request Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tooling 🔧 Changes related to tooling of the project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants