Why Your Solidity Contract Wouldn’t Deploy — And How One Number Fixed It

This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).

A debugging story about a Solidity contract deployment that hung indefinitely on a custom testnet. The root cause was the optimizer_runs setting in foundry.toml being set to 1000, which caused the compiler to generate larger bytecode (15,434 bytes) consuming over 3.1 million gas — exceeding the testnet's block gas limit. Dropping optimizer_runs to 100 shrank the bytecode enough to deploy successfully. The post explains what optimizer_runs actually controls (a deployment-to-call ratio hint, not iteration count), when to use low vs. high values, Ethereum's 24KB hard contract size limit (EIP-170), the EIP-1167 minimal proxy pattern as a long-term factory solution, and a practical Foundry debugging checklist for stuck pending transactions.

6m read timeFrom coinsbench.com
Post cover image

Sort: