Ethereum-Solidity Quiz Q7: What is the 'solc optimizer' in Solidity?

Published: (December 28, 2025 at 12:53 PM EST)
1 min read
Source: Dev.to

Source: Dev.to

Cover image for Ethereum-Solidity Quiz Q7: What is the "solc optimizer" in Solidity?

What is the solc optimizer?

The solc optimizer is built into the Solidity compiler and is used to reduce gas costs by optimizing the compiled bytecode. It analyzes the code and makes optimizations such as removing dead code, simplifying expressions, and reorganizing operations to use less gas. It is used across multiple tools, including Foundry, Hardhat, Truffle, and Remix.

Optimizer runs

The optimizer has a configurable parameter called optimizer runs. This number represents roughly how many times you expect the contract to be called.

  • Higher values (e.g., 2000) optimize for lower runtime gas costs, which is beneficial for contracts that are called frequently.
  • Lower values (e.g., 1–50) optimize for lower deployment costs.

Example: Foundry

[profile.default]
optimizer = true
optimizer_runs = 2000

Example: Hardhat

solidity: {
  version: "0.8.20",
  settings: {
    optimizer: {
      enabled: true,
      runs: 1
    }
  }
}
Back to Blog

Related posts

Read more »