1

The SSTORE opcode has differential pricing depending on what the original, current, and new storage values are (see EIP-2200 for the full details). In short, the idea is that setting a zero value to a non-zero value (e.g. 0 to 42) costs significantly more than setting a non-zero value to another non-zero value (e.g. 42 to 1337).

However, all standard ETH transfers cost the same, namely, 21,000 gas. Why?

Why don't ETH transfers cost more when the recipient's balance is zero (compared to when it is not zero)?

For example, why not something like ~5k extra?

Sender Recipient Recipient's Balance Gas Cost
Alice Bob 4.2 ETH 21,000
Alice Charlie 0 ETH 26,000

1 Answer 1

0

I guess this has to do with how accounts are stored on disk, basically once an account is created the entire tuple (nonce, balance, code, storageRoot) always exists, even when balance = 0. note that storageRoot is just the hash of that account's storage trie.

on the other hand, the storage trie is sparse on disk. all values are 0 by default, so by setting a storage slot to 0 you can also remove it from disk.

7
  • "basically once an account is created the entire tuple ... always exists" - ok so what if the recipient account does NOT exist at all? No nonce, no code, no anything. Just sending ETH to an empty EOA. Sep 28, 2023 at 8:08
  • Isn't the exact amount arbitrary, would guess it makes more sense to have a consistent value for a native transfer, than one that is "5000" more or less in some situations.
    – Maka
    Sep 28, 2023 at 13:06
  • @PaulRazvanBerg Tranferring ethers to an inexistent account will charge an extra 25000, see EIP-161 for the extra details eips.ethereum.org/EIPS/eip-161.
    – Ismael
    Oct 1, 2023 at 4:38
  • @Ismael that's for CALL and SELF-DESTRUCT. How about non-contract transfers of ETH between EOAs? Oct 2, 2023 at 9:06
  • 1
    @PaulRazvanBerg Increasing the cost for that case could break a lots of scripts that depends on 21k gas. In particular exchanges use EOA instead of contracts to move ether around.
    – Ismael
    Oct 6, 2023 at 3:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.