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.

2

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).

3
  • 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. – Nik Loladze Oct 22 '19 at 8: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 8: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 3 '20 at 14:19

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.