ETH Price: $1,869.72 (-0.93%)

Transaction Decoder

Block:
5019322 at Feb-02-2018 09:03:48 PM +UTC
Transaction Fee:
0.000105188 ETH $0.20
Gas Used:
26,297 Gas / 4 Gwei

Emitted Events:

42 CargoXToken.Transfer( from=[Sender] 0xe48f10c76dc5d130a9a712841fc950d395c8a97d, to=[Receiver] EtherDelta, value=631000000000000000000 )
43 EtherDelta.Deposit( token=CargoXToken, user=[Sender] 0xe48f10c76dc5d130a9a712841fc950d395c8a97d, amount=631000000000000000000, balance=1260000000000000000000 )

Account State Difference:

  Address   Before After State Difference Code
0x8d12A197...2A5CC6819
(EtherDelta 2)
0xb6EE9668...4F8097143
0xe48f10c7...395C8a97d
0.999894583335866632 Eth
Nonce: 180
0.999789395335866632 Eth
Nonce: 181
0.000105188
(Ethermine)
725.610766412380632884 Eth725.610871600380632884 Eth0.000105188

Execution Trace

EtherDelta.depositToken( token=0xb6EE9668771a79be7967ee29a63D4184F8097143, amount=631000000000000000000 )
  • CargoXToken.transferFrom( _from=0xe48f10c76Dc5d130a9A712841Fc950D395C8a97d, _to=0x8d12A197cB00D4747a1fe03395095ce2A5CC6819, _value=631000000000000000000 ) => ( success=True )
    File 1 of 2: EtherDelta
    pragma solidity ^0.4.9;
    
    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;
      }
    }
    
    contract Token {
      /// @return total amount of tokens
      function totalSupply() constant returns (uint256 supply) {}
    
      /// @param _owner The address from which the balance will be retrieved
      /// @return The balance
      function balanceOf(address _owner) constant returns (uint256 balance) {}
    
      /// @notice send `_value` token to `_to` from `msg.sender`
      /// @param _to The address of the recipient
      /// @param _value The amount of token to be transferred
      /// @return Whether the transfer was successful or not
      function transfer(address _to, uint256 _value) returns (bool success) {}
    
      /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
      /// @param _from The address of the sender
      /// @param _to The address of the recipient
      /// @param _value The amount of token to be transferred
      /// @return Whether the transfer was successful or not
      function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
    
      /// @notice `msg.sender` approves `_addr` to spend `_value` tokens
      /// @param _spender The address of the account able to transfer the tokens
      /// @param _value The amount of wei to be approved for transfer
      /// @return Whether the approval was successful or not
      function approve(address _spender, uint256 _value) returns (bool success) {}
    
      /// @param _owner The address of the account owning tokens
      /// @param _spender The address of the account able to transfer the tokens
      /// @return Amount of remaining tokens allowed to spent
      function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
    
      event Transfer(address indexed _from, address indexed _to, uint256 _value);
      event Approval(address indexed _owner, address indexed _spender, uint256 _value);
    
      uint public decimals;
      string public name;
    }
    
    contract StandardToken is Token {
    
      function transfer(address _to, uint256 _value) returns (bool success) {
        //Default assumes totalSupply can't be over max (2^256 - 1).
        //If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap.
        //Replace the if with this one instead.
        if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
        //if (balances[msg.sender] >= _value && _value > 0) {
          balances[msg.sender] -= _value;
          balances[_to] += _value;
          Transfer(msg.sender, _to, _value);
          return true;
        } else { return false; }
      }
    
      function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
        //same as above. Replace this line with the following if you want to protect against wrapping uints.
        if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
        //if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
          balances[_to] += _value;
          balances[_from] -= _value;
          allowed[_from][msg.sender] -= _value;
          Transfer(_from, _to, _value);
          return true;
        } else { return false; }
      }
    
      function balanceOf(address _owner) constant returns (uint256 balance) {
        return balances[_owner];
      }
    
      function approve(address _spender, uint256 _value) returns (bool success) {
        allowed[msg.sender][_spender] = _value;
        Approval(msg.sender, _spender, _value);
        return true;
      }
    
      function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
        return allowed[_owner][_spender];
      }
    
      mapping(address => uint256) balances;
    
      mapping (address => mapping (address => uint256)) allowed;
    
      uint256 public totalSupply;
    }
    
    contract ReserveToken is StandardToken, SafeMath {
      address public minter;
      function ReserveToken() {
        minter = msg.sender;
      }
      function create(address account, uint amount) {
        if (msg.sender != minter) throw;
        balances[account] = safeAdd(balances[account], amount);
        totalSupply = safeAdd(totalSupply, amount);
      }
      function destroy(address account, uint amount) {
        if (msg.sender != minter) throw;
        if (balances[account] < amount) throw;
        balances[account] = safeSub(balances[account], amount);
        totalSupply = safeSub(totalSupply, amount);
      }
    }
    
    contract AccountLevels {
      //given a user, returns an account level
      //0 = regular user (pays take fee and make fee)
      //1 = market maker silver (pays take fee, no make fee, gets rebate)
      //2 = market maker gold (pays take fee, no make fee, gets entire counterparty's take fee as rebate)
      function accountLevel(address user) constant returns(uint) {}
    }
    
    contract AccountLevelsTest is AccountLevels {
      mapping (address => uint) public accountLevels;
    
      function setAccountLevel(address user, uint level) {
        accountLevels[user] = level;
      }
    
      function accountLevel(address user) constant returns(uint) {
        return accountLevels[user];
      }
    }
    
    contract EtherDelta is SafeMath {
      address public admin; //the admin address
      address public feeAccount; //the account that will receive fees
      address public accountLevelsAddr; //the address of the AccountLevels contract
      uint public feeMake; //percentage times (1 ether)
      uint public feeTake; //percentage times (1 ether)
      uint public feeRebate; //percentage times (1 ether)
      mapping (address => mapping (address => uint)) public tokens; //mapping of token addresses to mapping of account balances (token=0 means Ether)
      mapping (address => mapping (bytes32 => bool)) public orders; //mapping of user accounts to mapping of order hashes to booleans (true = submitted by user, equivalent to offchain signature)
      mapping (address => mapping (bytes32 => uint)) public orderFills; //mapping of user accounts to mapping of order hashes to uints (amount of order that has been filled)
    
      event Order(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user);
      event Cancel(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s);
      event Trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, address get, address give);
      event Deposit(address token, address user, uint amount, uint balance);
      event Withdraw(address token, address user, uint amount, uint balance);
    
      function EtherDelta(address admin_, address feeAccount_, address accountLevelsAddr_, uint feeMake_, uint feeTake_, uint feeRebate_) {
        admin = admin_;
        feeAccount = feeAccount_;
        accountLevelsAddr = accountLevelsAddr_;
        feeMake = feeMake_;
        feeTake = feeTake_;
        feeRebate = feeRebate_;
      }
    
      function() {
        throw;
      }
    
      function changeAdmin(address admin_) {
        if (msg.sender != admin) throw;
        admin = admin_;
      }
    
      function changeAccountLevelsAddr(address accountLevelsAddr_) {
        if (msg.sender != admin) throw;
        accountLevelsAddr = accountLevelsAddr_;
      }
    
      function changeFeeAccount(address feeAccount_) {
        if (msg.sender != admin) throw;
        feeAccount = feeAccount_;
      }
    
      function changeFeeMake(uint feeMake_) {
        if (msg.sender != admin) throw;
        if (feeMake_ > feeMake) throw;
        feeMake = feeMake_;
      }
    
      function changeFeeTake(uint feeTake_) {
        if (msg.sender != admin) throw;
        if (feeTake_ > feeTake || feeTake_ < feeRebate) throw;
        feeTake = feeTake_;
      }
    
      function changeFeeRebate(uint feeRebate_) {
        if (msg.sender != admin) throw;
        if (feeRebate_ < feeRebate || feeRebate_ > feeTake) throw;
        feeRebate = feeRebate_;
      }
    
      function deposit() payable {
        tokens[0][msg.sender] = safeAdd(tokens[0][msg.sender], msg.value);
        Deposit(0, msg.sender, msg.value, tokens[0][msg.sender]);
      }
    
      function withdraw(uint amount) {
        if (tokens[0][msg.sender] < amount) throw;
        tokens[0][msg.sender] = safeSub(tokens[0][msg.sender], amount);
        if (!msg.sender.call.value(amount)()) throw;
        Withdraw(0, msg.sender, amount, tokens[0][msg.sender]);
      }
    
      function depositToken(address token, uint amount) {
        //remember to call Token(address).approve(this, amount) or this contract will not be able to do the transfer on your behalf.
        if (token==0) throw;
        if (!Token(token).transferFrom(msg.sender, this, amount)) throw;
        tokens[token][msg.sender] = safeAdd(tokens[token][msg.sender], amount);
        Deposit(token, msg.sender, amount, tokens[token][msg.sender]);
      }
    
      function withdrawToken(address token, uint amount) {
        if (token==0) throw;
        if (tokens[token][msg.sender] < amount) throw;
        tokens[token][msg.sender] = safeSub(tokens[token][msg.sender], amount);
        if (!Token(token).transfer(msg.sender, amount)) throw;
        Withdraw(token, msg.sender, amount, tokens[token][msg.sender]);
      }
    
      function balanceOf(address token, address user) constant returns (uint) {
        return tokens[token][user];
      }
    
      function order(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce) {
        bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
        orders[msg.sender][hash] = true;
        Order(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender);
      }
    
      function trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount) {
        //amount is in amountGet terms
        bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
        if (!(
          (orders[user][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == user) &&
          block.number <= expires &&
          safeAdd(orderFills[user][hash], amount) <= amountGet
        )) throw;
        tradeBalances(tokenGet, amountGet, tokenGive, amountGive, user, amount);
        orderFills[user][hash] = safeAdd(orderFills[user][hash], amount);
        Trade(tokenGet, amount, tokenGive, amountGive * amount / amountGet, user, msg.sender);
      }
    
      function tradeBalances(address tokenGet, uint amountGet, address tokenGive, uint amountGive, address user, uint amount) private {
        uint feeMakeXfer = safeMul(amount, feeMake) / (1 ether);
        uint feeTakeXfer = safeMul(amount, feeTake) / (1 ether);
        uint feeRebateXfer = 0;
        if (accountLevelsAddr != 0x0) {
          uint accountLevel = AccountLevels(accountLevelsAddr).accountLevel(user);
          if (accountLevel==1) feeRebateXfer = safeMul(amount, feeRebate) / (1 ether);
          if (accountLevel==2) feeRebateXfer = feeTakeXfer;
        }
        tokens[tokenGet][msg.sender] = safeSub(tokens[tokenGet][msg.sender], safeAdd(amount, feeTakeXfer));
        tokens[tokenGet][user] = safeAdd(tokens[tokenGet][user], safeSub(safeAdd(amount, feeRebateXfer), feeMakeXfer));
        tokens[tokenGet][feeAccount] = safeAdd(tokens[tokenGet][feeAccount], safeSub(safeAdd(feeMakeXfer, feeTakeXfer), feeRebateXfer));
        tokens[tokenGive][user] = safeSub(tokens[tokenGive][user], safeMul(amountGive, amount) / amountGet);
        tokens[tokenGive][msg.sender] = safeAdd(tokens[tokenGive][msg.sender], safeMul(amountGive, amount) / amountGet);
      }
    
      function testTrade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount, address sender) constant returns(bool) {
        if (!(
          tokens[tokenGet][sender] >= amount &&
          availableVolume(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, user, v, r, s) >= amount
        )) return false;
        return true;
      }
    
      function availableVolume(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) constant returns(uint) {
        bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
        if (!(
          (orders[user][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == user) &&
          block.number <= expires
        )) return 0;
        uint available1 = safeSub(amountGet, orderFills[user][hash]);
        uint available2 = safeMul(tokens[tokenGive][user], amountGet) / amountGive;
        if (available1<available2) return available1;
        return available2;
      }
    
      function amountFilled(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) constant returns(uint) {
        bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
        return orderFills[user][hash];
      }
    
      function cancelOrder(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, uint8 v, bytes32 r, bytes32 s) {
        bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
        if (!(orders[msg.sender][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == msg.sender)) throw;
        orderFills[msg.sender][hash] = amountGet;
        Cancel(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender, v, r, s);
      }
    }

    File 2 of 2: CargoXToken
    pragma solidity ^0.4.11;
    
    // File: contracts/SafeMathLib.sol
    
    /**
     * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
     *
     * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
     */
    
    pragma solidity ^0.4.6;
    
    /**
     * Safe unsigned safe math.
     *
     * https://blog.aragon.one/library-driven-development-in-solidity-2bebcaf88736#.750gwtwli
     *
     * Originally from https://raw.githubusercontent.com/AragonOne/zeppelin-solidity/master/contracts/SafeMathLib.sol
     *
     * Maintained here until merged to mainline zeppelin-solidity.
     *
     */
    library SafeMathLib {
    
      function times(uint a, uint b) returns (uint) {
        uint c = a * b;
        assert(a == 0 || c / a == b);
        return c;
      }
    
      function minus(uint a, uint b) returns (uint) {
        assert(b <= a);
        return a - b;
      }
    
      function plus(uint a, uint b) returns (uint) {
        uint c = a + b;
        assert(c>=a);
        return c;
      }
    
    }
    
    // File: contracts/zeppelin/contracts/math/SafeMath.sol
    
    /**
     * @title SafeMath
     * @dev Math operations with safety checks that throw on error
     */
    library SafeMath {
      function mul(uint256 a, uint256 b) internal constant returns (uint256) {
        uint256 c = a * b;
        assert(a == 0 || c / a == b);
        return c;
      }
    
      function div(uint256 a, uint256 b) internal constant returns (uint256) {
        // assert(b > 0); // Solidity automatically throws when dividing by 0
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
      }
    
      function sub(uint256 a, uint256 b) internal constant returns (uint256) {
        assert(b <= a);
        return a - b;
      }
    
      function add(uint256 a, uint256 b) internal constant returns (uint256) {
        uint256 c = a + b;
        assert(c >= a);
        return c;
      }
    }
    
    // File: contracts/zeppelin/contracts/token/ERC20Basic.sol
    
    /**
     * @title ERC20Basic
     * @dev Simpler version of ERC20 interface
     * @dev see https://github.com/ethereum/EIPs/issues/179
     */
    contract ERC20Basic {
      uint256 public totalSupply;
      function balanceOf(address who) constant returns (uint256);
      function transfer(address to, uint256 value) returns (bool);
      event Transfer(address indexed from, address indexed to, uint256 value);
    }
    
    // File: contracts/zeppelin/contracts/token/BasicToken.sol
    
    /**
     * @title Basic token
     * @dev Basic version of StandardToken, with no allowances.
     */
    contract BasicToken is ERC20Basic {
      using SafeMath for uint256;
    
      mapping(address => uint256) balances;
    
      /**
      * @dev transfer token for a specified address
      * @param _to The address to transfer to.
      * @param _value The amount to be transferred.
      */
      function transfer(address _to, uint256 _value) returns (bool) {
        balances[msg.sender] = balances[msg.sender].sub(_value);
        balances[_to] = balances[_to].add(_value);
        Transfer(msg.sender, _to, _value);
        return true;
      }
    
      /**
      * @dev Gets the balance of the specified address.
      * @param _owner The address to query the the balance of.
      * @return An uint256 representing the amount owned by the passed address.
      */
      function balanceOf(address _owner) constant returns (uint256 balance) {
        return balances[_owner];
      }
    
    }
    
    // File: contracts/zeppelin/contracts/token/ERC20.sol
    
    /**
     * @title ERC20 interface
     * @dev see https://github.com/ethereum/EIPs/issues/20
     */
    contract ERC20 is ERC20Basic {
      function allowance(address owner, address spender) constant returns (uint256);
      function transferFrom(address from, address to, uint256 value) returns (bool);
      function approve(address spender, uint256 value) returns (bool);
      event Approval(address indexed owner, address indexed spender, uint256 value);
    }
    
    // File: contracts/zeppelin/contracts/token/StandardToken.sol
    
    /**
     * @title Standard ERC20 token
     *
     * @dev Implementation of the basic standard token.
     * @dev https://github.com/ethereum/EIPs/issues/20
     * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
     */
    contract StandardToken is ERC20, BasicToken {
    
      mapping (address => mapping (address => uint256)) allowed;
    
    
      /**
       * @dev Transfer tokens from one address to another
       * @param _from address The address which you want to send tokens from
       * @param _to address The address which you want to transfer to
       * @param _value uint256 the amout of tokens to be transfered
       */
      function transferFrom(address _from, address _to, uint256 _value) returns (bool) {
        var _allowance = allowed[_from][msg.sender];
    
        // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
        // require (_value <= _allowance);
    
        balances[_to] = balances[_to].add(_value);
        balances[_from] = balances[_from].sub(_value);
        allowed[_from][msg.sender] = _allowance.sub(_value);
        Transfer(_from, _to, _value);
        return true;
      }
    
      /**
       * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
       * @param _spender The address which will spend the funds.
       * @param _value The amount of tokens to be spent.
       */
      function approve(address _spender, uint256 _value) returns (bool) {
    
        // 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
        require((_value == 0) || (allowed[msg.sender][_spender] == 0));
    
        allowed[msg.sender][_spender] = _value;
        Approval(msg.sender, _spender, _value);
        return true;
      }
    
      /**
       * @dev Function to check the amount of tokens that an owner allowed to a spender.
       * @param _owner address The address which owns the funds.
       * @param _spender address The address which will spend the funds.
       * @return A uint256 specifing the amount of tokens still available for the spender.
       */
      function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
        return allowed[_owner][_spender];
      }
    
    }
    
    // File: contracts/StandardTokenExt.sol
    
    /**
     * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
     *
     * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
     */
    
    pragma solidity ^0.4.14;
    
    
    
    
    /**
     * Standard EIP-20 token with an interface marker.
     *
     * @notice Interface marker is used by crowdsale contracts to validate that addresses point a good token contract.
     *
     */
    contract StandardTokenExt is StandardToken {
    
      /* Interface declaration */
      function isToken() public constant returns (bool weAre) {
        return true;
      }
    }
    
    // File: contracts/zeppelin/contracts/ownership/Ownable.sol
    
    /**
     * @title Ownable
     * @dev The Ownable contract has an owner address, and provides basic authorization control
     * functions, this simplifies the implementation of "user permissions".
     */
    contract Ownable {
      address public owner;
    
    
      /**
       * @dev The Ownable constructor sets the original `owner` of the contract to the sender
       * account.
       */
      function Ownable() {
        owner = msg.sender;
      }
    
    
      /**
       * @dev Throws if called by any account other than the owner.
       */
      modifier onlyOwner() {
        require(msg.sender == owner);
        _;
      }
    
    
      /**
       * @dev Allows the current owner to transfer control of the contract to a newOwner.
       * @param newOwner The address to transfer ownership to.
       */
      function transferOwnership(address newOwner) onlyOwner {
        require(newOwner != address(0));
        owner = newOwner;
      }
    
    }
    
    // File: contracts/MintableToken.sol
    
    /**
     * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
     *
     * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
     */
    
    
    
    
    
    
    pragma solidity ^0.4.6;
    
    /**
     * A token that can increase its supply by another contract.
     *
     * This allows uncapped crowdsale by dynamically increasing the supply when money pours in.
     * Only mint agents, contracts whitelisted by owner, can mint new tokens.
     *
     */
    contract MintableToken is StandardTokenExt, Ownable {
    
      using SafeMathLib for uint;
    
      bool public mintingFinished = false;
    
      /** List of agents that are allowed to create new tokens */
      mapping (address => bool) public mintAgents;
    
      event MintingAgentChanged(address addr, bool state);
      event Minted(address receiver, uint amount);
    
      /**
       * Create new tokens and allocate them to an address..
       *
       * Only callably by a crowdsale contract (mint agent).
       */
      function mint(address receiver, uint amount) onlyMintAgent canMint public {
        totalSupply = totalSupply.plus(amount);
        balances[receiver] = balances[receiver].plus(amount);
    
        // This will make the mint transaction apper in EtherScan.io
        // We can remove this after there is a standardized minting event
        Transfer(0, receiver, amount);
      }
    
      /**
       * Owner can allow a crowdsale contract to mint new tokens.
       */
      function setMintAgent(address addr, bool state) onlyOwner canMint public {
        mintAgents[addr] = state;
        MintingAgentChanged(addr, state);
      }
    
      modifier onlyMintAgent() {
        // Only crowdsale contracts are allowed to mint new tokens
        if(!mintAgents[msg.sender]) {
            throw;
        }
        _;
      }
    
      /** Make sure we are not done yet. */
      modifier canMint() {
        if(mintingFinished) throw;
        _;
      }
    }
    
    // File: contracts/ReleasableToken.sol
    
    /**
     * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
     *
     * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
     */
    
    pragma solidity ^0.4.8;
    
    
    
    
    
    /**
     * Define interface for releasing the token transfer after a successful crowdsale.
     */
    contract ReleasableToken is ERC20, Ownable {
    
      /* The finalizer contract that allows unlift the transfer limits on this token */
      address public releaseAgent;
    
      /** A crowdsale contract can release us to the wild if ICO success. If false we are are in transfer lock up period.*/
      bool public released = false;
    
      /** Map of agents that are allowed to transfer tokens regardless of the lock down period. These are crowdsale contracts and possible the team multisig itself. */
      mapping (address => bool) public transferAgents;
    
      /**
       * Limit token transfer until the crowdsale is over.
       *
       */
      modifier canTransfer(address _sender) {
    
        if(!released) {
            if(!transferAgents[_sender]) {
                throw;
            }
        }
    
        _;
      }
    
      /**
       * Set the contract that can call release and make the token transferable.
       *
       * Design choice. Allow reset the release agent to fix fat finger mistakes.
       */
      function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public {
    
        // We don't do interface check here as we might want to a normal wallet address to act as a release agent
        releaseAgent = addr;
      }
    
      /**
       * Owner can allow a particular address (a crowdsale contract) to transfer tokens despite the lock up period.
       */
      function setTransferAgent(address addr, bool state) onlyOwner inReleaseState(false) public {
        transferAgents[addr] = state;
      }
    
      /**
       * One way function to release the tokens to the wild.
       *
       * Can be called only from the release agent that is the final ICO contract. It is only called if the crowdsale has been success (first milestone reached).
       */
      function releaseTokenTransfer() public onlyReleaseAgent {
        released = true;
      }
    
      /** The function can be called only before or after the tokens have been releasesd */
      modifier inReleaseState(bool releaseState) {
        if(releaseState != released) {
            throw;
        }
        _;
      }
    
      /** The function can be called only by a whitelisted release agent. */
      modifier onlyReleaseAgent() {
        if(msg.sender != releaseAgent) {
            throw;
        }
        _;
      }
    
      function transfer(address _to, uint _value) canTransfer(msg.sender) returns (bool success) {
        // Call StandardToken.transfer()
       return super.transfer(_to, _value);
      }
    
      function transferFrom(address _from, address _to, uint _value) canTransfer(_from) returns (bool success) {
        // Call StandardToken.transferForm()
        return super.transferFrom(_from, _to, _value);
      }
    
    }
    
    // File: contracts/UpgradeAgent.sol
    
    /**
     * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
     *
     * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
     */
    
    pragma solidity ^0.4.6;
    
    /**
     * Upgrade agent interface inspired by Lunyr.
     *
     * Upgrade agent transfers tokens to a new contract.
     * Upgrade agent itself can be the token contract, or just a middle man contract doing the heavy lifting.
     */
    contract UpgradeAgent {
    
      uint public originalSupply;
    
      /** Interface marker */
      function isUpgradeAgent() public constant returns (bool) {
        return true;
      }
    
      function upgradeFrom(address _from, uint256 _value) public;
    
    }
    
    // File: contracts/UpgradeableToken.sol
    
    /**
     * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
     *
     * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
     */
    
    pragma solidity ^0.4.8;
    
    
    
    
    
    /**
     * A token upgrade mechanism where users can opt-in amount of tokens to the next smart contract revision.
     *
     * First envisioned by Golem and Lunyr projects.
     */
    contract UpgradeableToken is StandardTokenExt {
    
      /** Contract / person who can set the upgrade path. This can be the same as team multisig wallet, as what it is with its default value. */
      address public upgradeMaster;
    
      /** The next contract where the tokens will be migrated. */
      UpgradeAgent public upgradeAgent;
    
      /** How many tokens we have upgraded by now. */
      uint256 public totalUpgraded;
    
      /**
       * Upgrade states.
       *
       * - NotAllowed: The child contract has not reached a condition where the upgrade can bgun
       * - WaitingForAgent: Token allows upgrade, but we don't have a new agent yet
       * - ReadyToUpgrade: The agent is set, but not a single token has been upgraded yet
       * - Upgrading: Upgrade agent is set and the balance holders can upgrade their tokens
       *
       */
      enum UpgradeState {Unknown, NotAllowed, WaitingForAgent, ReadyToUpgrade, Upgrading}
    
      /**
       * Somebody has upgraded some of his tokens.
       */
      event Upgrade(address indexed _from, address indexed _to, uint256 _value);
    
      /**
       * New upgrade agent available.
       */
      event UpgradeAgentSet(address agent);
    
      /**
       * Do not allow construction without upgrade master set.
       */
      function UpgradeableToken(address _upgradeMaster) {
        upgradeMaster = _upgradeMaster;
      }
    
      /**
       * Allow the token holder to upgrade some of their tokens to a new contract.
       */
      function upgrade(uint256 value) public {
    
          UpgradeState state = getUpgradeState();
          if(!(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading)) {
            // Called in a bad state
            throw;
          }
    
          // Validate input value.
          if (value == 0) throw;
    
          balances[msg.sender] = balances[msg.sender].sub(value);
    
          // Take tokens out from circulation
          totalSupply = totalSupply.sub(value);
          totalUpgraded = totalUpgraded.add(value);
    
          // Upgrade agent reissues the tokens
          upgradeAgent.upgradeFrom(msg.sender, value);
          Upgrade(msg.sender, upgradeAgent, value);
      }
    
      /**
       * Set an upgrade agent that handles
       */
      function setUpgradeAgent(address agent) external {
    
          if(!canUpgrade()) {
            // The token is not yet in a state that we could think upgrading
            throw;
          }
    
          if (agent == 0x0) throw;
          // Only a master can designate the next agent
          if (msg.sender != upgradeMaster) throw;
          // Upgrade has already begun for an agent
          if (getUpgradeState() == UpgradeState.Upgrading) throw;
    
          upgradeAgent = UpgradeAgent(agent);
    
          // Bad interface
          if(!upgradeAgent.isUpgradeAgent()) throw;
          // Make sure that token supplies match in source and target
          if (upgradeAgent.originalSupply() != totalSupply) throw;
    
          UpgradeAgentSet(upgradeAgent);
      }
    
      /**
       * Get the state of the token upgrade.
       */
      function getUpgradeState() public constant returns(UpgradeState) {
        if(!canUpgrade()) return UpgradeState.NotAllowed;
        else if(address(upgradeAgent) == 0x00) return UpgradeState.WaitingForAgent;
        else if(totalUpgraded == 0) return UpgradeState.ReadyToUpgrade;
        else return UpgradeState.Upgrading;
      }
    
      /**
       * Change the upgrade master.
       *
       * This allows us to set a new owner for the upgrade mechanism.
       */
      function setUpgradeMaster(address master) public {
          if (master == 0x0) throw;
          if (msg.sender != upgradeMaster) throw;
          upgradeMaster = master;
      }
    
      /**
       * Child contract can enable to provide the condition when the upgrade can begun.
       */
      function canUpgrade() public constant returns(bool) {
         return true;
      }
    
    }
    
    // File: contracts/CrowdsaleToken.sol
    
    /**
     * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
     *
     * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
     */
    
    pragma solidity ^0.4.8;
    
    
    
    
    
    
    /**
     * A crowdsaled token.
     *
     * An ERC-20 token designed specifically for crowdsales with investor protection and further development path.
     *
     * - The token transfer() is disabled until the crowdsale is over
     * - The token contract gives an opt-in upgrade path to a new contract
     * - The same token can be part of several crowdsales through approve() mechanism
     * - The token can be capped (supply set in the constructor) or uncapped (crowdsale contract can mint new tokens)
     *
     */
    contract CrowdsaleToken is ReleasableToken, MintableToken, UpgradeableToken {
    
      /** Name and symbol were updated. */
      event UpdatedTokenInformation(string newName, string newSymbol);
    
      string public name;
    
      string public symbol;
    
      uint public decimals;
    
      /**
       * Construct the token.
       *
       * This token must be created through a team multisig wallet, so that it is owned by that wallet.
       *
       * @param _name Token name
       * @param _symbol Token symbol - should be all caps
       * @param _initialSupply How many tokens we start with
       * @param _decimals Number of decimal places
       * @param _mintable Are new tokens created over the crowdsale or do we distribute only the initial supply? Note that when the token becomes transferable the minting always ends.
       */
      function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint _decimals, bool _mintable)
        UpgradeableToken(msg.sender) {
    
        // Create any address, can be transferred
        // to team multisig via changeOwner(),
        // also remember to call setUpgradeMaster()
        owner = msg.sender;
    
        name = _name;
        symbol = _symbol;
    
        totalSupply = _initialSupply;
    
        decimals = _decimals;
    
        // Create initially all balance on the team multisig
        balances[owner] = totalSupply;
    
        if(totalSupply > 0) {
          Minted(owner, totalSupply);
        }
    
        // No more new supply allowed after the token creation
        if(!_mintable) {
          mintingFinished = true;
          if(totalSupply == 0) {
            throw; // Cannot create a token without supply and no minting
          }
        }
      }
    
      /**
       * When token is released to be transferable, enforce no new tokens can be created.
       */
      function releaseTokenTransfer() public onlyReleaseAgent {
        mintingFinished = true;
        super.releaseTokenTransfer();
      }
    
      /**
       * Allow upgrade agent functionality kick in only if the crowdsale was success.
       */
      function canUpgrade() public constant returns(bool) {
        return released && super.canUpgrade();
      }
    
      /**
       * Owner can update token information here.
       *
       * It is often useful to conceal the actual token association, until
       * the token operations, like central issuance or reissuance have been completed.
       *
       * This function allows the token owner to rename the token after the operations
       * have been completed and then point the audience to use the token contract.
       */
      function setTokenInformation(string _name, string _symbol) onlyOwner {
        name = _name;
        symbol = _symbol;
    
        UpdatedTokenInformation(name, symbol);
      }
    
    }
    
    // File: contracts/CargoXToken.sol
    
    /**
     * Copyright 2018 CargoX.io (https://cargox.io)
     *
     * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
     */
     pragma solidity ^0.4.8;
    
    
    
    
    /**
     * A CargoX token.
     *
     */
    contract CargoXToken is CrowdsaleToken {
    
      function CargoXToken(string _name, string _symbol, uint _initialSupply, uint _decimals, bool _mintable)
        CrowdsaleToken(_name, _symbol, _initialSupply, _decimals, _mintable) {
      }
    
    }