This repository has not been audited.
Use at your own risk. Do not use in production environments without a proper security review.
A lightweight Solidity security utilities library.
This repository contains reusable, security-focused smart contract modules, inspired by OpenZeppelin’s battle-tested security patterns, rebuilt from scratch with modern Solidity features.
Instead of just importing libraries, this project is about rebuilding and learning:
- 🛡 Deep Security Understanding – Writing security primitives line-by-line.
- ⛽ Gas-Optimized Patterns – Exploring efficient implementations.
- 🧪 Rigorous Testing – Unit, fuzz, and invariant tests.
- 🌍 Open Source Learning – Sharing progress with the community.
- 🔒 Reentrancy Protection (ReentrancyGuard)
- 👑 Ownership & Access Control (Kingable)
- ⛽ Modern Gas-Optimized Security Patterns
- ReentrancyGuard → Prevents reentrant calls
- Kingable → Custom ownership & access control
🔜 Coming Soon:
- Pausable → Emergency stop pattern
- PullPayment → Safer ETH transfers
You can import contracts directly from GitHub in your Solidity files:
Example: ReentrancyGuard
import "https://github.com/BuildsWithKing/buildswithking-security/blob/main/contracts/security/ReentrancyGuard.sol";💡 Best Practice: Pin to a specific commit hash for safety:
import "https://github.com/BuildsWithKing/buildswithking-security/blob/<commit-hash>/contracts/security/ReentrancyGuard.sol";forge install BuildsWithKing/buildswithking-securitySpecific version:
forge install BuildsWithKing/buildswithking-security@v1.3.0Add this to foundry.toml:
remappings = [
"buildswithking-security/=lib/buildswithking-security/contracts/"
]
Usage Example:
import {Kingable} from "buildswithking-security/access/core/Kingable.sol";
import {ReentrancyGuard} from "buildswithking-security/security/ReentrancyGuard.sol";
contract MyContract is Kingable, ReentrancyGuard {
// Your secure logic here
}git clone --branch v1.3.0 https://github.com/BuildsWithKing/buildswithking-security.git lib/buildswithking-securityThen configure your foundry.toml the same way as above.
Pull requests are welcome! 🚀
If you’d like to add new security modules or improve existing ones, fork the repo and open a PR.
All contributions will be reviewed for security soundness and code quality before merging.
Built and maintained by Michealking (@BuildsWithKing)
This project is licensed under the MIT License.
Current stable release: v1.3.0