contract BlockvToken is StandardToken, Pausable {

  string public constant name = "BLOCKv Token"; // Set the token name for display
  string public constant symbol = "VEE";        // Set the token symbol for display
  uint8  public constant decimals = 18;         // Set the number of decimals for display

  PoolBLock public poolBLock;
  PoolCLock public poolCLock;
  PoolDLock public poolDLock;

  uint256 public constant totalAmountOfTokens = 3646271241200255205023407108;
  uint256 public constant amountOfTokensPoolA = 1276194934420089321758192488;
  uint256 public constant amountOfTokensPoolB = 911567810300063801255851777;
  uint256 public constant amountOfTokensPoolC = 911567810300063801255851777;
  uint256 public constant amountOfTokensPoolD = 546940686180038280753511066;

  // migration
  address public migrationMaster;
  address public migrationAgent;
  uint256 public totalMigrated;
  event Migrate(address indexed _from, address indexed _to, uint256 _value);

  /**
   * @dev BlockvToken Constructor
   * Runs only on initial contract creation.
   */
  function BlockvToken(address _migrationMaster) Pausable(_migrationMaster) {
    require(_migrationMaster != 0);
    migrationMaster = _migrationMaster;

    totalSupply = totalAmountOfTokens; // Set the total supply

    balances[msg.sender] = amountOfTokensPoolA;
    Transfer(0x0, msg.sender, amountOfTokensPoolA);
  
    // time-locked tokens
    poolBLock = new PoolBLock(this);
    poolCLock = new PoolCLock(this);
    poolDLock = new PoolDLock(this);

    balances[poolBLock] = amountOfTokensPoolB;
    balances[poolCLock] = amountOfTokensPoolC;
    balances[poolDLock] = amountOfTokensPoolD;

    Transfer(0x0, poolBLock, amountOfTokensPoolB);
    Transfer(0x0, poolCLock, amountOfTokensPoolC);
    Transfer(0x0, poolDLock, amountOfTokensPoolD);
  }

  /**
   * @dev Transfer token for a specified address when not paused
   * @param _to The address to transfer to.
   * @param _value The amount to be transferred.
   */
  function transfer(address _to, uint256 _value) whenNotPaused returns (bool) {
    require(_to != address(0));
    require(_to != address(this));
    return super.transfer(_to, _value);
  }

  /**
   * @dev Transfer tokens from one address to another when not paused
   * @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 amount of tokens to be transferred
   */
  function transferFrom(address _from, address _to, uint256 _value) whenNotPaused returns (bool) {
    require(_to != address(0));
    require(_from != _to);
    require(_to != address(this));
    return super.transferFrom(_from, _to, _value);
  }

  /**
   * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender when not paused.
   * @param _spender The address which will spend the funds.
   * @param _value The amount of tokens to be spent.
   */
  function approve(address _spender, uint256 _value) whenNotPaused returns (bool) {
    require(_spender != address(0));
    require(_spender != address(this));
    return super.approve(_spender, _value);
  }

  /**
  * Token migration support:
  */

  /** 
  * @notice Migrate tokens to the new token contract.
  * @dev Required state: Operational Migration
  * @param _value The amount of token to be migrated
  */
  function migrate(uint256 _value) external {
    require(migrationAgent != 0);
    require(_value != 0);
    require(_value <= balances[msg.sender]);

    balances[msg.sender] = balances[msg.sender].sub(_value);
    totalSupply = totalSupply.sub(_value);
    totalMigrated = totalMigrated.add(_value);
    MigrationAgent(migrationAgent).migrateFrom(msg.sender, _value);
    
    Migrate(msg.sender, migrationAgent, _value);
  }

  /**
  * @dev Set address of migration target contract and enable migration process.
  * @param _agent The address of the MigrationAgent contract
  */
  function setMigrationAgent(address _agent) external {
    require(_agent != 0);
    require(migrationAgent == 0);
    require(msg.sender == migrationMaster);

    migrationAgent = _agent;
  }

  function setMigrationMaster(address _master) external {
    require(_master != 0);
    require(msg.sender == migrationMaster);

    migrationMaster = _master;
  }
}
function approve(address _spender, uint256 _value) whenNotPaused returns (bool) {
  require(_spender != address(0));
  require(_spender != address(this));
  return super.approve(_spender, _value);
}

/**
 * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender when not paused.
 * @param _spender The address which will spend the funds.
 * @param _value The amount of tokens to be spent.
 */