hi, i was just wondering if anyone can guide me a bit on what this do ?
contract Ownable {
address public owner;
event onOwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != address(0));
emit onOwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
Apr 8, 2021, 3:27 AM
it handles ownership operation, so you don't have to implement it yourself in the contract you are writing
Apr 8, 2021, 3:48 AM
This contracts specifies the deployer of the smart contract inherited from it as the owner. It also defines a modifier for functions such that these functions can only be called by the owner. Lastly, the ownership, with which the owner can call functoins requiring it, can be transferred to a new owner.
Apr 8, 2021, 4:51 AM
Thanks a lot
Apr 8, 2021, 4:52 AM