You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// SPDX-License-Identifier: GPL-3.0pragma solidity>=0.7.0<0.9.0;
import"hardhat/console.sol";
/** * @title Owner * @dev Set & change owner */contractOwner {
addressprivate owner;
// event for EVM loggingevent OwnerSet(addressindexedoldOwner, addressindexednewOwner);
// modifier to check if caller is ownermodifier isOwner() {
// If the first argument of 'require' evaluates to 'false', execution terminates and all// changes to the state and to Ether balances are reverted.// This used to consume all gas in old EVM versions, but not anymore.// It is often a good idea to use 'require' to check if functions are called correctly.// As a second argument, you can also provide an explanation about what went wrong.require(msg.sender== owner, "Caller is not owner");
_;
}
/** * @dev Set contract deployer as owner */constructor() {
console.log("Owner contract deployed by:", msg.sender);
owner =msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructoremitOwnerSet(address(0), owner);
}
/** * @dev Change owner * @param newOwner address of new owner */function changeOwner(addressnewOwner) public isOwner {
emitOwnerSet(owner, newOwner);
owner = newOwner;
}
/** * @dev Return owner address * @return address of owner */function getOwner() externalviewreturns (address) {
return owner;
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Beta Was this translation helpful? Give feedback.
All reactions