gas-struct-packing

July 4, 2025 ยท View on GitHub

Recommended Badge Category Badge Default Severity Badge warn

The {"extends": "solhint:recommended"} property in a configuration file enables this rule.

Description

Suggest to re-arrange struct packing order when it is inefficient

Options

This rule accepts a string option for rule severity. Must be one of "error", "warn", "off". Defaults to warn.

Example Config

{
  "rules": {
    "gas-struct-packing": "warn"
  }
}

Notes

  • This rule assumes all UserDefinedTypeName take a new slot. (beware of Enums inside Structs)
  • Simple cases like a struct with three addresses might be reported as false positive. (needs to be fixed)
  • source 1 of the rule initiative (Variable Packing)
  • source 2 of the rule initiative

Examples

This rule does not have examples.

Version

This rule was introduced in Solhint 4.5.0

Resources