Search⌘ K
AI Features

Ownability

Discover how to use the Ownable design pattern in Solidity with OpenZeppelin. Learn to define an owner role, restrict function access, transfer ownership, and renounce ownership to balance decentralization and control.

OpenZeppelin

OpenZeppelin is an open-source framework that gives us access to audited implementations of all sorts of standard design patterns and Ethereum Improvement Proposals. This framework can be installed on a server running Node.js using the following command:

npm install @openzeppelin/contracts

This gives us the ability to import OpenZeppelin code in Solidity, with the moniker @openzeppelin, and allows our contract to inherit from OpenZeppelin, as follows:

Solidity
import "@openzeppelin/contracts/access/Ownable.sol";
pragma solidity >=0.4.0 <0.7.0;
contract X is Ownable{}

It's also possible to store OpenZeppelin ...