solidity-security

Implements secure Solidity patterns to prevent reentrancy, overflow, and access control vulnerabilities.

Updated Apr 23, 2026
One-click install
npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill solidity-security-sanketadlak
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: solidity-security
Source: https://github.com/SanketAdlak/PDMProjectDesign/tree/main/.agents/skills/solidity-security
Command: npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill solidity-security-sanketadlak

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Smart contract bugs are irreversible and costly once deployed on-chain. This Skill helps developers write and audit Solidity contracts that resist common attack vectors like reentrancy, integer overflow, front-running, and broken access control. ## Core Features & Use Cases - Vulnerability Prevention Patterns: Apply Checks-Effects-Interactions, ReentrancyGuard, SafeMath, and commit-reveal schemes with concrete vulnerable-vs-secure code examples. - Security Best Practices: Implement pull-over-push payments, input validation, emergency stop (Pausable) circuit breakers, and role-based access control with OpenZeppelin. - Gas Optimization: Pack storage variables, use calldata over memory, and leverage events for cheaper data storage. - Use Case: Before deploying a DeFi vault contract, use this Skill to audit the withdrawal function for reentrancy, add a security checklist review, and write Hardhat tests that simulate attack scenarios. ## Quick Start Review my Solidity contract for reentrancy and access control vulnerabilities and rewrite the insecure functions using secure patterns.

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 attacks in Solidity?

Prevent reentrancy by following the Checks-Effects-Interactions pattern: update state before making external calls. Alternatively, inherit OpenZeppelin's ReentrancyGuard and apply the nonReentrant modifier to functions that transfer ETH or call external contracts.

How to fix integer overflow in Solidity smart contracts?

Use Solidity 0.8.0 or higher, which includes built-in overflow and underflow checks that automatically revert transactions. For older compiler versions, import OpenZeppelin's SafeMath library and use its add, sub, and mul functions for arithmetic.

What is the checks-effects-interactions pattern in Solidity?

Checks-effects-interactions is a function ordering pattern: first validate conditions with require statements, then update contract state, and finally make external calls. This ordering prevents reentrancy because state changes complete before any external contract can call back.

Does Solidity 0.8 still need SafeMath?

No, Solidity 0.8.0 and later include automatic overflow and underflow checks in the compiler, making SafeMath redundant. SafeMath is only necessary when maintaining contracts compiled with Solidity versions below 0.8.0.

Why is tx.origin unsafe for authentication in smart contracts?

tx.origin identifies the original externally owned account of a transaction chain, so a malicious intermediary contract can trick users into authorizing calls. Always use msg.sender for authentication, which identifies the immediate caller of the function.

How do I test smart contracts for security vulnerabilities with Hardhat?

Write Hardhat tests that simulate attack scenarios, such as deploying an attacker contract that attempts reentrant calls and asserting the transaction reverts. Use ethers.js with Chai matchers like expect(...).to.be.revertedWith to verify access control and overflow protections.