updated comments

updated comments

pragma solidity 0.4.15;

import 'zeppelin-solidity/contracts/ownership/Ownable.sol';
import 'zeppelin-solidity/contracts/token/StandardToken.sol';

/**
* Health Decentralized Record Service (DRS)
* This contract enables creation of services and keys which can
* be managed, shared, traded, and sold using Health Cash (HLTH).
*
* These keys enable gatekeeper services and
* cryptographically secure data exchanges.
*/

contract HealthDRS is Ownable {

   StandardToken public token;
   address public latestContract = address(this);
   uint8 public version = 1;

   struct Service {
       string url;
       address owner;
   }

   struct Key {
       address owner;
       bool canShare;
       bool canTrade;
       bool canSell;
       bytes32 service;
   }

   struct SalesOffer {
       address buyer;
       uint price;
       bool canSell;
   }

   mapping (bytes32 => Service) public services;
   bytes32[] public serviceList;

   mapping(bytes32 => Key) keys;
   bytes32[] public keyList;

   mapping(bytes32 => address[]) public owners;
   mapping(bytes32 => bytes32) public keyData;
   mapping(bytes32 => SalesOffer) public salesOffers;
   mapping(bytes32 => bytes32) public tradeOffers;

   event ServiceCreated(address indexed _owner, bytes32 indexed _service);
   event KeyCreated(address indexed _owner, bytes32 indexed _key);
   event KeySold(bytes32 _key, address indexed _seller, address indexed _buyer, uint _price);
   event KeysTraded(bytes32 indexed _key1, bytes32 indexed _key2);
   event Access(address indexed _owner, bytes32 indexed _from, bytes32 indexed _to, uint _time, string _data);
   event Message(address indexed _owner, bytes32 indexed _from, bytes32 indexed _to, uint _time, string _category, string _data);
   event Log(address indexed _owner, bytes32 indexed _from, uint _time, string _data);

   modifier validKey(bytes32 key) {
     require(keys[key].owner != address(0));
     _;
   }

   modifier validService(bytes32 service) {
     require(services[service].owner != address(0));
     _;
   }

   modifier ownsKey(bytes32 key) {
       require(isKeyOwner(key, msg.sender));
       _;
   }
   modifier ownsService(bytes32 service) {
       require(isServiceOwner(service, msg.sender));
       _;
   }

   modifier canSell(bytes32 key) {
     require(keys[key].canSell);
     _;
   }

   modifier canTrade(bytes32 key) {
     require(keys[key].canTrade);
     _;
   }

   modifier canShare(bytes32 key) {
     require(keys[key].canShare);
     _;
   }

   function isKeyOwner(bytes32 key, address account)
       public
       constant
       validKey(key)
       returns (bool)
   {
       if (keys[key].owner == account) {
           return true;
       } else {
           if (keys[key].canShare) {
               for (uint i = 0; i < owners[key].length; i++) {
                   if (owners[key][i] == account) {
                       return true;
                   }
               }
           }
       }
       return false;
   }

   function isServiceOwner(bytes32 service, address account)
       public
       constant
       validService(service)
       returns (bool)
   {
       if (services[service].owner == account) {
           return true;
       } else {
           for (uint i = 0; i < owners[service].length; i++) {
               if (owners[service][i] == account) {
                   return true;
               }
          }
       }
       return false;
   }

   function getUrl(bytes32 service)
       public
       constant
       validService(service)
       returns (string)
   {
      return services[service].url;
   }

   function getUrlFromKey(bytes32 key)
       public
       constant
       validKey(key)
       returns (string)
   {
       return services[keys[key].service].url;
   }

   function updateUrl(bytes32 service, string url)
       public
       ownsService(service)
   {
      services[service].url = url;
   }

   //user must authorize this contract to spend Health Cash (HLTH)
   function authorizedToSpend() public constant returns (uint) {
       return token.allowance(msg.sender, address(this));
   }

   //allow owner access to tokens erroneously transferred to this contract
   function recoverTokens(StandardToken _token, uint amount) public onlyOwner {
       _token.transfer(owner, amount);
   }

   function setHealthCashToken(StandardToken _token) public onlyOwner {
       token = _token;
   }

   function setLatestContract(address _contract) public onlyOwner {
       latestContract = _contract;
   }

  /**
  * Create Services & Keys
  * Keys can also be issued to accounts
  */
   function createService(string url) public {
       bytes32 id = keccak256(url);
       require(services[id].owner == address(0)); //prevent overwriting
       services[id].owner = msg.sender;
       services[id].url = url;
       serviceList.push(id);
       ServiceCreated(msg.sender, id);
   }

   function createKey(bytes32 service)
       public
       ownsService(service)
   {
       issueKey(service, msg.sender);
   }

   function issueKey(bytes32 service, address issueTo)
       public
       ownsService(service)
   {
       bytes32 id = keccak256(service, now, issueTo);
       require(keys[id].owner == address(0));
       keys[id].owner = issueTo;
       keys[id].service = service;
       keyList.push(id);
       KeyCreated(issueTo, id);
   }

  /**
  * Share Services and Keys
  * allow owners to authorize other accounts
  * a service can disable sharing for their keys.
  * Can also unshare.
  */
   function shareKey(bytes32 key, address account)
       public
       ownsKey(key)
       canShare(key)
   {
       if (isKeyOwner(key, account) == false) {
           owners[key].push(account);
       }
   }

   function shareService(bytes32 service, address account)
       public
       ownsService(service)
   {
       if (isServiceOwner(service, account) == false) {
           owners[service].push(account);
       }
   }

   function unshareKey(bytes32 key, address account)
       public
       ownsKey(key)
   {
       for (uint i = 0; i < owners[key].length; i++) {
           if (owners[key][i] == account) {
               if (i != owners[key].length - 1) {
                   owners[key][i] = owners[key][owners[key].length - 1];
               }
               owners[key].length--;
               break;
           }
       }
   }

   function unshareService(bytes32 service, address account)
       public
       ownsService(service)
   {
       for (uint i = 0; i < owners[service].length; i++) {
           if (owners[service][i] == account) {
               if (i != owners[service].length - 1) {
                   owners[service][i] = owners[service][owners[service].length - 1];
               }
               owners[service].length--;
               break;
           }
       }
   }

   /**
   * Sell Keys
   * Services have to authorize keys for sale.
   * Key owners can disable key selling at time
   * of sale to prevent re-selling.
   */
   function createSalesOffer(bytes32 key, address buyer, uint price, bool _canSell)
       public
       ownsKey(key)
       canSell(key)
   {
       //cancel trade offer & create sales offer
       tradeOffers[key] = bytes32(0);
       salesOffers[key].buyer = buyer;
       salesOffers[key].price = price;
       salesOffers[key].canSell = _canSell;
   }

   function cancelSalesOffer(bytes32 key)
       public
       ownsKey(key)
   {
       salesOffers[key].buyer = address(0);
       salesOffers[key].price = 0;
       salesOffers[key].canSell = false;
   }

   function purchaseKey(bytes32 key, uint value)
       public
       canSell(key)
   {

      //require explicit authority to spend tokens on the purchasers behalf
      require(value <= authorizedToSpend());
      require(salesOffers[key].buyer == msg.sender);
      require(salesOffers[key].price == value);

      /**
      * Price in HLTH tokens is transferred from the purchaser
      * to the primary owner of the key.
      */
      assert(token.transferFrom(msg.sender, keys[key].owner, value));

      KeySold(key, keys[key].owner, msg.sender, value);
      keys[key].owner = msg.sender;

      //set canSell - allows for non-resellable keys
      keys[key].canSell = salesOffers[key].canSell;
   }

   /**
   * Trade keys
   * both keys have to be authorized
   * to trade by their respective services.
   */
   function tradeKey(bytes32 have, bytes32 want)
       public
       ownsKey(have)
       canTrade(have)
       canTrade(want)
   {
      if (tradeOffers[want] == have) {

          KeysTraded(want, have);
          tradeOffers[want] = ""; //remove the tradeOffer

          //complete the trade
          keys[have].owner = keys[want].owner;
          keys[want].owner = msg.sender;

       } else {
           //create a trade offer & cancel sales offer
           cancelSalesOffer(have);
           tradeOffers[have] = want;
       }
   }

   /**
   * Manage Keys
   * Service owner can set key permissions
   * disabling sharing, trading, or selling
   * removes shared owners, active trade
   * offers, and active sales offers respectively
   *
   * Should also be able to get a key and service,
   * get a count of keys and services, and get
   * a key and service key from the respective
   * lists.
   */
   //service owner can set permissions
   function setKeyPermissions(
       bytes32 key,
       bool canShare_,
       bool canTrade_,
       bool canSell_)
       public
       validKey(key)
       ownsService(keys[key].service)
   {
       keys[key].canShare = canShare_;
       if (canShare_ == false) {
           owners[key].length = 0;
       }

       keys[key].canTrade = canTrade_;
       if (canTrade_ == false) {
           tradeOffers[key] = "";
       }

       keys[key].canSell = canSell_;
       if (canSell_ == false) {
           salesOffers[key].buyer = 0;
           salesOffers[key].price = 0;
       }

   }

   function getServiceCount() public constant returns (uint) {
       return serviceList.length;
   }

   function getKeyCount() public constant returns (uint) {
       return keyList.length;
   }

   function getService(bytes32 service)
       public
       constant
       validService(service)
       returns(string, address)
   {
      return (services[service].url, services[service].owner);
   }

   function getKey(bytes32 key)
       public
       constant
       validKey(key)
       returns(address, bool, bool, bool, bytes32)
   {
      return (keys[key].owner,
              keys[key].canShare,
              keys[key].canTrade,
              keys[key].canSell,
              keys[key].service);
   }

   /**
   * Key Data
   * A service can store public data for its keys.
   */
   function setKeyData(bytes32 key, bytes32 dataKey, bytes32 dataValue)
       public
       validKey(key)
       ownsService(keys[key].service)
   {
       keyData[keccak256(key,dataKey)] = dataValue;
   }

   function getKeyData(bytes32 key, bytes32 dataKey)
       public
       constant
       validKey(key)
       returns (bytes32)
   {
       return keyData[keccak256(key,dataKey)];
   }

   /**
   * ecrecover passthrough
   */
   function recoverAddress(
       bytes32 msgHash,
       uint8 v,
       bytes32 r,
       bytes32 s)
       constant
       returns (address)
   {
     return ecrecover(msgHash, v, r, s);
   }

   /**
   * Logging & Messaging
   * functions for creating an auditable record of activity.
   * A service can log access from any of its keys.
   */
   function logAccess(bytes32 key, string data)
       public
       validKey(key)
       ownsService(keys[key].service)
   {
       Access(msg.sender, keys[key].service, key, now, data);
   }

   //services and keys can log messages to each other
   function message(bytes32 from, bytes32 to, string category, string data)
       public
   {
       bool ownsFrom = false;
       if (isKeyOwner(from, msg.sender) || isServiceOwner(from, msg.sender)) {
           ownsFrom = true;
       }
       require(ownsFrom);

       bool validTo = false;
       if (keys[to].owner != address(0) || services[to].owner != address(0)) {
           validTo = true;
       }
       require(validTo);

       Message(msg.sender, from, to, now, category, data);
   }

   //any key or service can log
   function log(bytes32 from, string data)
       public
   {
       bool ownsFrom = false;
       if (isKeyOwner(from, msg.sender) || isServiceOwner(from, msg.sender)) {
           ownsFrom = true;
       }
       require(ownsFrom);

       Log(msg.sender, from, now, data);
   }

}

pragma solidity 0.4.15;

import 'zeppelin-solidity/contracts/ownership/Ownable.sol';
import 'zeppelin-solidity/contracts/token/StandardToken.sol';

/**
* Health Decentralized Record Service (DRS)
* This contract enables creation of services and keys which can
* be managed, shared, traded, and sold using Health Cash (HLTH).
*
* These keys enable gatekeeper services and
* cryptographically secure data exchanges.
*/

contract HealthDRS is Ownable {

    StandardToken public token;
    address public latestContract = address(this);
    uint8 public version = 1;

    struct Service {
        string url;
        address owner;
    }

    struct Key {
        address owner;
        bool canShare;
        bool canTrade;
        bool canSell;
        bytes32 service;
    }

    struct SalesOffer {
        address buyer;
        uint price;
        bool canSell;
    }

    mapping (bytes32 => Service) public services;
    bytes32[] public serviceList;

    mapping(bytes32 => Key) keys;
    bytes32[] public keyList;

    mapping(bytes32 => address[]) public owners;
    mapping(bytes32 => bytes32) public keyData;
    mapping(bytes32 => SalesOffer) public salesOffers;
    mapping(bytes32 => bytes32) public tradeOffers;

    event ServiceCreated(address indexed _owner, bytes32 indexed _service);
    event KeyCreated(address indexed _owner, bytes32 indexed _key);
    event KeySold(bytes32 _key, address indexed _seller, address indexed _buyer, uint _price);
    event KeysTraded(bytes32 indexed _key1, bytes32 indexed _key2);
    event Access(address indexed _owner, bytes32 indexed _from, bytes32 indexed _to, uint _time, string _data);
    event Message(address indexed _owner, bytes32 indexed _from, bytes32 indexed _to, uint _time, string _category, string _data);
    event Log(address indexed _owner, bytes32 indexed _from, uint _time, string _data);

    modifier validKey(bytes32 key) {
      require(keys[key].owner != address(0));
      _;
    }

    modifier validService(bytes32 service) {
      require(services[service].owner != address(0));
      _;
    }

    modifier ownsKey(bytes32 key) {
        require(isKeyOwner(key, msg.sender));
        _;
    }

    modifier ownsService(bytes32 service) {
        require(isServiceOwner(service, msg.sender));
        _;
    }

    modifier canSell(bytes32 key) {
      require(keys[key].canSell);
      _;
    }

    modifier canTrade(bytes32 key) {
      require(keys[key].canTrade);
      _;
    }

    modifier canShare(bytes32 key) {
      require(keys[key].canShare);
      _;
    }

    function isKeyOwner(bytes32 key, address account)
        public
        constant
        validKey(key)
        returns (bool)
    {
        if (keys[key].owner == account) {
            return true;
        } else {
            if (keys[key].canShare) {
                for (uint i = 0; i < owners[key].length; i++) {
                    if (owners[key][i] == account) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    function isServiceOwner(bytes32 service, address account)
        public
        constant
        validService(service)
        returns (bool)
    {
        if (services[service].owner == account) {
            return true;
        } else {
            for (uint i = 0; i < owners[service].length; i++) {
                if (owners[service][i] == account) {
                    return true;
                }
           }
        }
        return false;
    }

    function getUrl(bytes32 service)
        public
        constant
        validService(service)
        returns (string)
    {
       return services[service].url;
    }

    function getUrlFromKey(bytes32 key)
        public
        constant
        validKey(key)
        returns (string)
    {
        return services[keys[key].service].url;
    }

    function updateUrl(bytes32 service, string url)
        public
        ownsService(service)
    {
       services[service].url = url;
    }

    //user must authorize this contract to spend Health Cash (HLTH)
    function authorizedToSpend() public constant returns (uint) {
        return token.allowance(msg.sender, address(this));
    }

    //allow owner access to tokens erroneously transfered to this contract
    function recoverTokens(StandardToken _token, uint amount) public onlyOwner {
        _token.transfer(owner, amount);
    }

    function setHealthCashToken(StandardToken _token) public onlyOwner {
        token = _token;
    }

    function setLatestContract(address _contract) public onlyOwner {
        latestContract = _contract;
    }

   /**
   * Create Services & Keys
   * Keys can also be issued to accounts
   */
    function createService(string url) public {
        bytes32 id = keccak256(url);
        require(services[id].owner == address(0)); //prevent overwriting
        services[id].owner = msg.sender;
        services[id].url = url;
        serviceList.push(id);
        ServiceCreated(msg.sender, id);
    }

    function createKey(bytes32 service)
        public
        ownsService(service)
    {
        issueKey(service, msg.sender);
    }

    function issueKey(bytes32 service, address issueTo)
        public
        ownsService(service)
    {
        bytes32 id = keccak256(service, now, issueTo);
        require(keys[id].owner == address(0));
        keys[id].owner = issueTo;
        keys[id].service = service;
        keyList.push(id);
        KeyCreated(issueTo, id);
    }

   /**
   * Share Services and Keys
   * allow owners to authorize other accounts
   * a service can disable sharing for thier keys.
   * Can also unshare.
   */
    function shareKey(bytes32 key, address account)
        public
        ownsKey(key)
        canShare(key)
    {
        if (isKeyOwner(key, account) == false) {
            owners[key].push(account);
        }
    }

    function shareService(bytes32 service, address account)
        public
        ownsService(service)
    {
        if (isServiceOwner(service, account) == false) {
            owners[service].push(account);
        }
    }

    function unshareKey(bytes32 key, address account)
        public
        ownsKey(key)
    {
        for (uint i = 0; i < owners[key].length; i++) {
            if (owners[key][i] == account) {
                if (i != owners[key].length - 1) {
                    owners[key][i] = owners[key][owners[key].length - 1];
                }
                owners[key].length--;
                break;
            }
        }
    }

    function unshareService(bytes32 service, address account)
        public
        ownsService(service)
    {
        for (uint i = 0; i < owners[service].length; i++) {
            if (owners[service][i] == account) {
                if (i != owners[service].length - 1) {
                    owners[service][i] = owners[service][owners[service].length - 1];
                }
                owners[service].length--;
                break;
            }
        }
    }

    /**
    * Sell Keys
    * Services have to authorize keys for sale.
    * Key owners can disable key selling at time
    * of sale to prevent re-selling.
    */
    function createSalesOffer(bytes32 key, address buyer, uint price, bool _canSell)
        public
        ownsKey(key)
        canSell(key)
    {
        //cancell trade offer & create sales offer
        tradeOffers[key] = bytes32(0);
        salesOffers[key].buyer = buyer;
        salesOffers[key].price = price;
        salesOffers[key].canSell = _canSell;
    }

    function cancelSalesOffer(bytes32 key)
        public
        ownsKey(key)
    {
        salesOffers[key].buyer = address(0);
        salesOffers[key].price = 0;
        salesOffers[key].canSell = false;
    }

    function purchaseKey(bytes32 key, uint value)
        public
        canSell(key)
    {

       //require explictit authority to spend tokens on the purchasers behalf
       require(value <= authorizedToSpend());
       require(salesOffers[key].buyer == msg.sender);
       require(salesOffers[key].price == value);

       /**
       * Price in HLTH tokens is transfered from the purchaser
       * to the primary owner of the key.
       */
       assert(token.transferFrom(msg.sender, keys[key].owner, value));

       KeySold(key, keys[key].owner, msg.sender, value);
       keys[key].owner = msg.sender;

       //set canSell - allows for non-resellable keys
       keys[key].canSell = salesOffers[key].canSell;
    }

    /**
    * Trade keys
    * both keys have to be authorized
    * to trade by thier respective services.
    */
    function tradeKey(bytes32 have, bytes32 want)
        public
        ownsKey(have)
        canTrade(have)
        canTrade(want)
    {
       if (tradeOffers[want] == have) {

           KeysTraded(want, have);
           tradeOffers[want] = ""; //remove the tradeOffer

           //complete the trade
           keys[have].owner = keys[want].owner;
           keys[want].owner = msg.sender;

        } else {
            //create a trade offer & cancel sales offer
            cancelSalesOffer(have);
            tradeOffers[have] = want;
        }
    }

    /**
    * Manage Keys
    * Service owner can set key permissions
    * disabling sharing, trading, or selling
    * removes shared owners, active trade
    * offers, and active sales offers respectively
    *
    * Should also be able to get a key and service,
    * get a count of keys and services, and get
    * a key and service key from the respective
    * lists.
    */
    //service owner can set permissions
    function setKeyPermissions(
        bytes32 key,
        bool canShare_,
        bool canTrade_,
        bool canSell_)
        public
        validKey(key)
        ownsService(keys[key].service)
    {
        keys[key].canShare = canShare_;
        if (canShare_ == false) {
            owners[key].length = 0;
        }

        keys[key].canTrade = canTrade_;
        if (canTrade_ == false) {
            tradeOffers[key] = "";
        }

        keys[key].canSell = canSell_;
        if (canSell_ == false) {
            salesOffers[key].buyer = 0;
            salesOffers[key].price = 0;
        }

    }

    function getServiceCount() public constant returns (uint) {
        return serviceList.length;
    }

    function getKeyCount() public constant returns (uint) {
        return keyList.length;
    }

    function getService(bytes32 service)
        public
        constant
        validService(service)
        returns(string, address)
    {
       return (services[service].url, services[service].owner);
    }

    function getKey(bytes32 key)
        public
        constant
        validKey(key)
        returns(address, bool, bool, bool, bytes32)
    {
       return (keys[key].owner,
               keys[key].canShare,
               keys[key].canTrade,
               keys[key].canSell,
               keys[key].service);
    }

    /**
    * Key Data
    * A service can store public data for its keys.
    */
    function setKeyData(bytes32 key, bytes32 dataKey, bytes32 dataValue)
        public
        validKey(key)
        ownsService(keys[key].service)
    {
        keyData[keccak256(key,dataKey)] = dataValue;
    }

    function getKeyData(bytes32 key, bytes32 dataKey)
        public
        constant
        validKey(key)
        returns (bytes32)
    {
        return keyData[keccak256(key,dataKey)];
    }

    /**
    * ecrecover passthrough
    */
    function recoverAddress(
        bytes32 msgHash,
        uint8 v,
        bytes32 r,
        bytes32 s)
        constant
        returns (address)
    {
      return ecrecover(msgHash, v, r, s);
    }

    /**
    * Logging & Messaging
    * functions for creating an auditable record of activity.
    * A service can log access from any of its keys.
    */
    function logAccess(bytes32 key, string data)
        public
        validKey(key)
        ownsService(keys[key].service)
    {
        Access(msg.sender, keys[key].service, key, now, data);
    }

    //services and keys can log messages to each other
    function message(bytes32 from, bytes32 to, string category, string data)
        public
    {
        bool ownsFrom = false;
        if (isKeyOwner(from, msg.sender) || isServiceOwner(from, msg.sender)) {
            ownsFrom = true;
        }
        require(ownsFrom);

        bool validTo = false;
        if (keys[to].owner != address(0) || services[to].owner != address(0)) {
            validTo = true;
        }
        require(validTo);

        Message(msg.sender, from, to, now, category, data);
    }

    //any key or service can log
    function log(bytes32 from, string data)
        public
    {
        bool ownsFrom = false;
        if (isKeyOwner(from, msg.sender) || isServiceOwner(from, msg.sender)) {
            ownsFrom = true;
        }
        require(ownsFrom);

        Log(msg.sender, from, now, data);
    }

}


Fixed comments in userMaster

Fixed comments in userMaster

import "lib/random.sol";
import "tag.sol";
import "assessment.sol";
import "user.sol";
import "tagMaster.sol";

/*
@type: contract
@name: UserMaster
@purpose: To store data about users for easy and secure access
*/
contract UserMaster
{
  address tagMasterAddress; //The address of the tagMaster contract
  mapping (address => int)  tokenBalance; //Maps the addresses of users to their token balances
  mapping (address => address[])  achievements; //Maps the addresses of users to an array of addresses that contain the addresses of the tags that they have passed an assessment in
  mapping (address => bool)  availability; //Maps the addresses of users to their availability status for whether or not they can currently assess someone
  mapping (address => address)  users; //Maps the addresses of the users to their actual location of the blockchain
  bool firstUserMade = false; //Keeps track of whether or not the first user has been made yet
  event UserCreation(address _userAddress); //address of the created user contract

  /*
  @type: modifier
  @name: onlyTag
  @purpose: to only allow the Tag contract to call a function to which this modifier is applied
  */
  modifier onlyTag
  {
    if(TagMaster(tagMasterAddress).checkTag(msg.sender) == false) //checks if the address calling the function is not a tag
    {
      throw; //throws out the fucntion call
    }
  }

  /*
  @type: constructor function
  @purpose: To initialize the userMaster contract and have it make the account tag
  @param: address creator = the address of the creator contract
  @returns: nothing
  */
  function UserMaster(address tagMaster)
  {
    tagMasterAddress = tagMaster; //Sets the address of the tagMaster contract
  }

  /*
  @type: function
  @purpose: To get the address of the Tag Master
  @returns: The address of the Tag Master
  */
  function getTagMasterAddress() returns(address)
  {
    return tagMasterAddress;
  }

  /*
  @type: function
  @purpose: To create the first user in the system
  @returns: nothing
  */
  function firstUser()
  {
    if(firstUserMade == false) //Checks to make sure the first user has not already been made
    {
      User newUser = new User(0x83A6175DA23563D9DC3A9CDA1ec77EB02abF2630, address(this)); //Makes a new user that represents Jared's address
      availability[address(newUser)] = true; //Sets the availability of this user to true
      Tag(TagMaster(tagMasterAddress).getTagAddressFromName("account")).addFirstUser(address(newUser)); //Gives the first user the account tag so it can be used to verify users made later
      UserCreation(address(newUser)); //Makes a new UserCreation event with the address of the newly created user
      firstUserMade = true; //Sets firstUserMade to true so this function will not be able to create more users
    }
  }

  /*
  @type: function
  @purpose: To create a user contract
  @param: address userAddress = the address of the user's wallet
  @param: address masterAddress = the address of the master contract that stores this user's address
  @returns: nothing
  */
  function addUser(address userAddress)
  {
    User newUser = new User(userAddress, address(this)); //Makes a new user that represents the address from userAddress and uses the master from masterAddress as its datastore
    Tag(TagMaster(tagMasterAddress).getTagAddressFromName("account")).makeAssessment(address(newUser), 600); //Starts the account tag assessment process for the newly created tag to make sure it isnt a shitty bot
    UserCreation(address(newUser)); //Makes a new UserCreation event with the address of the newly created user
  }

  /*
  @type: function
  @purpose: To map the address of a user to the address of the tag that the user has just passed
  @param: address user = the address of the user
  @param: address acheivment = the address of the tag just passed
  @returns: nothing
  */
  function mapAchievement(address user, address achievment) onlyTag
  {
    achievements[user].push(achievment); //adds the address of the tag to the end of the array that is mapped to the user
  }

  /*
  @type: function
  @purpose: To map the user's availability to assess to the user's address
  @param: address user = the address of the user
  @param: bool available = the availa status of the user to assess
  @returns: nothing
  */
  function mapAvailability(address user, bool available)
  {
    if(msg.sender == user) //checks if the address that is calling the function is the same as the user whose availability is being set
    {
      availability[user] = available; //sets the availability of the user specified in the parameter to the availability specified in the parameter
    }
  }

  /*
  @type: function
  @purpose: To set a new token balance for a user
  @param: address user = the address of the user whose token balance is to be mapped
  @param: uint balance = the new token balance for the user
  @returns: nothing
  */
  function mapTokenBalance(address user, int balance) onlyTag
  {
    tokenBalance[user] = balance; //sets the token balance of the user
  }

  /*
  @type: function
  @purpose: To get the user's token balance
  @param: address user = the address of the user
  @returns: The token balance in the form of a uint
  */
  function getTokenBalance(address user) constant returns(int)
  {
    return tokenBalance[user];
  }

  /*
  @type: function
  @purpose: To get the addresses of the tags that the user has achieved
  @param: address user = the address of the user
  @returns: The addresses of the tags that the user has achieved in the form of an array of addresses
  */
  function getAchievement(address user) constant returns(address[])
  {
    return achievements[user];
  }

  /*
  @type: function
  @purpose: To get the number of achievments of a user
  @param: address user = the address of the user
  @returns: The number of achievments of a user in the form of a uint
  */
  function getNumberOfachievments(address user) constant returns(uint)
  {
    return achievements[user].length;
  }

  /*
  @type: function
  @purpose: To get the availability of a user to assess
  @param: address user = the address of the user
  @returns: The availability of a user to assess in the form of a bool
  */
  function getAvailability(address user) constant returns(bool)
  {
    return availability[user];
  }

  /*
  @type: function
  @purpose: to remove this contract
  @param: address receiver = the address of the wallet that will receive of the ether
  @returns: nothing
  */
  function remove(address reciever) onlyUser
  {
    suicide(reciever);
  }
}

import "lib/random.sol";
import "tag.sol";
import "assessment.sol";
import "user.sol";
import "tagMaster.sol";

/*
@type: contract
@name: UserMaster
@purpose: To store data about users for easy and secure access
*/
contract UserMaster
{
  address tagMasterAddress; //The address of the tagMaster contract
  mapping (address => int)  tokenBalance; //Maps the addresses of users to their token balances
  mapping (address => address[])  achievements; //Maps the addresses of users to an array of addresses that contain the addresses of the tags that they have passed an assessment in
  mapping (address => bool)  availability; //Maps the addresses of users to their availability status for whether or not they can currently assess someone
  mapping (address => address)  users; //Maps the addresses of the users to their actual location of the blockchain
  bool firstUserMade = false; //Keeps track of whether or not the first user has been made yet
  event UserCreation(address _userAddress); //address of the created user contract

  /*
  @type: modifier
  @name: onlyTag
  @purpose: to only allow the Tag contract to call a function to which this modifier is applied
  */
  modifier onlyTag
  {
    if(TagMaster(tagMasterAddress).checkTag(msg.sender) == false) //checks if the address calling the function is not a tag
    {
      throw; //throws out the fucntion call
    }
  }

  /*
  @type: constructor function
  @purpose: To initialize the master contract and have it make the account tag
  @param: address creator = the address of the creator contract
  @returns: nothing
  */
  function UserMaster(address tagMaster)
  {
    tagMasterAddress = tagMaster; //Sets the address of the tagMaster contract
  }

  /*
  @type: function
  @purpose: To get the address of the Tag Master
  @returns: The address of the Tag Master
  */
  function getTagMasterAddress() returns(address)
  {
    return tagMasterAddress;
  }

  /*
  @type: function
  @purpose: To create the first user in the system
  @returns: nothing
  */
  function firstUser()
  {
    if(firstUserMade == false) //Checks to make sure the first user has not already been made
    {
      User newUser = new User(0x83A6175DA23563D9DC3A9CDA1ec77EB02abF2630, address(this)); //Makes a new user that represents Jared's address
      availability[address(newUser)] = true; //Sets the availability of this user to true
      Tag(TagMaster(tagMasterAddress).getTagAddressFromName("account")).addFirstUser(address(newUser)); //Gives the first user the account tag so it can be used to verify users made later
      UserCreation(address(newUser)); //Makes a new UserCreation event with the address of the newly created user
      firstUserMade = true; //Sets firstUserMade to true so this function will not be able to create more users
    }
  }

  /*
  @type: function
  @purpose: To create a user contract
  @param: address userAddress = the address of the user's wallet
  @param: address masterAddress = the address of the master contract that stores this user's address
  @returns: nothing
  */
  function addUser(address userAddress)
  {
    User newUser = new User(userAddress, address(this)); //Makes a new user that represents the address from userAddress and uses the master from masterAddress as its datastore
    Tag(TagMaster(tagMasterAddress).getTagAddressFromName("account")).makeAssessment(address(newUser), 600); //Starts the account tag assessment process for the newly created tag to make sure it isnt a shitty bot
    UserCreation(address(newUser)); //Makes a new UserCreation event with the address of the newly created user
  }

  /*
  @type: function
  @purpose: To map the address of a user to the address of the tag that the user has just passed
  @param: address user = the address of the user
  @param: address acheivment = the address of the tag just passed
  @returns: nothing
  */
  function mapAchievement(address user, address achievment) onlyTag
  {
    achievements[user].push(achievment); //adds the address of the tag to the end of the array that is mapped to the user
  }

  /*
  @type: function
  @purpose: To map the user's availability to assess to the user's address
  @param: address user = the address of the user
  @param: bool available = the availa status of the user to assess
  @returns: nothing
  */
  function mapAvailability(address user, bool available)
  {
    if(msg.sender == user) //checks if the address that is calling the function is the same as the user whose availability is being set
    {
      availability[user] = available; //sets the availability of the user specified in the parameter to the availability specified in the parameter
    }
  }

  /*
  @type: function
  @purpose: To set a new token balance for a user
  @param: address user = the address of the user whose token balance is to be mapped
  @param: uint balance = the new token balance for the user
  @returns: nothing
  */
  function mapTokenBalance(address user, int balance) onlyTag
  {
    tokenBalance[user] = balance; //sets the token balance of the user
  }

  /*
  @type: function
  @purpose: To get the user's token balance
  @param: address user = the address of the user
  @returns: The token balance in the form of a uint
  */
  function getTokenBalance(address user) constant returns(int)
  {
    return tokenBalance[user];
  }

  /*
  @type: function
  @purpose: To get the addresses of the tags that the user has achieved
  @param: address user = the address of the user
  @returns: The addresses of the tags that the user has achieved in the form of an array of addresses
  */
  function getAchievement(address user) constant returns(address[])
  {
    return achievements[user];
  }

  /*
  @type: function
  @purpose: To get the number of achievments of a user
  @param: address user = the address of the user
  @returns: The number of achievments of a user in the form of a uint
  */
  function getNumberOfachievments(address user) constant returns(uint)
  {
    return achievements[user].length;
  }

  /*
  @type: function
  @purpose: To get the availability of a user to assess
  @param: address user = the address of the user
  @returns: The availability of a user to assess in the form of a bool
  */
  function getAvailability(address user) constant returns(bool)
  {
    return availability[user];
  }

  /*
  @type: function
  @purpose: to remove this contract
  @param: address receiver = the address of the wallet that will receive of the ether
  */
  function remove(address reciever) //remove after testing
  {
    suicide(reciever);
  }
}


Changed names in pH.sol example

Changed names in pH.sol example


Add contract

Add contract

contract Lock {
  uint price;
  uint startTime;
  uint endTime;
  uint userId;

  event GrantAccess(uint userId, uint startTime, uint endTime);

  function updateRentInfo(uint _price, uint _startTime, uint _endTime) {
    price = _price;
    startTime = _startTime;
    endTime = _endTime;
  }

  function getRentInfo() returns (uint[3]) {
    uint[3] memory arr;
    arr[0] = price;
    arr[1] = startTime;
    arr[2] = endTime;
    return arr;
  }

  function deposit(uint _userId) returns (bool) {
    if(msg.value < price) throw;

    userId = _userId;
    GrantAccess(userId, startTime, endTime);
    return true;
  }
}

error: pathspec 'lock.sol' did not match any file(s) known to git


[TokenVesting] Remove VestedTokenMock

[TokenVesting] Remove VestedTokenMock

pragma solidity ^0.4.11;

import '../../contracts/token/VestedToken.sol';

// mock class using StandardToken
contract VestedTokenMock is VestedToken {
  function VestedTokenMock(address initialAccount, uint256 initialBalance) {
    balances[initialAccount] = initialBalance;
    totalSupply = initialBalance;
  }
}


Various changes

Various changes

1. Added indexed to TradeListing and OwnerWithdrewERC20Token event addresses
2. Renamed tokens to etherValueOfTokensToSell in takerSellAsset(...) and TakerSoldAsset event
3. Less than or equal and greater than or equal comparison

1. and 2. suggested by JonnyLatte

pragma solidity ^0.4.4;

// ------------------------------------------------------------------------
// TokenTraderFactory
//
// Decentralised trustless ERC20-compliant token to ETH exchange contract
// on the Ethereum blockchain.
//
// Note that this TokenTrader cannot be used with the Golem Network Token
// directly as the token does not implement the ERC20
// transferFrom(...), approve(...) and allowance(...) methods
//
// Enjoy. (c) JonnyLatte & BokkyPooBah 2016. The MIT licence.
// ------------------------------------------------------------------------

// https://github.com/ethereum/EIPs/issues/20
contract ERC20 {
    function totalSupply() constant returns (uint totalSupply);
    function balanceOf(address _owner) constant returns (uint balance);
    function transfer(address _to, uint _value) returns (bool success);
    function transferFrom(address _from, address _to, uint _value) returns (bool success);
    function approve(address _spender, uint _value) returns (bool success);
    function allowance(address _owner, address _spender) constant returns (uint remaining);
    event Transfer(address indexed _from, address indexed _to, uint _value);
    event Approval(address indexed _owner, address indexed _spender, uint _value);
}

contract Owned {
    address public owner;
    event OwnershipTransferred(address indexed _from, address indexed _to);

    function Owned() {
        owner = msg.sender;
    }

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

    function transferOwnership(address newOwner) onlyOwner {
        OwnershipTransferred(owner, newOwner);
        owner = newOwner;
    }
}

// contract can buy or sell tokens for ETH
// prices are in amount of wei per batch of token units

contract TokenTrader is Owned {

    address public asset;       // address of token
    uint256 public buyPrice;    // contract buys lots of token at this price
    uint256 public sellPrice;   // contract sells lots at this price
    uint256 public units;       // lot size (token-wei)

    bool public buysTokens;     // is contract buying
    bool public sellsTokens;    // is contract selling

    event ActivatedEvent(bool buys, bool sells);
    event MakerDepositedEther(uint256 amount);
    event MakerWithdrewAsset(uint256 tokens);
    event MakerWithdrewERC20Token(address tokenAddress, uint256 tokens);
    event MakerWithdrewEther(uint256 ethers);
    event TakerBoughtAsset(address indexed buyer, uint256 ethersSent,
        uint256 ethersReturned, uint256 tokensBought);
    event TakerSoldAsset(address indexed seller, uint256 etherValueOfTokensToSell,
        uint256 tokensSold, uint256 etherValueOfTokensSold);

    // Constructor - only to be called by the TokenTraderFactory contract
    function TokenTrader (
        address _asset,
        uint256 _buyPrice,
        uint256 _sellPrice,
        uint256 _units,
        bool    _buysTokens,
        bool    _sellsTokens
    ) internal {
        asset       = _asset;
        buyPrice    = _buyPrice;
        sellPrice   = _sellPrice;
        units       = _units;
        buysTokens  = _buysTokens;
        sellsTokens = _sellsTokens;
        ActivatedEvent(buysTokens, sellsTokens);
    }

    // Maker can activate or deactivate this contract's buying and
    // selling status
    //
    // The ActivatedEvent() event is logged with the following
    // parameter:
    //   buysTokens   this contract can buy asset tokens
    //   sellsTokens  this contract can sell asset tokens
    //
    function activate (
        bool _buysTokens,
        bool _sellsTokens
    ) onlyOwner {
        buysTokens  = _buysTokens;
        sellsTokens = _sellsTokens;
        ActivatedEvent(buysTokens, sellsTokens);
    }

    // Maker can deposit ethers to this contract so this contract
    // can buy asset tokens.
    //
    // Maker deposits asset tokens to this contract by calling the
    // asset's transfer() method with the following parameters
    //   _to     is the address of THIS contract
    //   _value  is the number of asset tokens to be transferred
    //
    // Taker MUST NOT send tokens directly to this contract. Takers
    // MUST use the takerSellAsset() method to sell asset tokens
    // to this contract
    //
    // The MakerDepositedEther() event is logged with the following
    // parameter:
    //   ethers  is the number of ethers deposited by the maker
    //
    // This method was called deposit() in the old version
    //
    function makerDepositEther() payable onlyOwner {
        MakerDepositedEther(msg.value);
    }

    // Maker can withdraw asset tokens from this contract, with the
    // following parameter:
    //   tokens  is the number of asset tokens to be withdrawn
    //
    // The MakerWithdrewAsset() event is logged with the following
    // parameter:
    //   tokens  is the number of tokens withdrawn by the maker
    //
    // This method was called withdrawAsset() in the old version
    //
    function makerWithdrawAsset(uint256 tokens) onlyOwner returns (bool ok) {
        MakerWithdrewAsset(tokens);
        return ERC20(asset).transfer(owner, tokens);
    }

    // Maker can withdraw any ERC20 asset tokens from this contract
    //
    // This method is included in the case where this contract receives
    // the wrong tokens
    //
    // The MakerWithdrewERC20Token() event is logged with the following
    // parameter:
    //   tokenAddress  is the address of the tokens withdrawn by the maker
    //   tokens        is the number of tokens withdrawn by the maker
    //
    // This method was called withdrawToken() in the old version
    //
    function makerWithdrawERC20Token(
        address tokenAddress,
        uint256 tokens
    ) onlyOwner returns (bool ok) {
        MakerWithdrewERC20Token(tokenAddress, tokens);
        return ERC20(tokenAddress).transfer(owner, tokens);
    }

    // Maker can withdraw ethers from this contract
    //
    // The MakerWithdrewEther() event is logged with the following parameter
    //   ethers  is the number of ethers withdrawn by the maker
    //
    // This method was called withdraw() in the old version
    //
    function makerWithdrawEther(uint256 ethers) onlyOwner returns (bool ok) {
        if (this.balance >= ethers) {
            MakerWithdrewEther(ethers);
            return owner.send(ethers);
        }
    }

    // Taker buys asset tokens by sending ethers
    //
    // The TakerBoughtAsset() event is logged with the following parameters
    //   buyer           is the buyer's address
    //   ethersSent      is the number of ethers sent by the buyer
    //   ethersReturned  is the number of ethers sent back to the buyer as
    //                   change
    //   tokensBought    is the number of asset tokens sent to the buyer
    //
    // This method was called buy() in the old version
    //
    function takerBuyAsset() payable {
        if (sellsTokens || msg.sender == owner) {
            uint order    = msg.value / sellPrice;
            uint can_sell = ERC20(asset).balanceOf(address(this)) / units;
            uint256 change = 0;
            if (order > can_sell) {
                change = msg.value - (can_sell * sellPrice);
                order = can_sell;
                if (!msg.sender.send(change)) throw;
            }
            if (order > 0) {
                if(!ERC20(asset).transfer(msg.sender, order * units)) throw;
            }
            TakerBoughtAsset(msg.sender, msg.value, change, order * units);
        }
        // Return user funds if the contract is not selling
        else if (!msg.sender.send(msg.value)) throw;
    }

    // Taker sells asset tokens for ethers by:
    // 1. Calling the asset's approve() method with the following parameters
    //    _spender            is the address of this contract
    //    _value              is the number of tokens to be sold
    // 2. Calling this takerSellAsset() method with the following parameter
    //    etherValueOfTokens  is the ether value of the asset tokens to be sold
    //                        by the taker
    //
    // The TakerSoldAsset() event is logged with the following parameters
    //   seller                    is the seller's address
    //   etherValueOfTokensToSell  is the ether value of the asset tokens being
    //                             sold by the taker
    //   tokensSold                is the number of the asset tokens sold
    //   etherValueOfTokensSold    is the ether value of the asset tokens sold
    //
    // This method was called sell() in the old version
    //
    function takerSellAsset(uint256 etherValueOfTokensToSell) {
        if (buysTokens || msg.sender == owner) {
            // Maximum number of token the contract can buy
            uint256 can_buy = this.balance / buyPrice;
            // Token lots available
            uint256 order = etherValueOfTokensToSell / units;
            // Adjust order for funds available
            if (order > can_buy) order = can_buy;
            if (order > 0) {
                // Extract user tokens
                if(!ERC20(asset).transferFrom(msg.sender, address(this), order * units)) throw;
                // Pay user
                if(!msg.sender.send(order * buyPrice)) throw;
            }
            TakerSoldAsset(msg.sender, etherValueOfTokensToSell, order * units, order * buyPrice);
        }
    }

    // Taker buys tokens by sending ethers
    function () payable {
        takerBuyAsset();
    }
}

// This contract deploys TokenTrader contracts and logs the event
contract TokenTraderFactory is Owned {

    event TradeListing(address indexed ownerAddress, address indexed tokenTraderAddress,
        address indexed asset, uint256 buyPrice, uint256 sellPrice, uint256 units,
        bool buysTokens, bool sellsTokens);
    event OwnerWithdrewERC20Token(address indexed tokenAddress, uint256 tokens);

    mapping(address => bool) _verify;

    // Anyone can call this method to verify the settings of a
    // TokenTrader contract. The parameters are:
    //   tradeContract  is the address of a TokenTrader contract
    //
    // Return values:
    //   valid        did this TokenTraderFactory create the TokenTrader contract?
    //   owner        is the owner of the TokenTrader contract
    //   asset        is the ERC20 asset address
    //   buyPrice     is the buy price in ethers per `units` of asset tokens
    //   sellPrice    is the sell price in ethers per `units` of asset tokens
    //   units        is the number of units of asset tokens
    //   buysTokens   is the TokenTrader contract buying tokens?
    //   sellsTokens  is the TokenTrader contract selling tokens?
    //
    function verify(address tradeContract) constant returns (
        bool    valid,
        address owner,
        address asset,
        uint256 buyPrice,
        uint256 sellPrice,
        uint256 units,
        bool    buysTokens,
        bool    sellsTokens
    ) {
        valid = _verify[tradeContract];
        if (valid) {
            TokenTrader t = TokenTrader(tradeContract);
            owner         = t.owner();
            asset         = t.asset();
            buyPrice      = t.buyPrice();
            sellPrice     = t.sellPrice();
            units         = t.units();
            buysTokens    = t.buysTokens();
            sellsTokens   = t.sellsTokens();
        }
    }

    // Maker can call this method to create a new TokenTrader contract
    // with the maker being the owner of this new contract
    //
    // Parameters:
    //   asset        is the ERC20 asset address
    //   buyPrice     is the buy price in ethers per `units` of asset tokens
    //   sellPrice    is the sell price in ethers per `units` of asset tokens
    //   units        is the number of units of asset tokens
    //   buysTokens   is the TokenTrader contract buying tokens?
    //   sellsTokens  is the TokenTrader contract selling tokens?
    //
    // For example, listing a TokenTrader contract on the REP Augur token where
    // the contract will buy REP tokens at a rate of 39000/100000 = 0.39 ETH
    // per REP token and sell REP tokens at a rate of 41000/100000 = 0.41 ETH
    // per REP token:
    //   asset        0x48c80f1f4d53d5951e5d5438b54cba84f29f32a5
    //   buyPrice     39000
    //   sellPrice    41000
    //   units        100000
    //   buysTokens   true
    //   sellsTokens  true
    //
    // The TradeListing() event is logged with the following parameters
    //   ownerAddress        is the Maker's address
    //   tokenTraderAddress  is the address of the newly created TokenTrader contract
    //   asset               is the ERC20 asset address
    //   buyPrice            is the buy price in ethers per `units` of asset tokens
    //   sellPrice           is the sell price in ethers per `units` of asset tokens
    //   unit                is the number of units of asset tokens
    //   buysTokens          is the TokenTrader contract buying tokens?
    //   sellsTokens         is the TokenTrader contract selling tokens?
    //
    function createTradeContract(
        address asset,
        uint256 buyPrice,
        uint256 sellPrice,
        uint256 units,
        bool    buysTokens,
        bool    sellsTokens
    ) returns (address trader) {
        // Cannot set zero or negative price
        if (buyPrice <= 0 || sellPrice <= 0) throw;
        // Must make profit on spread
        if (buyPrice >= sellPrice) throw;
        // Cannot buy or sell zero or negative units
        if (units <= 0) throw;
        trader = new TokenTrader(
            asset,
            buyPrice,
            sellPrice,
            units,
            buysTokens,
            sellsTokens);
        // Record that this factory created the trader
        _verify[trader] = true;
        // Set the owner to whoever called the function
        TokenTrader(trader).transferOwnership(msg.sender);
        TradeListing(msg.sender, trader, asset, buyPrice, sellPrice, units, buysTokens, sellsTokens);
    }

    // Factory owner can withdraw any ERC20 asset tokens from this contract
    //
    // This method is included in the case where this contract receives
    // the wrong tokens
    //
    // The OwnerWithdrewERC20Token() event is logged with the following
    // parameter:
    //   tokenAddress  is the address of the tokens withdrawn by the maker
    //   tokens        is the number of tokens withdrawn by the maker
    //
    function ownerWithdrawERC20Token(address tokenAddress, uint256 tokens) onlyOwner returns (bool ok) {
        OwnerWithdrewERC20Token(tokenAddress, tokens);
        return ERC20(tokenAddress).transfer(owner, tokens);
    }

    // Prevents accidental sending of ether to the factory
    function () {
        throw;
    }
}

pragma solidity ^0.4.4;

// ------------------------------------------------------------------------
// TokenTraderFactory
//
// Decentralised trustless ERC20-compliant token to ETH exchange contract
// on the Ethereum blockchain.
//
// Note that this TokenTrader cannot be used with the Golem Network Token
// directly as the token does not implement the ERC20
// transferFrom(...), approve(...) and allowance(...) methods
//
// Enjoy. (c) JonnyLatte & BokkyPooBah 2016. The MIT licence.
// ------------------------------------------------------------------------

// https://github.com/ethereum/EIPs/issues/20
contract ERC20 {
    function totalSupply() constant returns (uint totalSupply);
    function balanceOf(address _owner) constant returns (uint balance);
    function transfer(address _to, uint _value) returns (bool success);
    function transferFrom(address _from, address _to, uint _value) returns (bool success);
    function approve(address _spender, uint _value) returns (bool success);
    function allowance(address _owner, address _spender) constant returns (uint remaining);
    event Transfer(address indexed _from, address indexed _to, uint _value);
    event Approval(address indexed _owner, address indexed _spender, uint _value);
}

contract Owned {
    address public owner;
    event OwnershipTransferred(address indexed _from, address indexed _to);

    function Owned() {
        owner = msg.sender;
    }

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

    function transferOwnership(address newOwner) onlyOwner {
        OwnershipTransferred(owner, newOwner);
        owner = newOwner;
    }
}

// contract can buy or sell tokens for ETH
// prices are in amount of wei per batch of token units

contract TokenTrader is Owned {

    address public asset;       // address of token
    uint256 public buyPrice;    // contract buys lots of token at this price
    uint256 public sellPrice;   // contract sells lots at this price
    uint256 public units;       // lot size (token-wei)

    bool public buysTokens;     // is contract buying
    bool public sellsTokens;    // is contract selling

    event ActivatedEvent(bool buys, bool sells);
    event MakerDepositedEther(uint256 amount);
    event MakerWithdrewAsset(uint256 tokens);
    event MakerWithdrewERC20Token(address tokenAddress, uint256 tokens);
    event MakerWithdrewEther(uint256 ethers);
    event TakerBoughtAsset(address indexed buyer, uint256 ethersSent,
        uint256 ethersReturned, uint256 tokensBought);
    event TakerSoldAsset(address indexed seller, uint256 tokensToSell,
        uint256 tokensSold, uint256 ethers);

    // Constructor - only to be called by the TokenTraderFactory contract
    function TokenTrader (
        address _asset,
        uint256 _buyPrice,
        uint256 _sellPrice,
        uint256 _units,
        bool    _buysTokens,
        bool    _sellsTokens
    ) internal {
        asset       = _asset;
        buyPrice    = _buyPrice;
        sellPrice   = _sellPrice;
        units       = _units;
        buysTokens  = _buysTokens;
        sellsTokens = _sellsTokens;
        ActivatedEvent(buysTokens, sellsTokens);
    }

    // Maker can activate or deactivate this contract's buying and
    // selling status
    //
    // The ActivatedEvent() event is logged with the following
    // parameter:
    //   buysTokens   this contract can buy asset tokens
    //   sellsTokens  this contract can sell asset tokens
    //
    function activate (
        bool _buysTokens,
        bool _sellsTokens
    ) onlyOwner {
        buysTokens  = _buysTokens;
        sellsTokens = _sellsTokens;
        ActivatedEvent(buysTokens, sellsTokens);
    }

    // Maker can deposit ethers to this contract so this contract
    // can buy asset tokens.
    //
    // Maker deposits asset tokens to this contract by calling the
    // asset's transfer() method with the following parameters
    //   _to     is the address of THIS contract
    //   _value  is the number of asset tokens to be transferred
    //
    // Taker MUST NOT send tokens directly to this contract. Takers
    // MUST use the takerSellAsset() method to sell asset tokens
    // to this contract
    //
    // The MakerDepositedEther() event is logged with the following
    // parameter:
    //   ethers  is the number of ethers deposited by the maker
    //
    // This method was called deposit() in the old version
    //
    function makerDepositEther() payable onlyOwner {
        MakerDepositedEther(msg.value);
    }

    // Maker can withdraw asset tokens from this contract, with the
    // following parameter:
    //   tokens  is the number of asset tokens to be withdrawn
    //
    // The MakerWithdrewAsset() event is logged with the following
    // parameter:
    //   tokens  is the number of tokens withdrawn by the maker
    //
    // This method was called withdrawAsset() in the old version
    //
    function makerWithdrawAsset(uint256 tokens) onlyOwner returns (bool ok) {
        MakerWithdrewAsset(tokens);
        return ERC20(asset).transfer(owner, tokens);
    }

    // Maker can withdraw any ERC20 asset tokens from this contract
    //
    // This method is included in the case where this contract receives
    // the wrong tokens
    //
    // The MakerWithdrewERC20Token() event is logged with the following
    // parameter:
    //   tokenAddress  is the address of the tokens withdrawn by the maker
    //   tokens        is the number of tokens withdrawn by the maker
    //
    // This method was called withdrawToken() in the old version
    //
    function makerWithdrawERC20Token(
        address tokenAddress,
        uint256 tokens
    ) onlyOwner returns (bool ok) {
        MakerWithdrewERC20Token(tokenAddress, tokens);
        return ERC20(tokenAddress).transfer(owner, tokens);
    }

    // Maker can withdraw ethers from this contract
    //
    // The MakerWithdrewEther() event is logged with the following parameter
    //   ethers  is the number of ethers withdrawn by the maker
    //
    // This method was called withdraw() in the old version
    //
    function makerWithdrawEther(uint256 ethers) onlyOwner returns (bool ok) {
        if (this.balance >= ethers) {
            MakerWithdrewEther(ethers);
            return owner.send(ethers);
        }
    }

    // Taker buys asset tokens by sending ethers
    //
    // The TakerBoughtAsset() event is logged with the following parameters
    //   buyer           is the buyer's address
    //   ethersSent      is the number of ethers sent by the buyer
    //   ethersReturned  is the number of ethers sent back to the buyer as
    //                   change
    //   tokensBought    is the number of asset tokens sent to the buyer
    //
    // This method was called buy() in the old version
    //
    function takerBuyAsset() payable {
        if (sellsTokens || msg.sender == owner) {
            uint order    = msg.value / sellPrice;
            uint can_sell = ERC20(asset).balanceOf(address(this)) / units;
            uint256 change = 0;
            if (order > can_sell) {
                change = msg.value - (can_sell * sellPrice);
                order = can_sell;
                if (!msg.sender.send(change)) throw;
            }
            if (order > 0) {
                if(!ERC20(asset).transfer(msg.sender, order * units)) throw;
            }
            TakerBoughtAsset(msg.sender, msg.value, change, order * units);
        }
        // Return user funds if the contract is not selling
        else if (!msg.sender.send(msg.value)) throw;
    }

    // Taker sells asset tokens for ethers by:
    // 1. Calling the asset's approve() method with the following parameters
    //    _spender  is the address of this contract
    //    _value    is the number of tokens to be sold
    // 2. Calling this takerSellAsset() method with the following parameter
    //    tokens    is the number of asset tokens to be sold
    //
    // The TakerSoldAsset() event is logged with the following parameters
    //   seller        is the seller's address
    //   tokensToSell  is the number of asset tokens offered by the seller
    //   tokensSold    is the number of asset tokens sold
    //   ethers        is the number of ethers sent to the seller
    //
    // This method was called sell() in the old version
    //
    function takerSellAsset(uint256 tokens) {
        if (buysTokens || msg.sender == owner) {
            // Maximum number of token the contract can buy
            uint256 can_buy = this.balance / buyPrice;
            // Token lots available
            uint256 order = tokens / units;
            // Adjust order for funds available
            if (order > can_buy) order = can_buy;
            if (order > 0) {
                // Extract user tokens
                if(!ERC20(asset).transferFrom(msg.sender, address(this), order * units)) throw;
                // Pay user
                if(!msg.sender.send(order * buyPrice)) throw;
            }
            TakerSoldAsset(msg.sender, tokens, order * units, order * buyPrice);
        }
    }

    // Taker buys tokens by sending ethers
    function () payable {
        takerBuyAsset();
    }
}

// This contract deploys TokenTrader contracts and logs the event
contract TokenTraderFactory is Owned {

    event TradeListing(address ownerAddress, address tokenTraderAddress, address asset,
        uint256 buyPrice, uint256 sellPrice, uint256 units,
        bool buysTokens, bool sellsTokens);
    event OwnerWithdrewERC20Token(address tokenAddress, uint256 tokens);

    mapping(address => bool) _verify;

    // Anyone can call this method to verify the settings of a
    // TokenTrader contract. The parameters are:
    //   tradeContract  is the address of a TokenTrader contract
    //
    // Return values:
    //   valid        did this TokenTraderFactory create the TokenTrader contract?
    //   owner        is the owner of the TokenTrader contract
    //   asset        is the ERC20 asset address
    //   buyPrice     is the buy price in ethers per `units` of asset tokens
    //   sellPrice    is the sell price in ethers per `units` of asset tokens
    //   units        is the number of units of asset tokens
    //   buysTokens   is the TokenTrader contract buying tokens?
    //   sellsTokens  is the TokenTrader contract selling tokens?
    //
    function verify(address tradeContract) constant returns (
        bool    valid,
        address owner,
        address asset,
        uint256 buyPrice,
        uint256 sellPrice,
        uint256 units,
        bool    buysTokens,
        bool    sellsTokens
    ) {
        valid = _verify[tradeContract];
        if (valid) {
            TokenTrader t = TokenTrader(tradeContract);
            owner         = t.owner();
            asset         = t.asset();
            buyPrice      = t.buyPrice();
            sellPrice     = t.sellPrice();
            units         = t.units();
            buysTokens    = t.buysTokens();
            sellsTokens   = t.sellsTokens();
        }
    }

    // Maker can call this method to create a new TokenTrader contract
    // with the maker being the owner of this new contract
    //
    // Parameters:
    //   asset        is the ERC20 asset address
    //   buyPrice     is the buy price in ethers per `units` of asset tokens
    //   sellPrice    is the sell price in ethers per `units` of asset tokens
    //   units        is the number of units of asset tokens
    //   buysTokens   is the TokenTrader contract buying tokens?
    //   sellsTokens  is the TokenTrader contract selling tokens?
    //
    // For example, listing a TokenTrader contract on the REP Augur token where
    // the contract will buy REP tokens at a rate of 39000/100000 = 0.39 ETH
    // per REP token and sell REP tokens at a rate of 41000/100000 = 0.41 ETH
    // per REP token:
    //   asset        0x48c80f1f4d53d5951e5d5438b54cba84f29f32a5
    //   buyPrice     39000
    //   sellPrice    41000
    //   units        100000
    //   buysTokens   true
    //   sellsTokens  true
    //
    // The TradeListing() event is logged with the following parameters
    //   ownerAddress        is the Maker's address
    //   tokenTraderAddress  is the address of the newly created TokenTrader contract
    //   asset               is the ERC20 asset address
    //   buyPrice            is the buy price in ethers per `units` of asset tokens
    //   sellPrice           is the sell price in ethers per `units` of asset tokens
    //   unit                is the number of units of asset tokens
    //   buysTokens          is the TokenTrader contract buying tokens?
    //   sellsTokens         is the TokenTrader contract selling tokens?
    //
    function createTradeContract(
        address asset,
        uint256 buyPrice,
        uint256 sellPrice,
        uint256 units,
        bool    buysTokens,
        bool    sellsTokens
    ) returns (address trader) {
        // Cannot set negative price
        if (buyPrice < 0 || sellPrice < 0) throw;
        // Must make profit on spread
        if (buyPrice > sellPrice) throw;
        // Cannot buy or sell zero or negative units
        if (units <= 0) throw;
        trader = new TokenTrader(
            asset,
            buyPrice,
            sellPrice,
            units,
            buysTokens,
            sellsTokens);
        // Record that this factory created the trader
        _verify[trader] = true;
        // Set the owner to whoever called the function
        TokenTrader(trader).transferOwnership(msg.sender);
        TradeListing(msg.sender, trader, asset, buyPrice, sellPrice, units, buysTokens, sellsTokens);
    }

    // Factory owner can withdraw any ERC20 asset tokens from this contract
    //
    // This method is included in the case where this contract receives
    // the wrong tokens
    //
    // The OwnerWithdrewERC20Token() event is logged with the following
    // parameter:
    //   tokenAddress  is the address of the tokens withdrawn by the maker
    //   tokens        is the number of tokens withdrawn by the maker
    //
    function ownerWithdrawERC20Token(address tokenAddress, uint256 tokens) onlyOwner returns (bool ok) {
        OwnerWithdrewERC20Token(tokenAddress, tokens);
        return ERC20(tokenAddress).transfer(owner, tokens);
    }

    // Prevents accidental sending of ether to the factory
    function () {
        throw;
    }
}


Math.sol is not used, not needed

Math.sol is not used, not needed

Small thing, but the Math.sol is not really needed, since it is not used.

pragma solidity ^0.4.11;

import './ERC20Basic.sol';
import './SafeERC20.sol';
import '../ownership/Ownable.sol';
import '../math/SafeMath.sol';

/**
 * @title TokenVesting
 * @dev A token holder contract that can release its token balance gradually like a
 * typical vesting scheme, with a cliff and vesting period. Optionally revocable by the
 * owner.
 */
contract TokenVesting is Ownable {
  using SafeMath for uint256;
  using SafeERC20 for ERC20Basic;

  event Released(uint256 amount);
  event Revoked();

  // beneficiary of tokens after they are released
  address public beneficiary;

  uint256 public cliff;
  uint256 public start;
  uint256 public duration;

  bool public revocable;

  mapping (address => uint256) public released;
  mapping (address => bool) public revoked;

  /**
   * @dev Creates a vesting contract that vests its balance of any ERC20 token to the
   * _beneficiary, gradually in a linear fashion until _start + _duration. By then all
   * of the balance will have vested.
   * @param _beneficiary address of the beneficiary to whom vested tokens are transferred
   * @param _cliff duration in seconds of the cliff in which tokens will begin to vest
   * @param _duration duration in seconds of the period in which the tokens will vest
   * @param _revocable whether the vesting is revocable or not
   */
  function TokenVesting(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) {
    require(_beneficiary != address(0));
    require(_cliff <= _duration);

    beneficiary = _beneficiary;
    revocable = _revocable;
    duration = _duration;
    cliff = _start.add(_cliff);
    start = _start;
  }

  /**
   * @notice Transfers vested tokens to beneficiary.
   * @param token ERC20 token which is being vested
   */
  function release(ERC20Basic token) public {
    uint256 unreleased = releasableAmount(token);

    require(unreleased > 0);

    released[token] = released[token].add(unreleased);

    token.safeTransfer(beneficiary, unreleased);

    Released(unreleased);
  }

  /**
   * @notice Allows the owner to revoke the vesting. Tokens already vested
   * remain in the contract, the rest are returned to the owner.
   * @param token ERC20 token which is being vested
   */
  function revoke(ERC20Basic token) public onlyOwner {
    require(revocable);
    require(!revoked[token]);

    uint256 balance = token.balanceOf(this);

    uint256 unreleased = releasableAmount(token);
    uint256 refund = balance.sub(unreleased);

    revoked[token] = true;

    token.safeTransfer(owner, refund);

    Revoked();
  }

  /**
   * @dev Calculates the amount that has already vested but hasn't been released yet.
   * @param token ERC20 token which is being vested
   */
  function releasableAmount(ERC20Basic token) public constant returns (uint256) {
    return vestedAmount(token).sub(released[token]);
  }

  /**
   * @dev Calculates the amount that has already vested.
   * @param token ERC20 token which is being vested
   */
  function vestedAmount(ERC20Basic token) public constant returns (uint256) {
    uint256 currentBalance = token.balanceOf(this);
    uint256 totalBalance = currentBalance.add(released[token]);

    if (now < cliff) {
      return 0;
    } else if (now >= start.add(duration) || revoked[token]) {
      return totalBalance;
    } else {
      return totalBalance.mul(now.sub(start)).div(duration);
    }
  }
}

pragma solidity ^0.4.11;

import './ERC20Basic.sol';
import './SafeERC20.sol';
import '../ownership/Ownable.sol';
import '../math/Math.sol';
import '../math/SafeMath.sol';

/**
 * @title TokenVesting
 * @dev A token holder contract that can release its token balance gradually like a
 * typical vesting scheme, with a cliff and vesting period. Optionally revocable by the
 * owner.
 */
contract TokenVesting is Ownable {
  using SafeMath for uint256;
  using SafeERC20 for ERC20Basic;

  event Released(uint256 amount);
  event Revoked();

  // beneficiary of tokens after they are released
  address public beneficiary;

  uint256 public cliff;
  uint256 public start;
  uint256 public duration;

  bool public revocable;

  mapping (address => uint256) public released;
  mapping (address => bool) public revoked;

  /**
   * @dev Creates a vesting contract that vests its balance of any ERC20 token to the
   * _beneficiary, gradually in a linear fashion until _start + _duration. By then all
   * of the balance will have vested.
   * @param _beneficiary address of the beneficiary to whom vested tokens are transferred
   * @param _cliff duration in seconds of the cliff in which tokens will begin to vest
   * @param _duration duration in seconds of the period in which the tokens will vest
   * @param _revocable whether the vesting is revocable or not
   */
  function TokenVesting(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) {
    require(_beneficiary != address(0));
    require(_cliff <= _duration);

    beneficiary = _beneficiary;
    revocable = _revocable;
    duration = _duration;
    cliff = _start.add(_cliff);
    start = _start;
  }

  /**
   * @notice Transfers vested tokens to beneficiary.
   * @param token ERC20 token which is being vested
   */
  function release(ERC20Basic token) public {
    uint256 unreleased = releasableAmount(token);

    require(unreleased > 0);

    released[token] = released[token].add(unreleased);

    token.safeTransfer(beneficiary, unreleased);

    Released(unreleased);
  }

  /**
   * @notice Allows the owner to revoke the vesting. Tokens already vested
   * remain in the contract, the rest are returned to the owner.
   * @param token ERC20 token which is being vested
   */
  function revoke(ERC20Basic token) public onlyOwner {
    require(revocable);
    require(!revoked[token]);

    uint256 balance = token.balanceOf(this);

    uint256 unreleased = releasableAmount(token);
    uint256 refund = balance.sub(unreleased);

    revoked[token] = true;

    token.safeTransfer(owner, refund);

    Revoked();
  }

  /**
   * @dev Calculates the amount that has already vested but hasn't been released yet.
   * @param token ERC20 token which is being vested
   */
  function releasableAmount(ERC20Basic token) public constant returns (uint256) {
    return vestedAmount(token).sub(released[token]);
  }

  /**
   * @dev Calculates the amount that has already vested.
   * @param token ERC20 token which is being vested
   */
  function vestedAmount(ERC20Basic token) public constant returns (uint256) {
    uint256 currentBalance = token.balanceOf(this);
    uint256 totalBalance = currentBalance.add(released[token]);

    if (now < cliff) {
      return 0;
    } else if (now >= start.add(duration) || revoked[token]) {
      return totalBalance;
    } else {
      return totalBalance.mul(now.sub(start)).div(duration);
    }
  }
}


Minor alteration to terms.

Minor alteration to terms.

contract Config {
	function register(uint id, address service) {}
	function unregister(uint id) {}
	function lookup(uint service) constant returns(address a) {}
	function kill() {}
}
contract NameReg {
	function register(string32 name) {}
	function unregister() {}
	function addressOf(string32 name) constant returns (address addr) {}
	function nameOf(address addr) constant returns (string32 name) {}
	function kill() {}
}
/*
 * Use with:
 * wget -S -O - http://bullionsupermarket.com/GOLD/ 2> /dev/null | \
 * grep ' GOLD' | sed 's/\s*<td.*> GOLD<.td><td.*>\(.*\)<.td><td.*>.*<.td>/\1/' | sed s/,//
 */
contract PriceFeed {
	function PriceFeed() {
		owner = msg.sender;
		address ConfigAddress = 0xd5f9d8d94886e70b06e474c3fb14fd43e2f23970;
		uint NameRegId = 1;
		address nameregAddress = Config(ConfigAddress).lookup(NameRegId);
		NameReg(nameregAddress).register("GoldFeed");
	}

	function updateInfo(uint newInfo) {
		if (msg.sender == owner)
			info = newInfo;
	}

	function setPrice(uint newPrice) {
		if (msg.sender == owner)
			price = newPrice;
	}

	function get() constant returns(uint r) {
		if (msg.value >= price)
			r = info;
	}

	function kill() {
		if (msg.sender == owner) {
			uint NameRegId = 1;
			address nameregAddress = Config(ConfigAddress).lookup(NameRegId);
			NameReg(nameregAddress).unregister();
			suicide(owner);
		}
	}

	address owner;
	uint price;
	uint info;
}
/*
// TODO: should be:
contract PriceFeed: owned, mortal {
	function updateInfo(uint newInfo) restrict {
		NameReg(service(1)).register("GoldFeed");
		info = newInfo;
	}

	function setPrice(uint newPrice) restrict {
		price = newPrice;
	}

	function get() constant returns(uint r) {
		if (msg.value >= price)
			r = info;
	}

	uint price;
	uint info;
}

contract owned {
	modifier onlyowner { if (msg.sender == owner) _ }
	address owner = msg.sender;
}

contract mortal extends owned {
	function kill() onlyowner {
		suicide(owner);
	}
}

contract costs extends owned {
	modifier costs { if (msg.value >= price) _ }
	function setPrice(uint newPrice) onlyowned {
		price = newPrice;
	}

	uint price = 0;
}

contract named extends owned, mortal {
	function named(string name) {
		address ConfigAddress = 0xd5f9d8d94886e70b06e474c3fb14fd43e2f23970;
		uint NameRegId = 1;
		address nameregAddress = Config(ConfigAddress).lookup(NameRegId);
		NameReg(nameregAddress).register(name);
	}

	function kill() onlyowner {
		uint NameRegId = 1;
		address nameregAddress = Config(ConfigAddress).lookup(NameRegId);
		NameReg(nameregAddress).unregister();
		mortal.kill();
	}
}

// TODO: or better:
contract PriceFeed extends owned, mortal, costs, named("GoldFeed") {
	function updateInfo(uint newInfo) onlyowner {
		info = newInfo;
	}

	function get() constant costs returns(uint r) {
		r = info;
	}

	uint info;
}
*/

contract Config {
	function register(uint id, address service) {}
	function unregister(uint id) {}
	function lookup(uint service) constant returns(address a) {}
	function kill() {}
}
contract NameReg {
	function register(string32 name) {}
	function unregister() {}
	function addressOf(string32 name) constant returns (address addr) {}
	function nameOf(address addr) constant returns (string32 name) {}
	function kill() {}
}
/*
 * Use with:
 * wget -S -O - http://bullionsupermarket.com/GOLD/ 2> /dev/null | \
 * grep ' GOLD' | sed 's/\s*<td.*> GOLD<.td><td.*>\(.*\)<.td><td.*>.*<.td>/\1/' | sed s/,//
 */
contract PriceFeed {
	function PriceFeed() {
		owner = msg.sender;
		address ConfigAddress = 0xd5f9d8d94886e70b06e474c3fb14fd43e2f23970;
		uint NameRegId = 1;
		address nameregAddress = Config(ConfigAddress).lookup(NameRegId);
		NameReg(nameregAddress).register("GoldFeed");
	}

	function updateInfo(uint newInfo) {
		if (msg.sender == owner)
			info = newInfo;
	}

	function setPrice(uint newPrice) {
		if (msg.sender == owner)
			price = newPrice;
	}

	function get() constant returns(uint r) {
		if (msg.value >= price)
			r = info;
	}

	function kill() {
		if (msg.sender == owner) {
			uint NameRegId = 1;
			address nameregAddress = Config(ConfigAddress).lookup(NameRegId);
			NameReg(nameregAddress).unregister();
			suicide(owner);
		}
	}

	address owner;
	uint price;
	uint info;
}
/*
// TODO: should be:
contract PriceFeed: owned, mortal {
	function updateInfo(uint newInfo) restrict {
		NameReg(service(1)).register("GoldFeed");
		info = newInfo;
	}

	function setPrice(uint newPrice) restrict {
		price = newPrice;
	}

	function get() constant returns(uint r) {
		if (msg.value >= price)
			r = info;
	}

	uint price;
	uint info;
}

contract owned {
	surround onlyowner { if (msg.sender == owner) _ }
	address owner = msg.sender;
}

contract mortal extends owned {
	function kill() onlyowner {
		suicide(owner);
	}
}

contract costs extends owned {
	surround costs { if (msg.value >= price) _ }
	function setPrice(uint newPrice) onlyowned {
		price = newPrice;
	}

	uint price = 0;
}

contract named extends owned, mortal {
	function named(string name) {
		address ConfigAddress = 0xd5f9d8d94886e70b06e474c3fb14fd43e2f23970;
		uint NameRegId = 1;
		address nameregAddress = Config(ConfigAddress).lookup(NameRegId);
		NameReg(nameregAddress).register(name);
	}

	function kill() onlyowner {
		uint NameRegId = 1;
		address nameregAddress = Config(ConfigAddress).lookup(NameRegId);
		NameReg(nameregAddress).unregister();
		mortal.kill();
	}
}

// TODO: or better:
contract PriceFeed extends owned, mortal, costs, named("GoldFeed") {
	function updateInfo(uint newInfo) onlyowner {
		info = newInfo;
	}

	function get() constant costs returns(uint r) {
		r = info;
	}

	uint info;
}
*/


Add fix for the approve() mitigation.

Add fix for the approve() mitigation.

pragma solidity ^0.4.8;

import './BasicToken.sol';
import './ERC20.sol';

/**
 * Standard ERC20 token
 *
 * https://github.com/ethereum/EIPs/issues/20
 * Based on code by FirstBlood:
 * https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
 */
contract StandardToken is BasicToken, ERC20 {

  mapping (address => mapping (address => uint)) allowed;

  function transferFrom(address _from, address _to, uint _value) {
    var _allowance = allowed[_from][msg.sender];

    // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
    // if (_value > _allowance) throw;

    balances[_to] = balances[_to].add(_value);
    balances[_from] = balances[_from].sub(_value);
    allowed[_from][msg.sender] = _allowance.sub(_value);
    Transfer(_from, _to, _value);
  }

  function approve(address _spender, uint _value) {

    // To change the approve amount you first have to reduce the addresses`
    //  allowance to zero by calling `approve(_spender,0)` if it is not
    //  already 0 to mitigate the race condition described here:
    //  https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
    if ((_amount!=0) && (allowed[msg.sender][_spender] !=0)) throw;

    allowed[msg.sender][_spender] = _value;
    Approval(msg.sender, _spender, _value);
  }

  function allowance(address _owner, address _spender) constant returns (uint remaining) {
    return allowed[_owner][_spender];
  }

}

pragma solidity ^0.4.8;

import './BasicToken.sol';
import './ERC20.sol';

/**
 * Standard ERC20 token
 *
 * https://github.com/ethereum/EIPs/issues/20
 * Based on code by FirstBlood:
 * https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
 */
contract StandardToken is BasicToken, ERC20 {

  mapping (address => mapping (address => uint)) allowed;

  function transferFrom(address _from, address _to, uint _value) {
    var _allowance = allowed[_from][msg.sender];

    // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
    // if (_value > _allowance) throw;

    balances[_to] = balances[_to].add(_value);
    balances[_from] = balances[_from].sub(_value);
    allowed[_from][msg.sender] = _allowance.sub(_value);
    Transfer(_from, _to, _value);
  }

  function approve(address _spender, uint _value) {
    allowed[msg.sender][_spender] = _value;
    Approval(msg.sender, _spender, _value);
  }

  function allowance(address _owner, address _spender) constant returns (uint remaining) {
    return allowed[_owner][_spender];
  }

}


Fix nonsense

Fix nonsense

pragma solidity ^0.4.4;

library ConvertLib{
    function convert(uint amount,uint conversionRate) returns (uint convertedAmount)
    {
        return amount * conversionRate;
    }
}

error: pathspec 'contracts/ConvertLib.sol' did not match any file(s) known to git