Performance Engineering

Gas Optimization Services

We reduce your smart contract gas costs through systematic optimization. Storage packing, calldata efficiency, assembly techniques, and chain-specific tuning.

Why Gas Optimization Matters

Gas costs directly impact user adoption and protocol competitiveness. When a swap on your DEX costs twice as much as a competitor, users leave. When minting an NFT from your collection costs more than the NFT itself, collectors lose interest. When governance votes cost significant gas, participation drops. Arthiq provides systematic gas optimization that makes your contracts competitive on every chain.

Gas optimization is not about clever tricks — it is about understanding how the EVM executes bytecode, how storage is laid out, how calldata is encoded, and how each opcode contributes to total gas consumption. Our optimization approach is measured and systematic, profiling every function, identifying the highest-cost operations, and applying targeted techniques that reduce costs without sacrificing readability or security.

Different chains have different gas economics. On Ethereum L1, storage operations dominate costs. On L2s like Arbitrum and Base, calldata size drives fees because data must be posted to L1. On Polygon, gas is cheap enough that extreme optimization may not be worth the complexity. We optimize for the specific chain your contracts run on.

Storage Optimization Techniques

Storage reads and writes are among the most expensive EVM operations. We apply storage packing to fit multiple variables into single 32-byte storage slots, reducing both read and write costs. Careful ordering of struct fields, use of smaller integer types, and boolean packing can reduce storage costs by 50% or more.

We minimize storage writes by caching frequently accessed values in memory, using events for data that only needs to be read off-chain, and designing state transitions that combine multiple writes into single slot updates. For mappings, we use efficient key derivation that reduces storage overhead.

Immutable and constant variables are resolved at compile time and stored in contract bytecode rather than storage, eliminating runtime storage reads. We identify variables that never change after construction and convert them to immutable, providing free gas savings with no tradeoffs.

Calldata and Computation Optimization

On L2 rollups, calldata efficiency is the primary optimization target because calldata must be posted to L1. We reduce calldata size through efficient function parameter encoding, using bytes instead of string where possible, packing multiple parameters into single words, and designing APIs that minimize the data users must send.

Computational optimization reduces execution gas through loop unrolling, efficient conditional ordering (cheapest checks first), mathematical simplification, and strategic use of unchecked blocks for arithmetic that is guaranteed not to overflow. Each technique is applied only where it provides meaningful savings without introducing safety risks.

We also optimize contract deployment gas through minimal proxy patterns (EIP-1167) for factory contracts, constructor-time computation of derived values, and bytecode size reduction through code deduplication and library usage.

Assembly-Level Optimization

For performance-critical functions, we apply Yul assembly optimization that provides fine-grained control over EVM execution. Assembly allows us to skip unnecessary safety checks that the Solidity compiler inserts, use efficient memory layout patterns, and implement custom encoding logic that reduces overhead.

Common assembly optimizations include efficient keccak256 computation for mapping keys, custom ABI decoding that avoids the compiler's generic decoder overhead, bitwise operations for boolean arrays and small enum types, and direct storage access patterns that bypass Solidity's accessor overhead.

Every assembly optimization is thoroughly documented with comments explaining the equivalent Solidity code and the reasoning for the optimization. We also provide test suites that verify the assembly code produces identical results to the unoptimized version across all inputs. Readability and maintainability are never sacrificed for marginal gas savings.

Gas Profiling and Benchmarking

Our optimization process begins with comprehensive gas profiling. We use Foundry's gas snapshots to measure the gas cost of every external function under representative call patterns. This baseline identifies which functions consume the most gas and where optimization effort will have the greatest impact.

We set gas budgets for critical functions based on competitive analysis and user experience requirements. After each optimization round, we re-profile and compare against these budgets. This measured approach ensures that optimization effort is directed where it matters most.

Arthiq delivers gas-optimized contracts with detailed profiling reports showing the cost of every function before and after optimization. Our Singapore-based team combines EVM expertise with practical engineering judgment to deliver contracts that are fast, cheap, and maintainable. Contact founders@arthiq.co for a gas optimization engagement.

What We Deliver

  • Comprehensive gas profiling and benchmarking
  • Storage packing and layout optimization
  • Calldata efficiency for L2 cost reduction
  • Yul assembly optimization for critical paths
  • Minimal proxy and factory pattern optimization
  • Chain-specific optimization strategies
  • Gas budget setting and competitive analysis

Technologies We Use

SolidityYulFoundryHardhatSolidity CompilerEVMEtherscanTenderlyOpenZeppelinEIP-1167

Frequently Asked Questions

Savings vary by contract, but we typically achieve 20-60% gas reduction on unoptimized contracts. Some specific operations like batch minting or storage-heavy updates can see even larger improvements.
Our optimization never compromises security. We document every optimization, maintain comprehensive test suites, and avoid techniques that introduce subtle vulnerabilities. Assembly code is thoroughly tested and commented.
Yes. On L1, we focus on storage and computation costs. On L2s like Arbitrum and Base, we focus on calldata size since that drives the L1 data posting cost. Each chain gets a targeted optimization strategy.
If your contracts use proxy patterns, we can deploy gas-optimized implementations. For immutable contracts, we can optimize and redeploy, or design migration strategies to move users to optimized versions.
We use Foundry gas snapshots for function-level profiling, Tenderly for transaction simulation and gas breakdown, and custom scripts for comparative benchmarking across optimization iterations.

Need Lower Gas Costs?

We reduce transaction costs through systematic, measured optimization. Storage, calldata, computation, and assembly — every byte counts.