solidity-security

Mitigate vulnerabilities in Solidity smart contracts using secure development patterns.

322|45|Updated Dec 1, 2025
One-click install
npx skills add https://github.com/Microck/ordinary-claude-skills --skill solidity-security
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: solidity-security
Source: https://github.com/Microck/ordinary-claude-skills/tree/main/solidity-security
Command: npx skills add https://github.com/Microck/ordinary-claude-skills --skill solidity-security

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires openzeppelin-contracts, hardhat, chai, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

Developing secure Solidity smart contracts is critical yet challenging, with common vulnerabilities like reentrancy and integer overflows leading to significant financial losses. This Skill provides best practices and patterns to prevent these issues and build robust blockchain applications.

Core Features & Use Cases

  • Vulnerability Prevention: Implement secure patterns to guard against reentrancy, integer overflow/underflow, and access control issues.
  • Gas Optimization: Learn and apply techniques to reduce transaction costs while maintaining contract security.
  • Audit Preparation: Structure and document your contracts for professional security audits, ensuring compliance and trust.
  • Use Case: When writing a new DeFi smart contract, use this skill to review your code for common vulnerabilities, apply the Checks-Effects-Interactions pattern, and ensure proper access control, significantly reducing the risk of exploits.

Quick Start

Review my Solidity contract for reentrancy vulnerabilities and suggest fixes using the Checks-Effects-Interactions pattern.

Frequently Asked Questions about solidity-security

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

FAQPage Schema
How do I prevent reentrancy vulnerabilities in my Solidity smart contracts?

Reentrancy vulnerabilities occur when a contract calls an external function before updating its state, allowing attackers to recursively drain funds. Apply the Checks-Effects-Interactions pattern: validate conditions first, update internal state second, then interact with external contracts. This ensures state changes complete before external calls can re-enter your code.

What's the best way to protect against integer overflow and underflow in Solidity?

Integer overflow and underflow happen when arithmetic operations exceed fixed-size integer bounds, corrupting calculations and enabling exploits. Use OpenZeppelin Contracts' SafeMath library or Solidity 0.8+ built-in overflow checks, which revert transactions on unsafe arithmetic and prevent silent data corruption.

How do I implement proper access control in smart contracts?

Access control restricts sensitive functions to authorized users, preventing unauthorized fund transfers or state changes. Implement role-based access using OpenZeppelin's AccessControl or ownership patterns, assigning specific roles with granular permissions and enforcing checks before executing protected operations.

Can I optimize gas costs without sacrificing security in Solidity?

Gas optimization reduces transaction fees while maintaining contract safety. Apply techniques like efficient storage layouts, batch operations, and avoiding redundant state reads—all supported by OpenZeppelin best practices—ensuring your optimizations don't weaken security patterns or introduce vulnerabilities.

How do I prepare my smart contract for a professional security audit?

Audit-ready contracts follow established security patterns, include clear documentation, and handle known attack vectors like reentrancy and front-running. Structure your code using Checks-Effects-Interactions, implement access control, apply safe arithmetic, and document design decisions so auditors can verify security comprehensively.

What are common front-running attack patterns I should mitigate?

Front-running occurs when attackers observe pending transactions and submit higher-priority transactions to manipulate execution order or outcomes. Mitigate by minimizing sensitive state exposure, using commit-reveal schemes, avoiding transaction ordering dependencies, and designing contracts where transaction order doesn't leak value.