fix(Simulator): use live gas price for send transaction fee#18005
Conversation
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.
✅ Deploy Preview for ethereumorg ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
wackerow
left a comment
There was a problem hiding this comment.
@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
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. |

Summary
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.42when realistic values are closer to~$0.05./api/gas-eth-pricealready returnsgasPricealongsideethPriceUSD; the simulator just wasn't consuming it.useEthPrice→useGasEthPriceto return{ ethPrice, gasPrice }, and derive the transfer fee inSendReceiveasETH_TRANSFER_GAS_UNITS * gasPrice * 1e-9.ETH_TRANSFER_FEEconstant withETH_TRANSFER_GAS_UNITS = 21_000andFALLBACK_GAS_PRICE_GWEI = 1(reflects typical post-Pectra base fee, keeps Chromatic snapshots deterministic via the existingisChromatic()guard).Test plan
/homepage simulator, step through the send flow to step 5 ("You are sending") and verify network fee shows a realistic value (~0.000021 ETHat 1 gwei, with USD equivalent proportional to live ETH price)SendReceive / SendSummaryremains stable (uses 1 gwei fallback deterministically)/walletspage wallet simulator still works end-to-endConnectWeb3screen still renders the final wallet state correctly (hook signature changed)