Skip to content

TKN ‐ TokenCard

BokkyPooBah edited this page May 7, 2017 · 1 revision

Table of contents



Token Information



Token Contract Information



Market Making Information

Creating Your Trade Contract

If you want to list an TKN TokenTrader contract on https://cryptoderivatives.market, use the TokenTraderFactory contract.

Execute createTradeContract(address asset, uint256 buyPrice, uint256 sellPrice, uint256 units, bool buysTokens, bool sellsTokens) to create your TKN TokenTrader contract.

The formula for working out the buyPrice or sellPrice follows:

rate = price / units * 10^(tokenDecimals - etherDecimals)

which is:

rate = price / units * 10^(tokenDecimals - 18)

and tokenDecimals = 8, so:

rate = price / units * 10^-10

or:

price = rates * units * 10^10

Watching Your Trade Contract

Find your newly created Trade contract on https://cryptoderivatives.market/tokenTraderContracts. Watch this contract address using the ABI at How To Watch A TokenTrader Contract In Ethereum Wallet / Mist.

Depositing Tokens

Use the TKN token contract to transfer your tokens to your newly created TokenTrader address.

Depositing Ethers

Execute your TokenTrader.makerDepositEther() function, sending the amount of ethers.



How To Watch The Token Contract In Ethereum Wallet / Mist

In Ethereum Wallet / Mist, select the CONTRACTS tab and click WATCH CONTRACT to open the Watch contract window. Then:

  • Under CONTRACT NAME, enter TKN

  • Under CONTRACT ADDRESS, enter 0xaaaf91d9b90df800df4f55c205fd6989c977e73a

  • Copy the Application Binary Interface below and paste it into the JSON INTERFACE text box

    [{"constant":false,"inputs":[],"name":"Launch","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"lockedTokenHolder","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"finalizeRemainders","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"lockTokenHolder","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"claimOwnerSupply","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address"},{"name":"amount","type":"uint256"}],"name":"mint","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_amount","type":"uint256"}],"name":"burn","outputs":[{"name":"result","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"neverPauseAgain","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_subtractedValue","type":"uint256"}],"name":"decreaseApproval","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"currentSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"launched","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"day","type":"uint256"}],"name":"setOwnerFreeDay","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"tokenholder","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"mintingDone","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"pausingMechanismLocked","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_controller","type":"address"}],"name":"setController","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"remaindersSet","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"data","type":"uint256[]"}],"name":"multiMint","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"remainingOwner","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"changeOwner","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"completeMinting","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"ownerTokensFreeDay","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"}],"name":"claimAuctionableTokens","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_remainingOwner","type":"uint256"},{"name":"_remainingAuctionable","type":"uint256"}],"name":"setRemainders","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"remainingAuctionable","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_addedValue","type":"uint256"}],"name":"increaseApproval","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"claimTokens","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_th","type":"address"}],"name":"setTokenHolder","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"controller","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"token","type":"address"},{"indexed":false,"name":"to","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"logTokenTransfer","type":"event"}]

  • Click OK



How To Watch The Token In Ethereum Wallet / Mist

In Ethereum Wallet / Mist, select the CONTRACTS tab and click WATCH TOKEN to open the Add token window. Then:

  • Under TOKEN CONTRACT ADDRESS, enter 0xaaaf91d9b90df800df4f55c205fd6989c977e73a. The additional fields should automatically be filled in.

  • Click OK



How To Check Your Token Balance In Ethereum Wallet / Mist

Watch The Token Contract, then:

  • Click on the TKN contract
  • Click on SHOW CONTRACT INFO
  • In the READ FROM CONTRACT section and under Balance of:
  • Enter the address you want to check the token balance of
  • The token balance will be displayed in the Natural Units with 8 decimal places, e.g., 123000000 is 123000000 / 1e8 = 1.23 token units



How To Transfer Your Tokens In Ethereum Wallet / Mist

Watch The Token Contract, then:

  • Click on the TKN contract
  • Click on SHOW CONTRACT INFO
  • In the WRITE TO CONTRACT section and under Select function:
  • Select the Transfer function
  • Under to, enter the address you want to transfer the token to
  • Under value, enter the amount of tokens you want to transfer. This amount needs to be specified in the natural units with 8 decimal places, e.g., 123000000 is 123000000 / 1e8 = 1.23 token units
  • Under Execute from, select the account you want to transfer your tokens from
  • Click on Execute, then confirm your transaction



The Token Contract Source Code

The verified source code can be found at 0xaaaf91d9b90df800df4f55c205fd6989c977e73a and follows:

pragma solidity >=0.4.4;

// Copyright 2017 Alchemy Limited LLC, Do not distribute

contract Constants {
    uint DECIMALS = 8;
}


contract Owned {
    address public owner;

    modifier onlyOwner() {
        if (msg.sender != owner) throw;
        _;
    }

    address newOwner;

    function changeOwner(address _newOwner) onlyOwner {
        newOwner = _newOwner;
    }

    function acceptOwnership() {
        if (msg.sender == newOwner) {
            owner = newOwner;
        }
    }
}

//from Zeppelin
contract SafeMath {
    function safeMul(uint a, uint b) internal returns (uint) {
        uint c = a * b;
        assert(a == 0 || c / a == b);
        return c;
    }

    function safeSub(uint a, uint b) internal returns (uint) {
        assert(b <= a);
        return a - b;
    }

    function safeAdd(uint a, uint b) internal returns (uint) {
        uint c = a + b;
        assert(c>=a && c>=b);
        return c;
    }

    function assert(bool assertion) internal {
        if (!assertion) throw;
    }
}



//Copyright 2017 Alchemy Limited LLC DO not distribute
//ERC20 token

contract Token is SafeMath, Owned, Constants {
    uint public currentSupply;
    uint public remainingOwner;
    uint public remainingAuctionable;
    uint public ownerTokensFreeDay;
    bool public launched = false;

    bool public remaindersSet = false;
    bool public mintingDone = false;

    address public controller;

    string public name;
    uint8 public decimals;
    string public symbol;

    modifier onlyController() {
        if (msg.sender != controller) throw;
        _;
    }

    modifier isLaunched() {
        assert(launched == true);
        _;
    }

    modifier onlyPayloadSize(uint numwords) {
        assert(msg.data.length == numwords * 32 + 4);
        _;
    }

    function Token() {
        owner = msg.sender;
        name = "Monolith TKN";
        decimals = uint8(DECIMALS);
        symbol = "TKN";
    }

    function Launch() onlyOwner {
        launched = true;
    }

    function setOwnerFreeDay(uint day) onlyOwner {
        if (ownerTokensFreeDay != 0) throw;

        ownerTokensFreeDay = day;
    }

    function totalSupply() constant returns(uint) {
        return currentSupply + remainingOwner;
    }

    function setRemainders(uint _remainingOwner, uint _remainingAuctionable) onlyOwner {
        if (remaindersSet) { throw; }

        remainingOwner = _remainingOwner;
        remainingAuctionable = _remainingAuctionable;
    }

    function finalizeRemainders() onlyOwner {
        remaindersSet = true;
    }

    function setController(address _controller) onlyOwner {
        controller = _controller;
    }

    function claimOwnerSupply() onlyOwner {
        if (now < ownerTokensFreeDay) throw;
        if (remainingOwner == 0) throw;
        if (!remaindersSet) throw; // must finalize remainders

        balanceOf[owner] = safeAdd(balanceOf[owner], remainingOwner);
        remainingOwner = 0;
    }

    function claimAuctionableTokens(uint amount) onlyController {
        if (amount > remainingAuctionable) throw;

        balanceOf[controller] = safeAdd(balanceOf[controller], amount);
        currentSupply = safeAdd(currentSupply, amount);
        remainingAuctionable = safeSub(remainingAuctionable,amount);

        Transfer(0, controller, amount);
    }

    event Transfer(address indexed from, address indexed to, uint value);
    event Approval(address indexed owner, address indexed spender, uint value);

    function mint(address addr, uint amount) onlyOwner onlyPayloadSize(2) {
        if (mintingDone) throw;

        balanceOf[addr] = safeAdd(balanceOf[addr], amount);

        currentSupply = safeAdd(currentSupply, amount);

        Transfer(0, addr, amount);
    }


    uint constant D160 = 0x0010000000000000000000000000000000000000000;

    // We don't use safe math in this function
    // because this will be called for the owner before the contract
    // is published and we need to save gas.
    function multiMint(uint[] data) onlyOwner {
        if (mintingDone) throw;

        uint supplyAdd;
        for (uint i = 0; i < data.length; i++ ) {
            address addr = address( data[i] & (D160-1) );
            uint amount = data[i] / D160;

            balanceOf[addr] += amount;
            supplyAdd += amount;
            Transfer(0, addr, amount);
        }
        currentSupply += supplyAdd;
    }

    function completeMinting() onlyOwner {
        mintingDone = true;
    }

    mapping(address => uint) public balanceOf;
    mapping(address => mapping (address => uint)) public allowance;

    function transfer(address _to, uint _value) isLaunched notPaused
    onlyPayloadSize(2)
    returns (bool success) {
        if (balanceOf[msg.sender] < _value) return false;
        if (_to == 0x0) return false;

        balanceOf[msg.sender] = safeSub(balanceOf[msg.sender], _value);
        balanceOf[_to] = safeAdd(balanceOf[_to], _value);
        Transfer(msg.sender, _to, _value);
        return true;
    }

    function transferFrom(address _from, address _to, uint _value)  isLaunched notPaused
    onlyPayloadSize(3)
    returns (bool success) {
        if (_to == 0x0) return false;
        if (balanceOf[_from] < _value) return false;

        var allowed = allowance[_from][msg.sender];
        if (allowed < _value) return false;

        balanceOf[_to] = safeAdd(balanceOf[_to], _value);
        balanceOf[_from] = safeSub(balanceOf[_from], _value);
        allowance[_from][msg.sender] = safeSub(allowed, _value);
        Transfer(_from, _to, _value);
        return true;
    }

    function approve(address _spender, uint _value)
    onlyPayloadSize(2)
    returns (bool success) {
        //require user to set to zero before resetting to nonzero
        if ((_value != 0) && (allowance[msg.sender][_spender] != 0)) {
            return false;
        }

        allowance[msg.sender][_spender] = _value;
        Approval(msg.sender, _spender, _value);
        return true;
    }

    function increaseApproval (address _spender, uint _addedValue)
    onlyPayloadSize(2)
    returns (bool success) {
        uint oldValue = allowance[msg.sender][_spender];
        allowance[msg.sender][_spender] = safeAdd(oldValue, _addedValue);
        Approval(msg.sender, _spender, allowance[msg.sender][_spender]);
        return true;
    }

    function decreaseApproval (address _spender, uint _subtractedValue)
    onlyPayloadSize(2)
    returns (bool success) {
        uint oldValue = allowance[msg.sender][_spender];
        if (_subtractedValue > oldValue) {
            allowance[msg.sender][_spender] = 0;
        } else {
            allowance[msg.sender][_spender] = safeSub(oldValue, _subtractedValue);
        }
        Approval(msg.sender, _spender, allowance[msg.sender][_spender]);
        return true;
    }

    /// @notice `msg.sender` approves `_spender` to send `_amount` tokens on
    ///  its behalf, and then a function is triggered in the contract that is
    ///  being approved, `_spender`. This allows users to use their tokens to
    ///  interact with contracts in one function call instead of two
    /// @param _spender The address of the contract able to transfer the tokens
    /// @param _amount The amount of tokens to be approved for transfer
    /// @return True if the function call was successful
    function approveAndCall(address _spender, uint256 _amount, bytes _extraData
    ) returns (bool success) {
        if (!approve(_spender, _amount)) throw;

        ApproveAndCallFallBack(_spender).receiveApproval(
            msg.sender,
            _amount,
            this,
            _extraData
        );

        return true;
    }

    //Holds accumulated dividend tokens other than TKN
    TokenHolder public tokenholder;

    //once locked, can no longer upgrade tokenholder
    bool public lockedTokenHolder;

    function lockTokenHolder() onlyOwner {
        lockedTokenHolder = true;
    }

    function setTokenHolder(address _th) onlyOwner {
        if (lockedTokenHolder) throw;
        tokenholder = TokenHolder(_th);
    }

    function burn(uint _amount) notPaused returns (bool result)  {
        if (_amount > balanceOf[msg.sender]) return false;

        balanceOf[msg.sender] = safeSub(balanceOf[msg.sender], _amount);
        currentSupply  = safeSub(currentSupply, _amount);
        result = tokenholder.burn(msg.sender, _amount);
        if (!result) throw;
        Transfer(msg.sender, 0, _amount);
    }

    // Peterson's Law Protection
    event logTokenTransfer(address token, address to, uint amount);

    function claimTokens(address _token) onlyOwner {
        if (_token == 0x0) {
            owner.transfer(this.balance);
            return;
        }

        Token token = Token(_token);
        uint balance = token.balanceOf(this);
        token.transfer(owner, balance);
        logTokenTransfer(_token, owner, balance);
    }

    // Pause mechanism

    bool public pausingMechanismLocked = false;
    bool public paused = false;

    modifier notPaused() {
        if (paused) throw;
        _;
    }

    function pause() onlyOwner {
        if (pausingMechanismLocked) throw;
        paused = true;
    }

    function unpause() onlyOwner {
        if (pausingMechanismLocked) throw;
        paused = false;
    }

    function neverPauseAgain() onlyOwner {
        pausingMechanismLocked = true;
    }
}

contract TokenHolder {
    function burn(address , uint )
    returns (bool result) {
        return false;
    }
}

contract ApproveAndCallFallBack {
    function receiveApproval(address from, uint256 _amount, address _token, bytes _data);
}
Clone this wiki locally