gas-optimization

Reduce deployment and runtime gas costs for Solidity contracts.

120|12|Updated Apr 10, 2026
One-click install
npx skills add https://github.com/ccashwell/evm-cortex --skill gas-optimization-ccashwell
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gas-optimization
Source: https://github.com/ccashwell/evm-cortex/tree/main/skills/gas-optimization
Command: npx skills add https://github.com/ccashwell/evm-cortex --skill gas-optimization-ccashwell

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Tackle high gas costs in Solidity by applying proven optimization patterns during development and auditing.

Core Features & Use Cases

  • Calldata vs Memory: prefer calldata for read-only external parameters to avoid unnecessary copies.
  • Immutable and Constant: use immutable and constant values to reduce storage reads and bytecode size.
  • Unchecked Arithmetic: wrap loops and counters with unchecked where overflow is impossible to save gas.
  • Storage Packing: align and pack frequently accessed variables to minimize storage slots.
  • Batch Operations: amortize fixed overhead across multiple operations to lower per-call gas.
  • Precompute Hashes: precompute keccak256 where possible to reduce runtime costs.

Quick Start

Audit a Solidity contract for gas-heavy paths and apply these patterns to reduce deployment and runtime gas.

Frequently Asked Questions about gas-optimization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce Solidity gas costs for smart contract deployment and runtime?

Reduce Solidity gas costs by applying proven patterns like using calldata for read-only parameters, immutable variables for constants, unchecked arithmetic for safe loops, and storage packing to minimize accessed storage slots.

What is storage packing in Solidity and how does it save gas?

Storage packing in Solidity aligns and packs frequently accessed variables into a single storage slot to minimize expensive storage reads and writes during contract execution.

When should I use calldata instead of memory in Solidity functions?

Use calldata instead of memory for read-only external function parameters to avoid unnecessary memory copies and significantly reduce execution gas costs.

Can I use unchecked arithmetic in Solidity loops to optimize gas?

Use unchecked arithmetic in Solidity loops and counters where overflow is impossible to save gas by bypassing redundant overflow checks.

What is the best way to lower per-call gas for batch operations in smart contracts?

Batch operations lower per-call gas by amortizing fixed transaction overhead across multiple operations within a single smart contract call.

How do precomputed hashes optimize runtime gas in Solidity contracts?

Precompute keccak256 hashes where possible to reduce runtime gas costs by avoiding repeated hash calculations during Solidity contract execution.