1

enter image description here

I ran into the eip-170 contract code size limitation. I need to trim it down. Do comments affect the size of the contract as I have a lot of them and don't mind getting rid of them.

1 Answers1

3

No, they affect only the contents of the hashed-metadata part in the bytecode, which is the 32 bytes (64 hexadecimal characters) which appear right before the last 2 bytes (4 hexadecimal characters).

The compiler appends a hash of the file's metadata (which includes your comments) at the end of the bytecode, so that you can retrieve this file in an authenticated manner.


UPDATE:

As of solc 0.5.x, those last 2 bytes have changed to 11 bytes (22 hexadecimal characters).

goodvibration
  • 26,003
  • 5
  • 46
  • 86
  • What do you recommend to reduce contract size? Is there a way to import Github files? I do not want to deploy it over the solidity compiler, I'd rather use remix. – Fifth Dimension Dragon Oct 22 '19 at 08:55
  • 1
    @NikLoladze: That would yield the exact same code, hence the exact same code size. You can try to reduce your actual code. Since you haven't posted it in a convenient manner (copyable plain text), the community here (with me included) will be kinda reluctant to help you with that. – goodvibration Oct 22 '19 at 08:58
  • Note to future readers: the metadata is in fact the 32 bytes (64 hexadecimal characters) which appear right before the last 2 bytes (4 hexadecimal characters). Also, starting from solc 0.5.x, those 2 bytes have changed to 11 bytes (22 hexadecimal characters). – goodvibration Nov 03 '20 at 14:19