Skip to main

How a multi‑chain wallet actually saves you gas: simulation, batching, and real-world tricks

Authors: Brian Solis Brian Solis
Posted Under: General
Listen to this Article

Okay, so check this out—imagine switching networks and suddenly your swap costs three times more. Whoa! That feeling when you hit “confirm” and the gas estimate balloons is familiar to everyone in DeFi. My instinct said there had to be a better way. Initially I thought the answer was “better estimators,” but actually, wait—let me rephrase that: it’s a stack of UX, on‑chain simulation, and chain‑aware strategies working together. This piece is a practical, somewhat opinionated deep dive into what multi‑chain wallets should do to optimize gas and simulate transactions before users spend a penny.

First, a quick gut take. Seriously? You still rely on a single RPC for gas price? That’s a recipe for overpaying. Hmm… somethin’ felt off the first time I watched a user accept a wildly inflated fee because the wallet showed a fuzzy estimate. This part bugs me because it’s avoidable. You can design around it.

Let’s start with the core problem. Multi‑chain means multiple gas models. Some chains use EIP‑1559 with base fees. Others still use legacy gas price markets. Layer 2s like Arbitrum and Optimism add L1 cost components. Some rollups require paying both L2 compute and L1 inclusion indirectly. Non‑EVM chains (think Solana or Aptos) bill differently: compute units, not gas units, and the UX needs to translate that to dollars. A one‑size estimator breaks down fast when crossing those lines.

Screenshot of a transaction simulation UI showing estimated fees across chains

What a practical wallet does (and why)

Good multi‑chain wallets do three things well: they simulate, they adapt, and they communicate. Simulate via an RPC eth_call or a local fork. Adapt by using chain‑specific rules and multiple data sources for fees. Communicate clearly with the user—showing a point estimate is lazy. Show a range, show worst‑case, and offer “speed up” options. For a concrete tool, I often recommend rabby for users who want a multi‑chain UX with many of these ideas baked in—it’s not perfect, but it’s a solid step toward thoughtful gas handling.

Alright—now the nitty‑gritty. Eth_estimateGas is necessary but not sufficient. It gives you gas units for the call, but not the actual price you’ll pay when the transaction hits the mempool. You must combine units with a price. For EIP‑1559 chains you need the latest baseFeePerGas and a sensible priorityFee (tip). Some wallets pick a tip conservatively, but that increases cost. Others guess low and risk slow inclusion. On one hand, overbilling is wasteful; on the other, underbilling wastes time and frustrates users. The trick: use dynamic priority fees derived from mempool analytics, not a static slider.

Simulation is the secret sauce. Use eth_call with the exact tx payload and the block number to simulate state changes. But here’s the rub—simulation on a public RPC can diverge from reality because of mempool dynamics or reorgs. So for high‑value operations or complex DeFi compositions, fork the chain locally (with tools like Anvil or Hardhat) and run the bundle there. This recreates contract state and lets you iterate rapidly. It also reveals slippages, revert reasons, and unexpected pathing in DEX aggregators. If you’re building a wallet, integrate a lightweight simulation service that can do fast local forks for heavy checks and simple eth_call for quick estimates.

Okay, cool. But what about frontrunning and MEV? Oh man—that’s where things get spicy. Simulating without considering the mempool is incomplete. You need to estimate how other actors will react. Flashbots and private relays let you submit bundles that avoid the public mempool, reducing frontrunning risk. For users executing complex swaps or sandwich‑able operations, the wallet should offer a protected submission path (bundle submission) or at least warn of MEV risk. I’m biased, but I’d rather have an option to submit via a private relay than watch a sandwich eat my slippage.

Nonce management is another deceptively important detail. Multi‑chain wallets must handle simultaneous transactions, chain switches, and hardware wallet latencies. A failed tx with a spent nonce can lock user funds behind a non‑broadcasted replacement. The wallet should queue and manage nonces, show pending state, and offer safe replace‑by‑fee flows. Double transactions or retry storms happen when UX misleads users into clicking confirm multiple times—so put some guardrails there.

Here’s a practical flow I use when building wallet features:

1) Pre‑flight: run an eth_call simulation to ensure the tx won’t revert. This catches silly errors and gives you gas units. 2) Price assembly: fetch base fee and tip estimates from multiple RPCs and a mempool feed. Blend them intelligently. 3) Buffering: add a small buffer to estimated gas units to avoid out‑of‑gas on edge conditions. 4) MEV check: if the action is MEV sensitive, simulate against a local fork with potential frontrunning transactions inserted. 5) Submission: choose between public mempool or private relay depending on risk and cost. 6) Post‑submit: monitor pending state and provide options to speed up or cancel. Sounds like a lot? It is. But each step prevents micro losses that add up.

One more thing—cross‑chain swaps and bridges are a different animal. You can optimize single‑chain gas aggressively, but bridging often requires on‑chain finality waits and L1 fees. Be transparent. Show the user compounded fees: L2 compute + L1 inclusion + relayer fees. Sometimes a bridge will cost less in total than a direct swap on a congested chain, and sometimes not. UX should present comparisons. (oh, and by the way…) allow users to adjust tolerances; some prefer cheaper but slower and riskier, others want speed.

Let’s talk about tooling. If you’re integrating simulations into a wallet, these are useful patterns:

– Use multiple RPC endpoints and cross‑validate responses. One RPC could be outdated or under attack. – Keep a local cache of recent baseFee and priority fee samples to smooth spikes. – Offer offline simulation (local fork) for high‑risk txs. – Integrate signing flows that can be reverted in the UI while a tx is pending. – Surface clear rollback and retry actions with presets (fast/normal/slow) and explain their tradeoffs in plain language.

On the topic of cost savings: batching and gas sponsorship can make a big difference. Batch several token approvals or meta‑transactions into a single on‑chain op where the chain supports it. Gasless UX (meta‑tx via relayers) is comfy for users but shifts costs and introduces trust. Some relayer networks will sponsor first‑time txs to onboard users. That reduces friction but know the economics—relayers expect compensation later or require KYC in some systems. Be transparent about that.

Security tradeoffs pop up everywhere. Simulation can show that a tx will succeed now, but if some dependency is permissioned or oracle prices change between simulation and inclusion, you can still lose. So I always recommend showing a worst‑case scenario in the UI. For swaps, show the price at the time of inclusion and the slippage tolerance. For more advanced users, expose raw simulation traces and revert reasons so they can decide. I’m not 100% sure every user will read them, but some do, and power users appreciate it.

Finally, measurement is essential. Track actual gas paid versus estimates. Learn and adapt. If your estimates systematically overshoot, dial them back. If they undershoot, increase the buffer. It’s a feedback loop; treat it like tuning a performance engine. Also, collect anonymized telemetry (with permission) so you can model typical user flows per chain and precompute better defaults.

Frequently asked questions

How accurate is eth_estimateGas?

eth_estimateGas is a useful baseline. It reports gas units assuming current state and no mempool interference. But it doesn’t account for priority fee volatility or external actors. Use it for gas units, not final cost. Then combine units with live fee data and a buffer for safety.

Should wallets always use private relays like Flashbots?

Not always. Private relays reduce frontrunning risk but add complexity and sometimes cost. Offer it as an option for sensitive ops. For routine transfers it’s overkill. Balance user needs with risk profiles and present choices clearly.

What about L2s and their quirks?

Layer 2s often bundle L1 inclusion costs into their fee models. That means a cheap L2 transaction can still carry an L1 component at settlement. Understand each rollup’s fee model and surface the breakdown to users. Also, test bridge finality times—those waiting periods matter for UX.

Blog Banner Image

Get our best tips in your inbox! Join the smartest marketers who receive our ON newsletter.

Join the Social Pros LinkedIn Community

Join a community of real social pros doing social media on LinkedIn. Receive all the inspiration and ideas straight to your feed and add your thoughts to the conversation.

Follow Social Pros on LinkedIn

Subscribe to Social Pros Podcast

b2b influencer

Ready to Get Started?

I am looking for...

(Required)