Skip to content

Instantly share code, notes, and snippets.

@libert-xyz
Created August 20, 2022 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save libert-xyz/7aa47a09a95fcfef0dbb919473b2f4b5 to your computer and use it in GitHub Desktop.
Save libert-xyz/7aa47a09a95fcfef0dbb919473b2f4b5 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.16+commit.07a7930e.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract Ownable {
address public owner;
uint public counter;
uint public counterPublic;
constructor () {
owner = msg.sender; //set the owner at deploy time
}
modifier isOwner(address _owner) {
require(_owner == owner, "You are not the owner");
_;
}
function onlyOwnercanIncrease() external isOwner(msg.sender) {
counter += 1;
}
function transferOwnership(address _newOwner) external isOwner(msg.sender) {
require (_newOwner != address(0), "Set a valid address");
owner = _newOwner;
}
function publicFunction() external {
counterPublic += 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment