Gas Fee Calculation and Settings in Mobile Crypto Wallet

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Gas Fee Calculation and Settings in Mobile Crypto Wallet
Medium
~2-3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1054
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Implementing Gas Fee Calculation and Settings in Mobile Crypto Wallet

Gas fee is not just a number in the UI. It's a balance between confirmation speed and cost. A mobile wallet must offer sensible defaults and give control to those who want it.

Where to Get Current gasPrice

For legacy transactions (pre-EIP-1559) or networks without EIP-1559 support (BNB Chain by default): eth_gasPrice returns median gasPrice from recent blocks. This is the starting point.

For Ethereum Mainnet and EIP-1559 networks—eth_feeHistory(10, "latest", [10,50,90]) gives percentile-distribution of priority fee over the last 10 blocks. This is the foundation for slow/average/fast.

// Android — web3j: get feeHistory
val feeHistory = web3j.ethFeeHistory(10, DefaultBlockParameterName.LATEST, listOf(10.0, 50.0, 90.0)).send()
val baseFee = feeHistory.feeHistory.baseFeePerGas.last() // in wei
val slowPriorityFee = feeHistory.feeHistory.reward[0][0] // 10th percentile
val avgPriorityFee = feeHistory.feeHistory.reward[0][1]  // 50th percentile
val fastPriorityFee = feeHistory.feeHistory.reward[0][2] // 90th percentile

For Polygon with its gas spikes, use Gas Station API: https://gasstation.polygon.technology/v2—accounts for network specifics.

Three Modes: Slow / Average / Fast

Standard scheme:

Mode Base Fee Priority Fee Expected Time
Slow base + 0% 10th percentile 3–5 min
Average base + 10% 50th percentile ~30 sec
Fast base + 20% 90th percentile ~15 sec

maxFeePerGas = baseFee * multiplier + priorityFee. User picks a mode—app auto-recalculates total cost in USD.

Custom Mode for Advanced Users

"Custom" mode: input fields for maxFeePerGas and maxPriorityFeePerGas in Gwei. Validation required:

  • maxPriorityFeePerGas <= maxFeePerGas
  • maxFeePerGas >= current baseFee (or transaction hangs)
  • Warning if values too low: "Transaction may not confirm for hours"

Gwei is more convenient than Wei. Conversion: 1 Gwei = 10^9 Wei.

Estimate gasLimit

eth_estimateGas is mandatory for ERC-20 transfers and contract calls. Returns an estimate—multiply by 1.2 for safety buffer. For ETH transfer—fixed 21,000 gas.

If eth_estimateGas returns execution reverted—transaction will definitely fail. Show the error to the user before confirmation; don't allow submit.

Timeline: 2–3 days: poll feeHistory, calculate three modes, UI mode selection with USD cost display, custom mode with validation, gasLimit estimation.