TruReputationToken

Title: TruReputationToken
Description: Smart Contract for the Tru Reputation Token
Author: Ian Bray, Tru Ltd
Solidity Version: 0.4.18
Relative Path: ./contracts/TruReputationToken.sol
License: Apache 2 License
Current Version: 0.1.9

1. Imports & Dependencies

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

Name Description
SafeMath Zeppelin Solidity Library to perform mathematics safely inside Solidity
TruAddress Library of helper functions surrounding the Solidity Address type
TruMintableToken Smart Contract derived from MintableToken by Zeppelin Solidity with additional functionality.
TruUpgradeableToken Smart Contract derived from UpgradeableToken by Token Market with additional functionality.

2. Variables

The following variables exist for the TruReputationToken Smart Contract:

Variable Type Vis Details
decimals uint8 public

Constant variable for number of decimals token supports

Default: 18

name string public

Constant variable for public name of the token

Default Tru Reputation Token

symbol string public

Constant variable for public symbol of the token

Default: TRU

execBoard address public

Variable containing address of the Tru Ltd Executive Board

Default: 0x0

3. Enums

There are no enums for the TruReputationToken Smart Contract.

4. Events

The following events exist for the TruReputationToken Solidity Library:

Name Description
BoardAddressChanged Event to notify when the execBoard address changes

BoardAddressChanged

Event Name: BoardAddressChanged
Description: Event to notify when the execBoard address changes

Usage

The BoardAddressChanged event has the following usage syntax and arguments:

  Argument Type Indexed? Details
1 oldAddress address Yes Source wallet that the older tokens are sent from
2 newAddress address Yes Address of the destination for upgraded tokens which is hardcoded to the upgradeAgent who sends them back to the originating address
3 executor address Yes Address that executed the BoardAddressChanged event
BoardAddressChanged Usage Example
 BoardAddressChanged(0x123456789abcdefghijklmnopqrstuvwxyz98765,
                         0x123456789abcdefghijklmnopqrstuvwxyz01234);

5. Mappings

There are no mappings for the TruReputationToken Smart Contract.

6. Modifiers

The following modifiers exist for the TruReputationToken Smart Contract:

Name Description
onlyExecBoard Modifier to check the Tru Advisory Board is executing this call

onlyExecBoard

Modifier Name: onlyExecBoard
Description: Modifier to check the Tru Advisory Board is executing this call

Code

The code for the onlyExecBoard modifier is as follows:

onlyExecBoard Code
modifier onlyExecBoard() {
    require(msg.sender == execBoard);
    _;
}

The onlyExecBoard function performs the following:

  • Checks that the msg.sender matches the execBoard variable

7. Functions

The following functions exist for the TruReputationToken Smart Contract:

Name Description
TruReputationToken Constructor Constructor for the TruReputationToken Smart Contract
changeBoardAddress Function to change the execBoard variable
canUpgrade Override of canUpgrade function
setUpgradeMaster Override of setUpgradeMaster function

TruReputationToken Constructor

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

Code

The code for the TruReputationToken Constructor function is as follows:

TruReputationToken Constructor Code
function TruReputationToken() public TruUpgradeableToken(msg.sender) {
    execBoard = msg.sender;
    BoardAddressChanged(0x0, msg.sender);
}

The TruReputationToken Constructor function performs the following:

  • Executes the TruUpgradeableToken constructor as part of its construction.
  • Sets the initial execBoard variable to msg.sender
  • Fires the BoardAddressChanged event

Usage

The TruReputationToken Constructor function has the following usage syntax and arguments:

  Argument Type Details
1 _upgradeMaster address Address to be set as the Upgrade Master
TruReputationToken Constructor Usage Example
 TruReputationToken(0x123456789abcdefghijklmnopqrstuvwxyz98765);

changeBoardAddress

Function Name: changeBoardAddress
Description: Function to change the execBoard variable
Function Type: N/A
Function Visibility: Public
Function Modifiers: onlyExecBoard
Return Type: None
Return Details: N/A

Code

The code for the changeBoardAddress function is as follows:

changeBoardAddress Code
function changeBoardAddress(address _newAddress) public onlyExecBoard {
    require(TruAddress.isValid(_newAddress) == true);
    require(_newAddress != execBoard);
    address oldAddress = execBoard;
    execBoard = _newAddress;
    BoardAddressChanged(oldAddress, _newAddress);
}

The changeBoardAddress function performs the following:

  • Checks the _newAddress argument is a valid Ethereum Address. If not, it will throw
  • Checks the _newAddress argument is not the same as the current execBoard variable. If it is, it will throw;
  • Sets the execBoard variable to the _newAddress argument.
  • Fires the BoardAddressChanged event

Usage

The changeBoardAddress function has the following usage syntax and arguments:

  Argument Type Details
1 _newAddress address Address to be set as the new Tru Advisory Board Address
changeBoardAddress Usage Example
 changeBoardAddress(0x123456789abcdefghijklmnopqrstuvwxyz98765);

canUpgrade

Function Name: canUpgrade
Description: Override of canUpgrade function
Function Type: Constant
Function Visibility: Public
Function Modifiers: None
Return Type: bool
Return Details: Returns true if the token is in an upgradeable state

Code

The code for the canUpgrade override function is as follows:

canUpgrade Code
function canUpgrade() public constant returns(bool) {
    return released && super.canUpgrade();
}

The canUpgrade function performs the following:

  • If the released variable and super.canUpgrade() are true, returns true; otherwise returns false

Usage

The canUpgrade function has the following usage syntax:

canUpgrade Usage Example
 canUpgrade();

setUpgradeMaster

Function Name: setUpgradeMaster
Description: Override of setUpgradeMaster function
Function Type: N/A
Function Visibility: Public
Function Modifiers: onlyOwner
Return Type: bool
Return Details: Returns true if the token is in an upgradeable state

Code

The code for the setUpgradeMaster override function is as follows:

setUpgradeMaster Code
 function setUpgradeMaster(address master) public onlyOwner {
     super.setUpgradeMaster(master);
 }

The setUpgradeMaster function performs the following:

Usage

The setUpgradeMaster function has the following usage syntax and arguments:

  Argument Type Details
1 _master address Address to be set as the new Upgrade Master Contract
setUpgradeMaster Usage Example
 setUpgradeMaster(0x123456789abcdefghijklmnopqrstuvwxyz98765);