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 |
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(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(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(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 |
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:
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:
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:
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(true, false);