Gas commission optimization
1) Why optimize gas in iGaming
In crypto payments, gas is the direct cost of Cost per Approved and the SLA factor (time to finalization). For iGaming, where fast deposits/withdrawals and predictable costs are important, gas management equals conversion and margin management.
2) Pricing fundamentals (EVM, EIP-1559)
Base fee (burned) + priority fee (tip to validator).
You put:- 'maxPriorityFeePerGas' (tip),
- `maxFeePerGas ≥ baseFee + maxPriorityFeePerGas`.
- Rule: Do not "hammer" the grid with a fixed gasPrice. Use oracles/medians, set the ceiling (ceil) and auto-drop when the load drops.
- Target ETA deposit'T _ target '(for example, ≤ 2 minutes).
- We select '(maxFee, maxPriority)' so that p95 is included in 'T _ target', with the restriction 'maxFee ≤ FeeCeil'.
3) Architectural level strategies
3. 1 Network selection and routing
For stables, keep a primary + secondary network (e.g. USDT/TRON + BSC; USDC/Arbitrum + Base).
Auto-switch by triggers: 'fee↑', 'ETA↑', RPC/bridge degradation, KYT failure growth.
3. 2 Butching and bundling
Batch conclusions: aggregate small payments into one batch (if UX and regulation allow).
Multi-send in one contract call: reduces overhead on calls.
Off-chain accumulation + onchain calculation 1 time/period for internal transfers.
3. 3 L2 и Rollups
Send mass transactions to L2 (Arbitrum/Optimism/Base/zk-rollups) followed by an off-/on- ramp.
For large VIP amounts, allow ETH L1 as the "anchor" of predictability.
4) Transaction-level tactics
4. 1 Dynamic confirmation windows
Low-risk stable → a minimum of confirmations.
New/High-risk address → more confirmations/hold.
During network congestion, increase the window, not the "unlimited" price.
4. 2 Adaptive tip (priority fee)
Put 'priority' on quantiles (p60-p75 mempool).
Algorithm: if tx does not go beyond K blocks, increase the'priority' stepwise, but do not go beyond FeeCeil.
4. 3 Fail-safe
Off-chain checks: limits/formats/balances/allowance up to the end of the chain.
Idempotency key to write (invoice/within) so that retrays do not duplicate write-offs.
Private mempool/relay for cereals (reduction of MEV/rebroadcast and unnecessary overpayments).
5) Reduced calldata and EVM operation
5. 1 Data compression and packaging
Pack fields in 'bytes32', use bit masks, event log instead of storage (where allowed).
Avoid lines/dynamic arrays on the contract payment path.
5. 2 Permit и meta-tx
EIP-2612 (permit): deposit with a token without a separate'approve '- minus 1 transaction and commission.
Meta-transactions: client's signature → relayer pays gas (increases mobile AR).
5. 3 ERC-4337 (Account Abstraction)
Paymaster pays gas per user (sponsor) when your conditions are met (KYC tier, VIP, promo).
Bundling 'UserOperation' → better block filling and competitive price.
6) Organization of contracts and code (microoptimization)
Cache 'SLOAD' to memory; avoid extra 'SSTORE'.
Minimize 'revert' branches (expensive and breaks SLA).
Reuse gas-cost optimized library methods.
If possible - off-chain calculations, onchain - only verification/minimum state.
Generate receipt events instead of storing intermediate statuses.
7) Operational Practices for Payment Team
7. 1 Fee-market monitoring
Take off the metrics: 'baseFee', 'priority p50/p95', 'ETA p50/p95', mempool volume.
Alerts on: baseFee surge, inclusion timeouts, orphan/replace-by-fee rise.
7. 2 Retray policy
Exponential backoff + jitter; limit of attempts; in case of exceeding - a swarm to the secondary network/method.
Replace-By-Fee (1559): Raise only priority without inflating maxFee indefinitely.
7. 3 RPC Management
2-3 RPC providers (primary/secondary/fallback), automatic switching.
Common rate-limit and connection pools, webhook signature, chainId check.
8) UX: How not to lose a conversion
ETA before payment (network/load dependent range).
Prompt "cheap network" and validate memo/tags.
QR/deeplink and network auto-detection at.
Show the commission and "what it consists of" (transparency reduces tickets).
"Soft holds" with timer and cause, partial release on EDD.
9) Economy: Consider all-in
Total Cost per Approved (CPA_chain) =
`gas(network) + provider_fee + bridge_fee + KYT/TravelRule + ops(time) + failures_cost`
Where failures_cost are repeated attempts, takes, manual cases and support.
Objective: to minimize CPA_chain while maintaining SLA finalization.
10) Policy examples
10. 1 Deposits (stables)
Primary: USDT/TRON (FeeCeil низкий), Secondary: USDC/Arbitrum.
'T _ target ≤ 2 min p95 '; if'fee> FeeCeil'or'ETA> 3 min' → auto-tip "switch to secondary network."
10. 2 Conclusions
Batch to'N 'recipients if delay ≤ SLA.
Large sums → private relay, priority by p75, extra confirms.
In case of network degradation: switching to backup, informing the statuses in the UI.
10. 3 Transaction reduction
Wherever possible: permit (no approve), meta-tx and 4337 Paymaster per share/threshold.
11) Metrics and OKR
Cost/speed
Cost per Approved by Network/Asset.
Time-to-Finality p50/p95 (deposits/conclusions).
Average/median gas and proportion of transactions ≤ FeeCeil.
Reliability
Proportion of retrays, duplicates, cancellations and 'revert'.
RPC uptime, авто-switch-over count.
UX/Business
Approval Rate, drop-off in payment flow, tickets "expensive/long."
Share of transfers with permit/meta-tx/4337.
12) Anti-patterns
Fixed gasPrice "by eye" without EIP-1559/quantiles.
Race to include "at any cost" (hyping maxFee).
No backup network/RPC provider.
No validation of memo/tags - "burning" payments.
Separate 'approve' before each deposit (no permit).
Butching excluding SLA and KYC/AML (regulatory risks).
One big all-in-one contract with expensive SSTOREs.
13) Implementation checklist (short)
- Network matrix: primary/secondary + switch rules.
- Oracle of commissions and EIP-1559 strategy (quantile/ceil).
- Butching/multisend for outputs; off-chain aggregation of small operations.
- Permit (EIP-2612) и meta-tx; ERC-4337 Paymaster for sponsor gas.
- calldata compression, events instead of storage, SLOAD cache.
- Private relay for large payouts; MEV/rebroadcast protection.
- Idempotency keys, anti-duplicates, correct retrays.
- Network/address/memo validation; QR/deeplink; ETA and decoding fee.
- Monitoring: base/priority/ETA, RPC health, failure-rate.
- Regular fee retrospect and A/B calibration of policies.
14) Summary
Gas optimization is not "knock down a couple of gwei," but a system architecture: correct networks and routing, EIP-1559 with quantiles and ceilings, butching and bundling, permit/meta-tx/AA, savings on calldata and failures, plus transparent UX. Bet on all-in value and SLA finalisations - and your crypto-payment rails will be fast, predictable and profitable.