openzeppelin

Implements secure Solidity smart contracts using OpenZeppelin Contracts v5 libraries and patterns.

6|20|Updated Mar 14, 2026
One-click install
npx skills add https://github.com/andresdefi/cryptoskills --skill openzeppelin-andresdefi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: openzeppelin
Source: https://github.com/andresdefi/cryptoskills/tree/main/skills/openzeppelin
Command: npx skills add https://github.com/andresdefi/cryptoskills --skill openzeppelin-andresdefi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Most AI training data reflects OpenZeppelin v4, so generated Solidity code fails to compile against v5 due to breaking changes like mandatory Ownable constructor arguments, removed SafeMath and Counters libraries, renamed hook functions, and moved import paths. This Skill provides correct, current v5 patterns for tokens, access control, security utilities, and upgradeable contracts. ## Core Features & Use Cases - Token Implementations: Production-ready ERC-20, ERC-721, and ERC-1155 contracts with extensions like Permit, Votes, Enumerable, URIStorage, and ERC2981 royalties, including correct v5 override resolution for _update and _increaseBalance. - Access Control & Security: Ownable, Ownable2Step, AccessControl, AccessManager, ReentrancyGuard, Pausable, and SafeERC20 patterns with v5-specific fixes like _grantRole replacing _setupRole. - Upgradeable Contracts: Complete UUPS lifecycle with Initializable, reinitializer, ERC1967Proxy deployment, storage layout safety rules, and Foundry test coverage. - Use Case: When asked to write a governance token, the Skill produces an ERC20Votes contract with the correct nonces diamond-resolution override, a Governor with TimelockController, and a deployment script that compiles on the first try. ## Quick Start Ask the agent to write an ERC-20 token with permit and voting extensions using OpenZeppelin v5, or to migrate an existing v4 contract to v5.

Frequently Asked Questions about openzeppelin

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

FAQPage Schema
How do I create an ERC-20 token with OpenZeppelin v5?

Inherit from ERC20 and call _mint in the constructor with the desired supply. For extensions like Permit or Votes, add the inheritance and resolve the _update and nonces overrides explicitly, since v5 requires diamond resolution when combining ERC20Permit with ERC20Votes.

How to migrate OpenZeppelin contracts from v4 to v5?

Pass an initial owner to the Ownable constructor, replace _setupRole with _grantRole, replace _beforeTokenTransfer with _update, remove SafeMath and Counters, and move Pausable and ReentrancyGuard imports from security/ to utils/. ERC721Enumerable also requires a new _increaseBalance override.

Why does my Ownable contract fail to compile in OpenZeppelin v5?

OpenZeppelin v5 removed the default owner, so Ownable requires an initial owner address passed to its constructor. Write constructor(address initialOwner) Ownable(initialOwner) instead of inheriting Ownable with no arguments.

How do UUPS upgradeable contracts work with OpenZeppelin?

Use the contracts-upgradeable package with Initializable, UUPSUpgradeable, and an initialize function instead of a constructor. Deploy an ERC1967Proxy pointing to the implementation, gate _authorizeUpgrade with onlyOwner, and use reinitializer(n) for version-specific setup in later upgrades.

Does OpenZeppelin v5 still include SafeMath and Counters?

No, both were removed in v5. Solidity 0.8+ has built-in overflow checks making SafeMath unnecessary, and Counters was replaced by plain uint256 variables with the ++ operator.

Why does my ERC721Enumerable contract fail to compile in v5?

OpenZeppelin v5 requires overriding both _update and _increaseBalance when combining ERC721 with ERC721Enumerable. Add both overrides calling super, and list all parent contracts in the override specifier.