Ownable
Create a contract that has an owner and only the owner can assign a new owner.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract Ownable {
address public owner;
constructor() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner, "not owner");
_;
}
function setOwner(address _newOwner) external onlyOwner {
require(_newOwner != address(0), "new owner = zero address");
owner = _newOwner;
}
}
Last updated
Was this helpful?