Solidity Bytecode Size Analyzer

Check compiled contract bytecode against the 24 KB size limit and estimate the minimum deployment gas, before you deploy to mainnet.

Did this tool help? Rate it Be the first to rate this tool

Check the 24 KB contract size limit

Ethereum rejects contracts whose deployed code is larger than 24,576 bytes, a rule introduced by EIP-170, and since EIP-3860 it also rejects creation code over 49,152 bytes. Paste the compiled bytecode from Hardhat, Foundry, Remix or solc and this tool tells you how close you are, how many bytes you have to spare, and a floor estimate for the gas needed to deploy it.

Runtime versus creation bytecode

  • Runtime (deployed) bytecode is what stays on the chain. It is the one the 24 KB limit applies to. In Hardhat it is the deployedBytecode field, and in Foundry it is the deployedBytecode in the artifact.
  • Creation (init) bytecode is runtime code plus the constructor and is what the deployment transaction carries. It is checked against the 49,152 byte initcode limit.

How the gas estimate works

A deployment pays 21,000 base gas, 32,000 for contract creation, and calldata gas of 4 per zero byte and 16 per non-zero byte. Contracts then pay 200 gas for every byte of runtime code stored, and EIP-3860 adds 2 gas per 32-byte word of initcode. The estimate cannot include what your constructor does when it runs, such as writing storage or calling other contracts, so treat it as the minimum and measure the real cost on a test network.

Ways to shrink a large contract

Enable the optimizer with a low runs value, use custom errors in place of revert strings, remove unused code, move shared logic into libraries, and split big systems across several contracts. Other chains and test networks can have different limits, and some allow larger contracts, so check the one you deploy to. Foundry and Hardhat can also print contract sizes during a build.

The 24 KB limit

Ethereum limits deployed contract code to 24,576 bytes under EIP-170. If the compiled runtime bytecode is larger, deployment fails. Make sure you check runtime bytecode, not creation bytecode.

Reducing size

Enable the optimizer with a suitable number of runs, move code into libraries, remove unused functions, use custom errors instead of long revert strings and split a contract into several using proxies or the diamond pattern.

Gas considerations

Deployment cost grows with bytecode size, so smaller contracts are cheaper to deploy, though over-optimising for size can raise runtime gas. Measure both with your test suite.

Deploy checks

Use the compiler's size report or a Hardhat or Foundry plugin to track bytecode size on every build. Check runtime size with the optimizer on, because it often lowers size. If you are close to the limit, plan to split logic across contracts early, since refactoring later is harder. Test deployment on a local node and a testnet before mainnet, and review audits for each upgrade.

Testing and tooling

Add a size check to continuous integration so a build fails when a contract nears the limit. Foundry and Hardhat both have options to print contract sizes. Review compiler version and optimizer runs, because they change size and gas. Keep a record of results for each release.

Frequently asked questions

Which bytecode should I paste?

Paste the runtime bytecode to check the 24 KB limit. Paste the creation bytecode to check the initcode limit.

Where do I find the bytecode?

In Hardhat or Foundry build artifacts (bytecode and deployedBytecode fields), in Remix under Compilation Details, or from solc with the --bin and --bin-runtime options.

Is the gas figure exact?

No. It is a floor that leaves out the constructor's execution and any storage writes, so the real deployment cost is higher.

Does this limit apply on every chain?

Ethereum mainnet enforces it. Many EVM chains copy it, but some change or remove it, so check your target chain.

Is my bytecode uploaded?

No. The analysis runs in your browser.

More in Web3 & Crypto SEO Tools