Skip to content

Instantly share code, notes, and snippets.

@ArslanKathia
Created February 6, 2023 17:38
Show Gist options
  • Save ArslanKathia/54e33a48595094895042f044adc8a7fa to your computer and use it in GitHub Desktop.
Save ArslanKathia/54e33a48595094895042f044adc8a7fa to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
contract Ownable{
address public owner;
event OwnershipTransferred(address indexed _previousOwner, address indexed newOnwer);
modifier onlyOwner{
require(owner == msg.sender,"Only Owner can access this");
_;
}
constructor(){
owner = msg.sender;
}
function getCurrentOwner() public view returns(address){
return owner;
}
function transferOwnership(address _newOwner) public onlyOwner{
require(_newOwner != address(0),"New Owner Address is invalid");
owner = _newOwner;
emit OwnershipTransferred(msg.sender,owner);
}
function renounceOwnership() public virtual onlyOwner{
owner = address(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment