MultiversX Tracker is Live!

Did you know that when transferring on Ethereum, it costs ~40% more gas to send tokens to a zero-balance account, and also 10% less gas to empty out an existing account's balance.

All Cryptocurrencies

by COINS NEWS 111 Views

TL;DR

There is a little-known secret about Ethereum gas fees that you probably won't know unless you're an EVM dev or have studied Ethereum's Yellow Paper of fee schedules.

  • It's ~40% more expensive to send tokens to a zero-balance account than to positive-balance account.
  • It's also ~10% cheaper to empty out an existing account's balance when transferring.

Some exchanges like Coinbase already take advantage of this rule to save on gas fees.

Here's why - Let's get technical:

In Appendix G of the Yellow Paper, you can find the fee schedule:

  • Gtransaction: 21k gas - Paid for every transaction
  • Gnewaccount: 25k gas - Paid for a CALL or SELFDESTRUCT operation which creates an account
  • Gsset: 20k gas - Paid for an SSTORE operation when the storage value is set to non-zero from zero
  • Gsreset: 2.9k gas - Paid for an SSTORE operation when the storage value's zeroness remains unchanged or is set to zero
  • Rsclear: 5k gas - Refund given (added into refund counter) when the storage value is set to zero from non-zero

Thus if you create a new balance, it costs ~20k gas extra. If you destroy a balance, you get a refund of 5k gas. The reason the fee schedule is set this way is to reflect the cost of storing additional account data.

Here's an example of this for the CRV token:

  • To an old account while emptying the sending account: 29449 gas
  • To a new account and NOT emptying the sending account: 51349 gas, a 17.1k + 4.8k = 21.9k gas increase

If you look at the GETH debug trace, the difference between sending to a zero and a non-zero account is that SSTORE costs 2900 to send to positive-balance accounts and 20000 to zero-balance accounts, which is a 17.1k gas difference. On top of that, emptying the account is 4.8k gas cheaper due to Rsclear.

Every token is different and has slightly-different gas fees. But you'll find the same differences everywhere.

Examples of sending USDC on the Goerli testnet:

  • Account to non-zero account: 48424 gas
  • Account to zero-balance account: 65524 gas, 17.1k more
  • Emptying account to a non-zero account: 43624 gas, 4.8k less
  • Emptying account to a zero-balance account: 60724 gas, 12.3k more

Thus it's always cheaper to send to an account with an existing balance, and also cheaper to clear an existing balance. Note that this only applies to transfers that use a smart contract. A normal ETH transfer that doesn't use a smart contract will always cost 21k gas regardless of existing balance.

How centralized exchanges already take advantage of this

Coinbase is a great example of an exchange that exploits this gas fee rule. Coinbase uses different processes when sending to positive-balance accounts vs zero-balance accounts.

  • Coinbase 10 makes batch transfers to old accounts with balances
  • Coinbase 2 makes single-transfers to new accounts without balances
    • This is always 21k gas for a normal transfer. If they tried to batch-transfer these using a contract, it would actually cost them 30k gas due to Gnewaccount.

Thus, for ETH transfers, it's better to use batch transfers to send to positive-balance and normal transfers to send to new zero-balance accounts.

Extra side note: Coinbase usually charges withdrawal fees at ~10x their actual cost of network fees. So they're totally ripping you off on withdrawal fees.

How can you take advantage of this?

Realistically, I don't expect of you to change your bad habits. And most of you aren't making enough transfers for this to matter.

But here's what you can do:

  1. For Bitcoin, the best privacy practice is to spin up a new UTXO for every transaction and never reuse UTXOs. Do NOT do this for Ethereum-like networks for tokens transfers. You will end up paying ~40% more for every transaction.
  2. If you can avoid it, don't leave token dust when transferring from your wallet accounts. Just empty your old account for a small gas savings.
submitted by /u/Maleficent_Plankton
[link] [comments]
Get BONUS $200 for FREE!

You can get bonuses upto $100 FREE BONUS when you:
πŸ’° Install these recommended apps:
πŸ’² SocialGood - 100% Crypto Back on Everyday Shopping
πŸ’² xPortal - The DeFi For The Next Billion
πŸ’² CryptoTab Browser - Lightweight, fast, and ready to mine!
πŸ’° Register on these recommended exchanges:
🟑 Binance🟑 Bitfinex🟑 Bitmart🟑 Bittrex🟑 Bitget
🟑 CoinEx🟑 Crypto.com🟑 Gate.io🟑 Huobi🟑 Kucoin.



Comments