TruPreSale

The TruPreSale Smart Contract acts a child class to the TruSale and is used for the main CrowdSale of the TruReputationToken.

Title: TruPreSale
Description: Smart Contract for the Pre-Sale of the TruReputationToken.
Author: Ian Bray, Tru Ltd
Solidity Version: 0.4.18
Relative Path: ./contracts/TruPreSale.sol
License: Apache 2 License
Current Version: 0.1.12

1. Imports & Dependencies

The following imports and dependencies exist for the TruPreSale 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 TruPreSale Smart Contract:

Variable Type Vis Details
PRESALE_CAP uint256 public

Variable for the Pre-Sale cap

Default: 8000 * 10^18

3. Enums

There are no enums for the TruPreSale Smart Contract.

4. Events

There are no events for the TruPreSale Smart Contract.

5. Mappings

There are no mappings for the TruPreSale Smart Contract.

6. Modifiers

There are no modifiers for the TruPreSale Smart Contract.

7. Functions

The following functions exist for the TruPreSale Smart Contract:

Name Description
TruPreSale Constructor Constructor for the TruPreSale Smart Contract
finalise Function to finalise Pre-Sale.
completion Internal function to complete Pre-Sale.

TruPreSale Constructor

Function Name: TruPreSale
Description: Constructor for the TruPreSale Smart Contract
Function Type: Constructor
Function Visibility: Public
Function Modifiers: N/A
Return Type: None
Return Details: N/A

Code

The code for the TruPreSale Constructor function is as follows:

TruPreSale Constructor Code
unction TruPreSale(
    uint256 _startTime,
    uint256 _endTime,
    address _token,
    address _saleWallet) public TruSale(_startTime, _endTime, _token, _saleWallet)
{
        isPreSale = true;
        isCrowdSale = false;
        cap = PRESALE_CAP;
}

The TruPreSale Constructor function performs the following:

  • Executes the super TruSale Constructor function.
  • Sets the isPreSale variable to true.
  • Sets the isCrowdSale variable to false.
  • Set the cap variable to equal the PRESALE_CAP variable value.

Usage

The TruPreSale 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 TruPreSale wallet
TruPreSale Constructor Usage Example
 TruPreSale(1511930475,
              1512016874,
              0x123456789abcdefghijklmnopqrstuvwxyz98765,
              0x987654321abcdefghijklmnopqrstuvwxyz12345);

finalise

Function Name: finalise
Description: Function to finalise Pre-Sale.
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:

finalise Code
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.

Usage

The finalise function has the following usage syntax:

finalise Usage Example
finalise();

completion

Function Name: completion
Description: Internal function to complete Pre-Sale.
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:

completion Code
function completion() internal {

    // Double sold pool to allocate to Tru Resource Pools
    uint256 poolTokens = truToken.totalSupply();

    // Issue poolTokens to multisig wallet
    truToken.mint(multiSigWallet, poolTokens);
    truToken.finishMinting(true, false);
    truToken.transferOwnership(msg.sender);
}

The completion function performs the following:

  • Calculates the number of tokens sold in this Pre-Sale 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 end Pre-Sale minting and await CrowdSale minting
  • Transfers ownership of the TruReputationToken back to the executing account now the Pre-Sale is complete.

Usage

The completion function has the following usage syntax:

completion Usage Example
completion();