Haltable

Title: Haltable
Description: Modified Token Market Smart Contract that provides a capability to halt a contract (namely a CrowdSale). Updated by Tru Ltd.
Author: TokenMarket Ltd/Updated by Ian Bray, Tru Ltd
Solidity Version: 0.4.18
Relative Path: ./contracts/supporting/Haltable.sol
License: Apache 2 License
Current Version: 0.1.12
Original Source: Haltable Source

1. Imports & Dependencies

The following imports and dependencies exist for the Haltable Smart Contract:

Name Description
Ownable Zeppelin Solidity Smart Contract for Ownership capabilities in a token

2. Variables

The following variables exist for the Haltable Smart Contract:

Variable Type Vis Details
halted bool public Variable to indicate whether the contract is halted or not

3. Enums

There are no enums for the Haltable Smart Contract.

4. Events

The following events exist for the Haltable Smart Contract:

Name Description
HaltStatus Event to track halted status changes

HaltStatus

Event Name: HaltStatus
Description: Event to track halted status changes

Usage

The HaltStatus event has the following usage syntax and arguments:

  Argument Type Indexed? Details
1 status bool No Whether the contract is halted or not
HaltStatus Usage Example
 HaltStatus(true);

5. Mappings

The are no mappings for the Haltable Smart Contract.

6. Modifiers

The following modifiers exist for the Haltable Smart Contract:

Name Description
stopInEmergency Modifier that requires the contract is not halted
onlyInEmergency Modifier that requires the contract is halted

stopInEmergency

Modifier Name: stopInEmergency
Description: Modifier that requires the contract is not halted

Code

The code for the stopInEmergency modifier is as follows:

stopInEmergency Code
modifier stopInEmergency {
    require(!halted);
    _;
}

The stopInEmergency function performs the following:

  • Checks that the halted variable is false otherwise it throws

onlyInEmergency

Modifier Name: onlyInEmergency
Description: Modifier that requires the contract is halted

Code

The code for the onlyInEmergency modifier is as follows:

onlyInEmergency Code
modifier onlyInEmergency {
    require(halted);
    _;
}

The onlyInEmergency function performs the following:

  • Checks that the halted variable is true otherwise it throws

7. Functions

The following functions exist for the Haltable Smart Contract:

Name Description
halt Function to halt the contract
unhalt Function to unhalt the contract

halt

Function Name: halt
Description: Function to halt the contract
Function Type: N/A
Function Visibility: External
Function Modifiers: onlyOwner
Return Type: None
Return Details: N/A

Code

The code for the halt function is as follows:

halt Code
function halt() external onlyOwner {
    halted = true;
    HaltStatus(halted);
}

The halt function performs the following:

  • Sets the halted variable to true
  • Fires the HaltStatus event

Usage

The halt function has the following usage syntax:

halt Usage Example
 halt();

unhalt

Function Name: unhalt
Description: Function to unhalt the contract
Function Type: N/A
Function Visibility: External
Function Modifiers: onlyOwner, onlyInEmergency
Return Type: None
Return Details: N/A

Code

The code for the unhalt function is as follows:

unhalt Code
function unhalt() external onlyOwner onlyInEmergency {
    halted = false;
    HaltStatus(halted);
}

The unhalt function performs the following:

  • Sets the halted variable to false
  • Fires the HaltStatus event

Usage

The unhalt function has the following usage syntax:

unhalt Usage Example
 unhalt();