The Ownable contract is common smart contract access restriction pattern. In its essence the ownable smart contract allows for a single user to have "super-user" privileges in the context of this smart contract.
Upon deployment, the user that deploys the contract is marked as "owner" in the owner variable.
The "onlyOwner" function, when executed, throws if the caller of the function is not the "owner". Put onlyOwner
into your contract methods to restrict them to the contract owner.
owner()
- returns the address of the contract ownerisOwner()
- return true if the Call.caller is the contract owneronlyOwner()
- throws if the Call.caller is not the contract ownertransferOwnership(newOwner: address)
- transfers the ownership over a contract, to a new owner specified by thenewOwner
address. Callable only by the ownerrenounceOwnership()
- Using this method, the owner of the contract can resign from his duties. Callable only by the owner.