TruCrowdSale¶
The TruCrowdSale Smart Contract acts a child class to the TruSale and is used for the main CrowdSale of the TruReputationToken.
Title: | TruCrowdSale |
Description: | Smart Contract for the CrowdSale of the TruReputationToken. |
Author: | Ian Bray, Tru Ltd |
Solidity Version: | 0.4.18 |
Relative Path: | ./contracts/TruCrowdSale.sol |
License: | Apache 2 License |
Current Version: | 0.1.9 |
1. Imports & Dependencies¶
The following imports and dependencies exist for the TruCrowdSale Smart Contract:
Name | Description |
TruSale | Parent Smart Contract for all TruReputationToken Token Sales |
TruReputationToken | Smart Contract for the Tru Reputation Token |
SafeMath | Zeppelin Solidity Library to perform mathematics safely inside Solidity |
2. Variables¶
The following variables exist for the TruCrowdSale Smart Contract:
Variable | Type | Vis | Details |
TOTAL_CAP | uint256 | public | Variable for the Total cap for the Crowdsale & Pre-Sale |
existingSupply | uint256 | private | Variable containing the existing TruReputationToken supply. |
3. Enums¶
There are no enums for the TruCrowdSale Smart Contract.
4. Events¶
There are no events for the TruCrowdSale Smart Contract.
5. Mappings¶
There are no mappings for the TruCrowdSale Smart Contract.
6. Modifiers¶
There are no modifiers for the TruCrowdSale Smart Contract.
7. Functions¶
The following functions exist for the TruCrowdSale Smart Contract:
Name | Description |
TruCrowdSale Constructor | Constructor for the TruCrowdSale Smart Contract |
finalise | Function to finalise CrowdSale. |
completion | Internal function to complete CrowdSale. |
TruCrowdSale Constructor¶
Function Name: | TruCrowdSale |
Description: | Constructor for the TruCrowdSale Smart Contract |
Function Type: | Constructor |
Function Visibility: | Public |
Function Modifiers: | N/A |
Return Type: | None |
Return Details: | N/A |
Code¶
The code for the TruCrowdSale Constructor function is as follows:
function TruCrowdSale(
uint256 _startTime,
uint256 _endTime,
address _token,
address _saleWallet,
uint256 _currentSupply,
uint256 _currentRaise) public TruSale(_startTime, _endTime, _token, _saleWallet)
{
isPreSale = false;
isCrowdSale = true;
uint256 remainingCap = TOTAL_CAP.sub(_currentRaise);
cap = remainingCap;
existingSupply = _currentSupply;
}
The TruCrowdSale Constructor function performs the following:
- Executes the super TruSale Constructor function.
- Sets the isPreSale variable to false.
- Sets the isCrowdSale variable to true.
- Calculates the cap variable by removing the _currentRaise argument from the TOTAL_CAP variable.
- Sets existingSupply variable to the _currentSupply argument.
Usage¶
The TruCrowdSale Constructor function has the following usage syntax and arguments:
Argument | Type | Details | |
1 | _startTime | uint256 | Sale start timestamp |
2 | _endTime | uint256 | Sale end timestamp |
3 | _token | address | Address of TruReputationToken Contract |
4 | _saleWallet | address | Address of TruCrowdSale wallet |
5 | _currentSupply | uint256 | Current amount of TruReputationToken tokens issued. |
6 | _currentRaise | uint256 | Current amount of ETH raised in the TruPreSale |
TruCrowdSale(1511930475,
1512016874,
0x123456789abcdefghijklmnopqrstuvwxyz98765,
0x987654321abcdefghijklmnopqrstuvwxyz12345,
8000000000000000000000,
10000000000000000000000000);
finalise¶
Function Name: | finalise |
Description: | Function to finalise CrowdSale. |
Function Type: | N/A |
Function Visibility: | Public |
Function Modifiers: | ref:ownable-only-owner |
Return Type: | None |
Return Details: | N/A |
Code¶
The code for the finalise function is as follows:
function finalise() public onlyOwner {
require(!isCompleted);
require(hasEnded());
completion();
Completed();
isCompleted = true;
}
The finalise function performs the following:
- Checks that the isCompleted variable is set to false. If not, it will throw.
- Checks the hasEnded function returns true. If not, it will throw.
- Executes the completion function.
- Fires the Completed event.
- Sets isCompleted variable to true.
completion¶
Function Name: | completion |
Description: | Internal function to complete CrowdSale. |
Function Type: | N/A |
Function Visibility: | Internal |
Function Modifiers: | N/A |
Return Type: | None |
Return Details: | N/A |
Code¶
The code for the completion function is as follows:
function completion() internal {
// Double sold pool to allocate to Tru Resource Pools
uint256 poolTokens = truToken.totalSupply();
poolTokens = poolTokens.sub(existingSupply);
// Issue poolTokens to multisig wallet
truToken.mint(multiSigWallet, poolTokens);
truToken.finishMinting(false, true);
truToken.transferOwnership(msg.sender);
truToken.releaseTokenTransfer();
}
The completion function performs the following:
- Calculates the number of tokens sold in this CrowdSale and mints the same amount again into the multiSigWallet Sale wallet for use by Tru Ltd as per the Tru Reputation Protocol Whitepaper.
- Executes the finishMinting function to finalise all minting activity for the TruReputationToken
- Transfers ownership of the TruReputationToken back to the executing account now the Crowdsale is complete.
- Executes releaseTokenTransfer function.