EVMTools

Contract Size Calculator

Check if your Solidity contract bytecode fits within the 24KB EIP-170 limit. Paste bytecode to see size, percentage used, and optimization tips.

What is EIP-170?

  • EIP-170 introduced a maximum deployed contract size of 24,576 bytes (24 KB) as part of the Spurious Dragon hard fork (Nov 2016).
  • This limit prevents denial-of-service attacks through excessively large contracts that would slow down the network.
  • The limit applies to the deployed bytecode (runtime code), not the creation/constructor bytecode.
  • EIP-3860 (Shanghai upgrade) also limits initcode to 49,152 bytes (2x the runtime limit).

Tips for Reducing Contract Size

  • Use libraries: Extract shared logic into external libraries to reduce duplicated bytecode.
  • Split contracts: Use the proxy pattern or diamond pattern (EIP-2535) to split logic across multiple contracts.
  • Shorter error messages: Replace long require/revert strings with custom errors (saves significant bytes).
  • Optimizer: Enable the Solidity optimizer with a low "runs" value (e.g., 200) to optimize for deployment size.
  • Remove unused code: Remove dead functions, unused imports, and debugging utilities before deployment.
  • Use via-IR: The Solidity via-IR pipeline can sometimes produce smaller bytecode.