Skip to content

feat(config): allow overriding solc settings per contract #7720

@mds1

Description

@mds1

Component

Forge

Describe the feature you would like

The main use case for this is when one contract is close to the size limit—compile the large contract with 1 optimizer run (which minimizes code size) and compile the rest with larger values of optimizer runs.

In #3062 we were tracking this and had a potential UX but that issue was closed by the inline config PR, so I think we lost track of this feature request? Either way, the idea was :

# In our default solidity profile we apply 10M optimizer runs.
[profile.default.solidity]
optimizer = true
optimizer-runs = 10_000_000

# But we have one really big contract, so we use 1 optimizer run to minimize
# its size.
[profile.default.solidity.minimize_size]
optimizer = true
optimizer-runs = 1
match-contract = "MyBigContract" # all match flags supported

Hardhat has supported this for a long time, as seen here:

module.exports = {
  solidity: {
    compilers: [...],
    overrides: {
      "contracts/Foo.sol": {
        version: "0.5.5",
        settings: { }
      }
    }
  }
}

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions