solidity-gas-optimization

Installation
SKILL.md

Solidity Gas Optimization

When to Apply

  • During contract development to reduce deployment and runtime costs.
  • When hitting the 24KB contract size limit.
  • When optimizing high-frequency functions (e.g., swaps, transfers).
  • When designing storage-heavy protocols.
  • Before final security audits to ensure efficiency doesn't compromise safety.

Critical Optimizations

Storage Layout Packing

EVM reads and writes in 32-byte (256-bit) slots. Variables smaller than 32 bytes that are declared consecutively share a slot, reducing SSTORE operations. A new SSTORE costs 20,000 gas; packing avoids additional slot allocations.

What to verify: Consecutive variables of the same or smaller combined size (≤32 bytes) are grouped together. Place uint128 next to uint128, not separated by a uint256.

Custom Errors vs Revert Strings

Installs
19
First Seen
Feb 15, 2026
solidity-gas-optimization — whackur/solidity-agent-toolkit