2

The error that happens to me when I make a large contract. My contract cannot be split up into multiple contracts, it needs to all be one (particularly large) contract.

Warning: Contract code size is 24888 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries.
--> main.sol:16:1:
|
16 | contract ERC20 is IERC20 {
| ^ (Relevant source part starts here and spans across multiple lines).

I understand that this is induced by the size of the contract byte code, which is changed by the size of the contract. But why is there an error for this, and why may it actually be not deployable on mainnet?

A possible solution that I have thought is that the post will exceed the block gas limit, but I think it is probably something else. Please let me know the answer, thank you!

1

2 Answers 2

1

Here's something you can try that might work

Enable the optimizer in solidity

pragma solidity ^0.8.0;

// Enable the optimizer with 200 runs
pragma solidity optimizer enabled 200;

or alternatively if you are using Remix IDE you can enable this setting directly using GUI as follow

enter image description here

Hope that works for you Good Luck

0

The cause of this limit. I still do not know how to fix it, without decreasing functionality, especially if my contract is about triple the limit.

https://eips.ethereum.org/EIPS/eip-170

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.