0

I've a smart contract that's already optimised but the bytecode is still 60kb. (~1.5k lines, comments excluded (I know lines does not matter but it's to give you a better idea))

It's an ERC20Token that includes RFI and Voting, that's why it's so big. I heard about proxies or diamond shape, but don't know if and how I can use it to reduce my smart contract.

Any idea on how I could make it smaller?

btw, I can deploy it on bsc-testnet, but can't use it in my tests inside brownie... weird stuff. Would love to hear your piece of advise, cheers!

1 Answer 1

1

This contract won't be deployable on mainnet.

You should look for a way to encode multiple argument into one.

Use external Libraries for storage.

And refactor in multiple smaller contract.

Breaking one large contract to multiple smaller contracts

There is no other way around your are stuck within these limits.

2
  • How can I use Libraries for storage? I already optimised the code to not have repetitive code and thus making libraries for them. Encoding multiple arguments are also already done and I can't make it more compact I think. Do you have any example of refactoring in multiple smaller contract? The token inherits from all of them in a way or another (Token is A, R - A is B - B is C - B is D) Commented Oct 26, 2021 at 21:00
  • There are plenty of article out there that will show you how to do this. Commented Oct 26, 2021 at 21:05

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.