Bitcoin Forum
November 25, 2026, 01:34:08 PM *
News: Latest Bitcoin Core release: 32.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Your ERC-20 transfer is expensive because of storage, not gas price  (Read 11 times)
khalidxpert (OP)
Member
**
Online Online

Activity: 279
Merit: 31

XpertCreation - https://xpertcreation.com


View Profile WWW
Today at 12:30:01 PM
 #1

Everyone watches the gas price and ignores where the gas goes. For a plain USDT or any ERC-20 transfer, the cost is dominated by storage writes, not arithmetic:

    [] Writing a storage slot from zero to non-zero costs 20,000 gas. [] Updating an existing non-zero slot costs 5,000 gas.
  • Clearing a slot refunds a capped amount (currently 4,800 gas per slot, capped at one fifth of the transaction's total gas).
That is why the same transfer costs different amounts depending on the recipient. If the recipient's token balance slot is currently zero — a brand new wallet, a fresh exchange deposit address — the sender pays to create it. 20,000 gas is roughly four times a normal update.

Practical consequences:

First transfer to a new address always costs more than the second one. If you are sending small amounts to many fresh addresses, budget for the creation, not the transfer.

Batching helps when the storage pattern is the same. Ten zero-to-non-zero writes cost the same as ten separate transactions in gas terms; you save on the 21,000 base cost per transaction and on calldata, not on the storage.

A contract that pays twenty people from one call is not automatically cheaper than twenty transfers, unless those slots already exist. It is cheaper in transaction overhead only.

Before optimising anything, run the numbers on a fork:
Code:
cast estimate --rpc-url $RPC --value 0 $TOKEN "transfer(address,uint256)" $TO $AMOUNT
Do it twice — once to a fresh address, once to an address that already holds the token. The difference is the storage, and it is usually the largest line item in the bill.


X P E R T C R E A T I O N We build it, we run it, we keep it online. Django · React · Linux VPS · Custom platforms xpertcreation.com

3) Badi (Sr. Member+)

X P E R T C R E A T I O N Full-stack development — from database schema to Nginx.

› Django + React web platforms › Linux VPS setup, deployment & hardening › Crypto payments, wallets & on-chain integrations

xpertcreation.com
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!