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

1. Imports & Dependencies

There are no imports and dependencies for the Ownable Smart Contract.

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

3. Enums

There are no enums for the Ownable Smart Contract.

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 Usage Example
OwnershipTransferred(0x123456789abcdefghijklmnopqrstuvwxyz98765,
                     0x123456789abcdefghijklmnopqrstuvwxyz54321);

5. Mappings

The are no mappings for the Ownable Smart Contract.

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

Code

The code for the onlyOwner modifier is as follows:

onlyOwner 1.4.0 Code
modifier onlyOwner() {
    require(msg.sender == owner);
    _;
}

The onlyOwner function performs the following:

  • Checks that the transaction sender address is the same as the owner address variable otherwise it throws

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:

Ownable Constructor 1.4.0 Code
function Ownable() public {
    owner = msg.sender;
}

The Ownable Constructor function performs the following:

  • Sets the owner variable msg.sender

Usage

The Ownable Constructor function has the following usage syntax:

Ownable Constructor Usage Example
 Ownable();

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:

transferOwnership 1.4.0 Code
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 Usage Example
 transferOwnership(0x123456789abcdefghijklmnopqrstuvwxyz98765);