OpenZeppelin Contracts: Secure smart contract library
A library of audited Solidity components for secure smart contract development on Ethereum and EVM-compatible chains.
Learn more about OpenZeppelin Contracts
OpenZeppelin Contracts is a library of reusable Solidity smart contract components designed for secure blockchain development. The library provides implementations of standard token contracts (ERC20, ERC721, ERC1155), access control mechanisms, and utility functions that developers can inherit and extend. All contracts undergo rigorous security audits and follow semantic versioning to ensure backwards compatibility and safe upgrades. The library is commonly used as a foundation for building decentralized applications, token systems, and complex blockchain protocols.
Audited Security
All stable releases undergo comprehensive security audits and are covered by a bug bounty program. The library follows rigorous security practices and maintains a detailed security policy.
Standard Implementations
Provides battle-tested implementations of Ethereum standards including ERC20, ERC721, ERC1155, and ERC6909 tokens. Includes flexible role-based access control and permission systems.
Upgrade Safety
Uses semantic versioning to communicate API and storage layout compatibility. Provides clear guidance on safe upgrade paths for upgradeable contract systems.
pragma solidity ^0.8.20;
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
contract MyCollectible is ERC721 {
uint256 private _tokenIdCounter;
constructor() ERC721("MyCollectible", "MCO") {
_tokenIdCounter = 0;
}
function mint(address to) public {
uint256 tokenId = _tokenIdCounter;
_tokenIdCounter++;
_mint(to, tokenId);
}
function totalSupply() public view returns (uint256) {
return _tokenIdCounter;
}
}Adds ERC-165 detection for IERC6909ContentURI, IERC6909TokenSupply and IERC6909Metadata interfaces.
- –Add ERC-165 detection for the IERC6909ContentURI, IERC6909TokenSupply and IERC6909Metadata interfaces in the ERC6909ContentURI, ERC6909TokenSupply and ERC6909Metadata contracts respectively
Prevents setting operators for address(0) in ERC721 and ERC1155, updates ERC-4337 entrypoint to v0.9, and improves batch transfer handling.
- –ERC721 and ERC1155: Prevent setting an operator for address(0). In the case of ERC721 this type of operator allowance could lead to obfuscated mint permission
- –Account: Update default version of the ERC-4337 entrypoint to v0.9
- –AccountERC7579: Do not revert and perform the uninstall if the onUninstall hook of a module reverts
- –ERC1155: Introduce the _checkAuthorized internal virtual function to encapsulate isApprovedForAll and msg.sender == from checks
- –ERC1155: Call IERC1155Receiver.onERC1155BatchReceived when performing a batch transfers with exactly one id/value in the batch
Fixes ERC165Checker revert handling, renames SignerERC7702 to SignerEIP7702, and adds InteroperableAddress library for ERC-7930 support.
- –ERC165Checker: Ensure the supportsERC165 function returns false if the target reverts during the supportsInterface(0xffffffff) call
- –SignerERC7702 is renamed as SignerEIP7702. Imports and inheritance must be updated to that new name and path. Behavior is unmodified
- –ECDSA signature malleability protection is partly deprecated. See documentation for more details
- –ERC4626: compute maxWithdraw using maxRedeem and previewRedeem so that changes to the preview functions affect the max functions
- –InteroperableAddress: Add a library for formatting and parsing ERC-7930 interoperable addresses
Related Repositories
Discover similar tools and frameworks used by developers
Substrate
A modular framework for building custom blockchains with configurable consensus and runtime logic.
Sui
A blockchain platform using Move programming language with parallel transaction processing and asset-oriented design.
Solmate
A collection of gas-optimized Solidity contracts including ERC token implementations and utility libraries.
Solidity StringUtils
A gas-efficient string utility library for Solidity using slice abstractions for string manipulation operations.
Optimism
Layer 2 blockchain that scales Ethereum using optimistic rollup technology and the open-source OP Stack framework.