Ownable¶
Title: | Ownable |
Description: | Zeppelin Solidity Smart Contract that provides ownership capabilities to a contract. |
Author: | Smart Contract Solutions, Inc. |
Solidity Version: | ^0.4.18 |
Relative Path: | ./contracts/supporting/Ownable.sol |
License: | MIT License |
Current Version: | 1.4.0 |
Original Source: | Ownable Source |
2. Variables¶
The following variables exist for the Ownable Smart Contract:
Variable | Type | Vis | Details |
owner | address | public | Variable containing the address of the contract owner |
4. Events¶
The following events exist for the Ownable Smart Contract:
Name | Description |
OwnershipTransferred | Event to track change of ownership |
OwnershipTransferred¶
Event Name: | OwnershipTransferred |
Description: | Event to track change of ownership |
Usage¶
The OwnershipTransferred event has the following usage syntax and arguments:
Argument | Type | Indexed? | Details | |
1 | previousOwner | address | Yes | Address of the previous owner |
2 | newOwner | address | Yes | Address of the new owner |
OwnershipTransferred(0x123456789abcdefghijklmnopqrstuvwxyz98765,
0x123456789abcdefghijklmnopqrstuvwxyz54321);
6. Modifiers¶
The following modifiers exist for the Ownable Smart Contract:
Name | Description |
onlyOwner | Modifier that requires the contract owner is the sender of the transaction |
onlyOwner¶
Modifier Name: | onlyOwner |
Description: | Modifier that requires the contract owner is the sender of the transaction |
7. Functions¶
The following functions exist for the Ownable Smart Contract:
Name | Description |
Ownable Constructor | Constructor Function for Ownable Contract |
transferOwnership | Function transfer the contract ownership |
Ownable Constructor¶
Function Name: | Ownable |
Description: | Constructor for the Ownable Smart Contract |
Function Type: | Constructor |
Function Visibility: | Public |
Function Modifiers: | N/A |
Return Type: | None |
Return Details: | N/A |
Code¶
The code for the Ownable Constructor function is as follows:
function Ownable() public {
owner = msg.sender;
}
The Ownable Constructor function performs the following:
- Sets the owner variable msg.sender
transferOwnership¶
Function Name: | transferOwnership |
Description: | Function transfer the contract ownership |
Function Type: | N/A |
Function Visibility: | Public |
Function Modifiers: | onlyOwner |
Return Type: | None |
Return Details: | N/A |
Code¶
The code for the transferOwnership function is as follows:
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
The transferOwnership function performs the following:
- Validates that the supplied newOwner argument is a valid Ethereum address. If it is not, it will throw.
- Fires the OwnershipTransferred event.
- sets the owner to the newOwner argument value.
Usage¶
The transferOwnership function has the following usage syntax:
transferOwnership(0x123456789abcdefghijklmnopqrstuvwxyz98765);