Solidity Security
Master smart contract security best practices, vulnerability prevention, and secure Solidity development patterns.
When to Use This Skill
- Writing secure smart contracts
- Auditing existing contracts for vulnerabilities
- Implementing secure DeFi protocols
- Preventing reentrancy, overflow, and access control issues
- Optimizing gas usage while maintaining security
- Preparing contracts for professional audits
- Understanding common attack vectors
Detailed patterns and worked examples
Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.
Testing for Security
// Hardhat test example
const { expect } = require("chai");
const { ethers } = require("hardhat");
describe("Security Tests", function () {
it("Should prevent reentrancy attack", () {
[attacker] = ethers.();
= ethers.();
bank = .();
= ethers.();
attackerContract = .(bank.);
bank.({ : ethers..() });
(
attackerContract.({ : ethers..() }),
)...();
});
(, () {
= ethers.();
token = .();
(token.(attacker., ethers..))
...;
});
(, () {
[owner, attacker] = ethers.();
= ethers.();
contract = .();
(contract.(attacker).())...(
,
);
});
});