Solidity Gas Optimization
Analyzes Solidity code to identify gas optimization opportunities, suggesting improvements for reduced transaction costs.
Install on your platform
We auto-selected Claude Code based on this skill’s supported platforms.
Run in terminal (recommended)
claude mcp add solidity-gas-optimization npx -- -y @trustedskills/solidity-gas-optimization
Or manually add to ~/.claude/settings.json
{
"mcpServers": {
"solidity-gas-optimization": {
"command": "npx",
"args": [
"-y",
"@trustedskills/solidity-gas-optimization"
]
}
}
}Requires Claude Code (claude CLI). Run claude --version to verify your install.
About This Skill
What it does
This skill provides a comprehensive guide to optimizing gas costs in Solidity smart contracts. It offers over 80 techniques, categorized by impact and risk, drawing from the RareSkills Book of Gas Optimization. The tool helps developers identify areas for improvement in their code, leading to reduced transaction fees during deployment or execution.
When to use it
- When writing new Solidity smart contracts.
- During reviews or audits of existing contracts.
- To optimize gas costs before deploying a contract.
- When refactoring storage layouts within a contract.
- When implementing interactions between different smart contracts.
- When choosing between different design patterns (e.g., ERC721 vs ERC1155).
Key capabilities
- Storage Optimization: Techniques to minimize gas usage related to data stored on the blockchain.
- Deployment Optimization: Strategies for reducing gas costs during contract deployment.
- Calldata Optimization: Methods for efficiently handling function input data.
- Design Pattern Guidance: Recommendations for selecting efficient design patterns, including token standards like ERC721 and ERC1155.
- Cross-Contract Call Optimization: Techniques to reduce gas costs when interacting between contracts.
- Compiler Optimization Suggestions: Advice on leveraging compiler features to improve gas efficiency.
Example prompts
- "Analyze this Solidity code for potential gas optimization opportunities." (followed by the code)
- "What are some strategies for storage optimization in Solidity?"
- "Should I use ERC721 or ERC1155 for my NFT project, and why?"
Tips & gotchas
- Prioritize "Storage Optimization" techniques first as they have the most critical impact.
- Be cautious when applying "Dangerous Techniques," as they carry a high risk of introducing vulnerabilities.
- Consider using
bytes calldatainstead ofbytes memoryin function parameters to avoid unnecessary data copying.
Tags
TrustedSkills Verification
Unlike other registries that point to live repositories, TrustedSkills pins every skill to a verified commit hash. This protects you from malicious updates — what you install today is exactly what was reviewed and verified.
Security Audits
| Gen Agent Trust Hub | Pass |
| Socket | Pass |
| Snyk | Pass |
🌐 Community
Passed automated security scans.