Skip to content

Commit

Permalink
Create Owner.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Jul 27, 2024
1 parent 897d438 commit 13b8631
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
pragma solidity ^0.8.0;

contract Owner {
address public owner;
address public newOwner;

event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

modifier onlyOwner() {
require(msg.sender == owner, "Only the owner can call this function");
_;
}

constructor() public {
owner = msg.sender;
}

function transferOwnership(address _newOwner) public onlyOwner {
newOwner = _newOwner;
}

function acceptOwnership() public {
require(msg.sender == newOwner, "Only the new owner can accept ownership");
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
newOwner = address(0);
}
}

0 comments on commit 13b8631

Please sign in to comment.