Following the rules of the yellow paper, it costs 4 gas for every zero bytes of transaction data (msg.data
). Compare that to the cost of 68 gas, or 17 times as expensive for a non-zero byte. The hamming weight of msg.sender
makes no difference tho. The only bytes we are interested in are in msg.data
, which includes the function selector.
For example, if you're using the transfer(_to, _amount)
method on an ERC20 token, if the receiver address _to
contains a lot of zeroes, it will save you gas executing the transaction.
Using OpenZeppelin’s StandardTokenStandardToken
as a reference implementation, a standard transfer to an address with zeronon-zero bytes costs 51,486 gas
. However, a transfer to an address with eight zero bytes only costs 50,974 gas
, a difference of 51486 — 50974 = 512 gas
. This, which can also be expressed as 64 * 8 (the number of zero bytes)
.
I suggest you read this article On Efficient Ethereum Addresses for a detailed explanation.