TruMintableToken

Title: TruMintableToken
Description: Smart Contract derived from MintableToken by Zeppelin Solidity with additional functionality for the TruReputationToken.
Author: Ian Bray, Tru Ltd; derived from MintableToken
Solidity Version: ^0.4.18
Relative Path: ./contracts/supporting/TruMintableToken.sol
License: Apache 2 License
Current Version: 0.1.9
Original Source: MintableToken

1. Imports & Dependencies

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

Name Description
SafeMath Zeppelin Solidity Library to perform mathematics safely inside Solidity
TruAddress Solidity Library of helper functions surrounding the Address type in Solidity.
ReleaseableToken Token Market Contract that allows control over when a Token can be released.

2. Variables

The following variables exist for the TruMintableToken Smart Contract:

Variable Type Vis Details
mintingFinished bool public

Variable to mark if minting is finished for this token

Default: false

preSaleComplete bool public

Variable to mark if the Pre-Sale is complete for this

Default: false

saleComplete bool public

Variable to mark if the CrowdSale is complete for this

Default: false

3. Enums

There are no enums for the TruMintableToken Smart Contract.

4. Events

The following events for the TruMintableToken Smart Contract:

Name Description
Minted Event to track when tokens are minted
MintFinished Event to notify when minting is finalised and finished
PreSaleComplete Event to notify when a Pre-Sale is complete
SaleComplete Event to notify when a CrowdSale is complete

Minted

Event Name: Minted
Description: Event to track when tokens are minted

Usage

The Minted event has the following usage syntax and arguments:

  Argument Type Indexed? Details
1 _to address Yes Address tokens have been minted to
2 _amount uint256 No Amount of tokens minted
Minted Usage Example
Minted(0x123456789abcdefghijklmnopqrstuvwxyz98765, 100);

MintFinished

Event Name: MintFinished
Description: Event to notify when minting is finalised and finished

Usage

The MintFinished event has the following usage syntax and arguments:

  Argument Type Indexed? Details
1 _executor address Yes Address that executed the MintFinished event
MintFinished Usage Example
MintFinished(0x123456789abcdefghijklmnopqrstuvwxyz98765);

PreSaleComplete

Event Name: PreSaleComplete
Description: Event to notify when a Pre-Sale is complete

Usage

The PreSaleComplete event has the following usage syntax and arguments:

  Argument Type Indexed? Details
1 _executor address Yes Address that executed the PreSaleComplete event
PreSaleComplete Usage Example
PreSaleComplete(0x123456789abcdefghijklmnopqrstuvwxyz98765);

SaleComplete

Event Name: SaleComplete
Description: Event to notify when a CrowdSale is complete

Usage

The SaleComplete event has the following usage syntax and arguments:

  Argument Type Indexed? Details
1 _executor address Yes Address that executed the SaleComplete event
SaleComplete Usage Example
SaleComplete(0x123456789abcdefghijklmnopqrstuvwxyz98765);

5. Mappings

There are no mappings for the TruMintableToken Smart Contract.

6. Modifiers

The following modifiers exist for the TruMintableToken Smart Contract:

Name Description
canMint Modifier to check the Token can mint

canMint

Modifier Name: canMint
Description: Modifier to check if minting has finished for this token or not

Code

The code for the canMint modifier is as follows:

canMint Code
modifier canMint() {
    require(!mintingFinished);
    _;
}

The canMint function performs the following:

  • Checks that the mintingFinished variable is false otherwise it throws

7. Functions

The following functions exist for the TruMintableToken Smart Contract:

Name Description
mint Function to mint tokens
finishMinting Function to stop minting new tokens.

mint

Function Name: mint
Description: Function to mint tokens
Function Type: Pure
Function Visibility: Public
Function Modifiers: onlyOwner, canMint
Return Type: Bool
Return Details: Returns whether mint completed successfully

Code

The code for the mint function is as follows:

mint Code
function mint(address _to, uint256 _amount) public onlyOwner canMint returns (bool) {
    require(_amount > 0);
    require(TruAddress.isValid(_to) == true);

    totalSupply = totalSupply.add(_amount);
    balances[_to] = balances[_to].add(_amount);
    Minted(_to, _amount);
    Transfer(0x0, _to, _amount);
    return true;
}

The mint function performs the following:

  • Checks the supplied _amount is greater than 0
  • Checks the supplied _to address is valid
  • Adds the newly minted amount to the totalSupply of tokens
  • Transfers the newly minted tokens to the recipient
  • Fires the Minted event
  • Fires the Transfer event
  • returns true

Usage

The mint function has the following usage syntax and arguments:

  Argument Type Details
1 _to address | Address to mint tokens to
2 _amount uint256 | Amount of tokens to mint
mint Usage Example
mint(0x123456789abcdefghijklmnopqrstuvwxyz98765);

finishMinting

Function Name: finishMinting
Description: Function to mint tokens
Function Type: Pure
Function Visibility: Public
Function Modifiers: onlyOwner, canMint
Return Type: Bool
Return Details: Returns whether mint completed successfully

Code

The code for the finishMinting function is as follows:

finishMinting Code
function finishMinting(bool _presale, bool _sale) public onlyOwner returns (bool) {
    require(_sale != _presale);

    if (_presale == true) {
        preSaleComplete = true;
        PreSaleComplete();
        return true;
    }

    require(preSaleComplete == true);
    saleComplete = true;
    SaleComplete();
    mintingFinished = true;
    MintFinished();
    return true;
}

The finishMinting function performs the following:

  • Ensures that the _presale and _sale argument do not match (one must be true, the other false)
  • If _presale argument is true, change the preSaleComplete variable to true, fire the PreSaleComplete event and return true
  • If _sale argument is true, change the saleComplete variable to true, fire the SaleComplete event, set the mintingFinished variable to true, fire the MintFinished event and return true

Usage

The finishMinting function has the following usage syntax and arguments:

  Argument Type Details
1 _presale bool Whether this call is from the Pre-Sale or not
2 _sale bool Whether this call is from the CrowdSale or not
finishMinting Usage Example
finishMinting(true, false);