4

I have seen many contract addresses being created using vanity address generators to have many 0s in the begginning and even method sighashes having all 0s in them and have come to the conclusion that they do save gas. If yes, then how much gas do they really save?

1
  • I would think that they have no function at all (and no gas saving). It's only for vanity and looking cool. But I am not sure so I will let someone else answer...
    – Undead8
    Jun 6, 2021 at 23:03

1 Answer 1

1

One of the projects using such 'short' addresses is the Gas Token. From https://gastoken.io/#GST2 :

The address of our GST2 GasToken, 0x0000000000b3F879cb30FE243b4Dfee438691c04, is hardcoded. Note that this address is very short (only 15 non-zero bytes instead of 20). We generated our GasToken contract at such an address on purpose, so as to save some gas when creating contracts. The above child contract uses 22 bytes of code, and thus costs roughly 32000 + 22 * 200 = 36400 gas to create (the additional overhead of calling mint is only about 150 gas). If we could make use of address 0x0 for GasToken, we could save an extra 3000 gas or so for every created contract!

So there are gas savings. And the cost savings really depend on the usage. In this case, the usage is when new contracts are created which reference to another (short addressed) contract. Basically less bytes need to be stored.

I'm not sure if having zeros in method signature hashes help, but I guess it might. Haven't really encountered such. Anyway, in my opinion, modifying function names to get a desired hash for them is bad idea, since it makes the contract harder for humans to understand.

2
  • Thanks for the answer. My question is "HOW" much gas does it save
    – User
    Jun 7, 2021 at 11:46
  • There is no generic answer to that question. It depends on the implementation. I just gave you one example which states how much is saved Jun 7, 2021 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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