- Home
- Skills
- Raintree Technology
- Claude Starter
- Gas Optimization
gas-optimization_skill
62
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill raintree-technology/claude-starter --skill gas-optimization- SKILL.md3.7 KB
Overview
This skill is an Aptos gas and performance optimization expert for Move smart contracts. It focuses on minimizing gas costs and improving execution throughput by applying practical strategies like data-structure selection, function inlining, struct packing, event optimizations, and parallel-safe aggregators. The guidance is platform-agnostic and aimed at production-ready Move code.
How this skill works
The skill inspects Move smart contract patterns and recommends targeted changes that reduce Execution, Storage, and IO gas. It highlights tradeoffs between vectors, Table, and SmartTable, when to use aggregators for parallel counters, how to emit cheaper Event V2, and where to inline or cache values. It also guides on running gas profiling and interpreting profiles to prioritize optimizations.
When to use it
- Before mainnet deployment to reduce predictable gas spikes and storage costs.
- When profiling test transactions shows hotspots or large execution gas.
- When handling large datasets (thousands to 100k+ entries) where data structure choice matters.
- When global counters or high-concurrency updates must scale without contention.
Best practices
- Prefer Table or SmartTable for large maps; use vector/SimpleMap only for small lists (<1000).
- Use Aggregator for global counters to enable parallel-safe increments and lower contention.
- Inline trivial helper functions and cache loop lengths to avoid repeated calls in hot loops.
- Pack struct fields (group booleans or use bitmaps) to reduce storage and IO gas.
- Emit Event V2 for cheaper events and batch operations to amortize per-transaction overhead.
- Run gas profiling (aptos move test --gas) and act on the top contributors first.
Example use cases
- Converting a user registry from vector to Table to avoid O(n) writes on large datasets.
- Replacing a global u64 counter with Aggregator to allow concurrent increments across txns.
- Refactoring hot loops to cache vector::length and inline simple helpers to lower execution gas.
- Packing struct flags into a bitmap to reduce storage bytes and per-write gas.
- Batching multiple transfers in a single entry function to reduce repeated transaction overhead.
FAQ
Use SmartTable for very large datasets (100k+ entries) where backend optimizations and storage layout reduce gas and IO compared with Table.
Does using Aggregator always save gas?
Aggregators save contention and enable parallel increments, but evaluate access patterns—if you rarely update a counter, the benefit is smaller than for high-concurrency scenarios.