contract DNACoin is StandardToken, Ownable {
  string public constant name = "DNA Coin";
  string public constant symbol = "DNA";
  uint256 public constant decimals = 18;

  uint256 public constant UNIT = 10 ** decimals;

  address public companyWallet;
  address public backendWallet;

  uint256 public maxSupply = 1000000 * UNIT;
  

  /**
   * event for token purchase logging
   * @param purchaser who paid for the tokens
   * @param beneficiary who got the tokens
   * @param value weis paid for purchase
   * @param amount amount of tokens purchased
   */
  event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);

  modifier onlyBackend() {
    require(msg.sender == backendWallet);
    _;
  }

  function DNACoin(address _companyWallet, address _backendWallet) public {
    companyWallet = _companyWallet;
    backendWallet = _backendWallet;
    balances[companyWallet] = 500000 * UNIT;
    totalSupply_ = totalSupply_.add(500000 * UNIT);
    Transfer(address(0x0), _companyWallet, 500000 * UNIT);
  }

  /**
   * Change the backendWallet that is allowed to issue new tokens (used by server side)
   * Or completely disabled backend unrevokable for all eternity by setting it to 0x0. Should be done after token sale completed.
   */
  function setBackendWallet(address _backendWallet) public onlyOwner {
    if (backendWallet != address(0)) {
      backendWallet = _backendWallet;
    }
  }

  function() public payable {
    revert();
  }

  /***
   * This function is used to transfer tokens that have been bought through other means (credit card, bitcoin, etc), and to burn tokens after the sale.
   */
  function mint(address receiver, uint256 tokens) public onlyBackend {
    require(totalSupply_ + tokens <= maxSupply);
    balances[receiver] += tokens;
    totalSupply_ += tokens;
    Transfer(address(0x0), receiver, tokens);
  }

  function sendBonus(address receiver, uint256 bonus) public onlyBackend {
    Transfer(companyWallet, receiver, bonus);
    balances[companyWallet] = balances[companyWallet].sub(bonus);
    balances[receiver] = balances[receiver].add(bonus);
  }

}
function setBackendWallet(address _backendWallet) public onlyOwner {
  if (backendWallet != address(0)) {
    backendWallet = _backendWallet;
  }
}

/**
 * Change the backendWallet that is allowed to issue new tokens (used by server side)
 * Or completely disabled backend unrevokable for all eternity by setting it to 0x0. Should be done after token sale completed.
 */