ReleaseableToken

Title: ReleaseableToken
Description: Smart Contract derived from ReleaseableToken by Token Market with additional functionality for the TruReputationToken.
Author: Ian Bray, Tru Ltd
Solidity Version: 0.4.18
Relative Path: ./contracts/supporting/ReleaseableToken.sol
License: Apache 2 License
Current Version: 0.1.12
Original Source: ReleaseableToken Source

1. Imports & Dependencies

The following imports and dependencies exist for the ReleaseableToken Solidity Library:

Name Description
Ownable Zeppelin Solidity Smart Contract that provides ownership capabilities to a contract.
StandardToken Zeppelin Solidity Smart Contract for a Standard ERC-20 Token

2. Variables

The following variables exist for the ReleaseableToken Smart Contract:

Variable Type Vis Details
releaseAgent address public Variable containing the address of the Release Agent
released bool public

Variable for whether the token is released or not

Default: false

3. Enums

There are no enums for the ReleaseableToken Smart Contract.

4. Events

The following events exist for the ReleaseableToken Smart Contract:

Name Description
Released Event to notify when a token is released
ReleaseAgentSet Event to notify when a releaseAgent is set
TransferAgentSet Event to notify when a Transfer Agent is set or updated

Released

Event Name: Released
Description: Event to notify when a token is released

Usage

The Released event has the following usage syntax:

Released Usage Example
 Released();

ReleaseAgentSet

Event Name: ReleaseAgentSet
Description: Event to notify when a releaseAgent is set

Usage

The ReleaseAgentSet event has the following usage syntax and arguments:

  Argument Type Indexed? Details
1 releaseAgent address Yes Address of new releaseAgent
ReleaseAgentSet Usage Example
 ReleaseAgentSet(0x123456789abcdefghijklmnopqrstuvwxyz98765);

TransferAgentSet

Event Name: TransferAgentSet
Description: Event to notify when a Transfer Agent is set or updated

Usage

The TransferAgentSet event has the following usage syntax and arguments:

  Argument Type Indexed? Details
1 transferAgent address Yes Address of new Transfer Agent
2 status bool Yes Whether Transfer Agent is enabled or disabled
TransferAgentSet Usage Example
 TransferAgentSet(0x123456789abcdefghijklmnopqrstuvwxyz98765, true);

5. Mappings

The following mappings exist for the ReleaseableToken Smart Contract:

Name Mapping Type Description
transferAgents address => uint256 Mapping to status of transfer agents

6. Modifiers

The following modifiers exist for the ReleaseableToken Smart Contract:

Name Description
canTransfer Modifier that checks whether token is in a transferable state
inReleaseState Modifier that checks whether token is in a given released state
onlyReleaseAgent Modifier that checks whether the executor is the releaseAgent

canTransfer

Modifier Name: canTransfer
Description: Modifier that checks whether token is in a transferable state

Code

The code for the canTransfer modifier is as follows:

canTransfer Code
modifier canTransfer(address _sender) {
    require(released || transferAgents[_sender]);
    _;
}

The canTransfer function performs the following:

  • Checks that the released variable is true and that the _sender argument is in the transferAgents mapping otherwise it throws

inReleaseState

Modifier Name: inReleaseState
Description: Modifier that checks whether token is in a given released state

Code

The code for the inReleaseState modifier is as follows:

inReleaseState Code
modifier inReleaseState(bool releaseState) {
    require(releaseState == released);
    _;
}

The inReleaseState function performs the following:

  • Checks that the supplied releaseState argument matches the released variable otherwise it throws

onlyReleaseAgent

Modifier Name: onlyReleaseAgent
Description: Modifier that checks whether the executor is the releaseAgent

Code

The code for the onlyReleaseAgent modifier is as follows:

onlyReleaseAgent Code
modifier onlyReleaseAgent() {
    require(msg.sender == releaseAgent);
    _;
}

The onlyReleaseAgent function performs the following:

  • Checks that the transaction sender address matches the releaseAgent address otherwise it throws

7. Functions

The following functions exist for the ReleaseableToken Smart Contract:

Name Description
setReleaseAgent Function to set the* releaseAgent variable
setTransferAgent Function to set or update the* transferAgents mapping
releaseTokenTransfer Function to release the token
transfer Function to override transfer function
transferFrom Function to override transferFrom function

setReleaseAgent

Function Name: setReleaseAgent
Description: Function to set the* releaseAgent variable
Function Type: N/A
Function Visibility: Public
Function Modifiers: onlyOwner, inReleaseState
Return Type: None
Return Details: N/A

Code

The code for the setReleaseAgent function is as follows:

setReleaseAgent Code
function setReleaseAgent(address addr) public onlyOwner inReleaseState(false) {
    ReleaseAgentSet(addr);
    // We don't do interface check here as we might want to a normal wallet address to act as a release agent
    releaseAgent = addr;
}

The setReleaseAgent function performs the following:

  • Fires the ReleaseAgentSet event
  • Sets the releaseAgent variable to the addr argument

Usage

The setReleaseAgent function has the following usage syntax:

setReleaseAgent Usage Example
 setReleaseAgent(0x123456789abcdefghijklmnopqrstuvwxyz98765);

setTransferAgent

Function Name: setTransferAgent
Description: Function to set or update the* transferAgents mapping
Function Type: N/A
Function Visibility: Public
Function Modifiers: onlyOwner, inReleaseState
Return Type: None
Return Details: N/A

Code

The code for the setTransferAgent function is as follows:

setTransferAgent Code
function setTransferAgent(address addr, bool state) public onlyOwner inReleaseState(false) {
    TransferAgentSet(addr, state);
    transferAgents[addr] = state;
}

The setTransferAgent function performs the following:

  • Fires the TransferAgentSet event
  • Add the supplied addr and state to the transferAgents mapping

Usage

The setTransferAgent function has the following usage syntax:

setTransferAgent Usage Example
setTransferAgent(0x123456789abcdefghijklmnopqrstuvwxyz98765, true);

releaseTokenTransfer

Function Name: releaseTokenTransfer
Description: Function to release the token
Function Type: N/A
Function Visibility: Public
Function Modifiers: onlyReleaseAgent
Return Type: None
Return Details: N/A

Code

The code for the releaseTokenTransfer function is as follows:

releaseTokenTransfer Code
function releaseTokenTransfer() public onlyReleaseAgent {
    Released();
    released = true;
}

The releaseTokenTransfer function performs the following:

  • Fires the Released event
  • Sets the released variable to true

Usage

The releaseTokenTransfer function has the following usage syntax:

releaseTokenTransfer Usage Example
releaseTokenTransfer();

transfer

Function Name: transfer
Description: Function to override transfer function
Function Type: N/A
Function Visibility: Public
Function Modifiers: canTransfer
Return Type: bool
Return Details: Returns whether the transfer was successful or not

Code

The code for the transfer function is as follows:

transfer Code
function transfer(address _to,
                  uint _value) public canTransfer(msg.sender) returns (bool success) {
    return super.transfer(_to, _value);
}

The transfer function performs the following:

Usage

The transfer function has the following usage syntax and arguments:

  Argument Type Details
1 _to address Address to be sent _value to
2 _value uint Value of tokens to send to _to address
transfer Usage Example
 transfer(0x123456789abcdefghijklmnopqrstuvwxyz98765, true);

transferFrom

Function Name: transferFrom
Description: Function to override transferFrom function
Function Type: N/A
Function Visibility: Public
Function Modifiers: canTransfer
Return Type: bool
Return Details: Returns whether the transferFrom was successful or not

Code

The code for the transferFrom function is as follows:

transferFrom Code
function transferFrom(address _from,
                      address _to,
                      uint _value) public canTransfer(_from) returns (bool success) {
    return super.transferFrom(_from, _to, _value);
}

The transferFrom function performs the following:

Usage

The transferFrom function has the following usage syntax and arguments:

  Argument Type Details
1 _fro address Address to be sent _value from
2 _to address Address to be sent _value to
3 _value uint Value of tokens to send to _to address
transferFrom Usage Example
 transferFrom(0x123456789abcdefghijklmnopqrstuvwxyz98765,
              0x423456789abcdefghijklmnopqrstuvwxyz12345,
              true);