contract CryptoAxe is ERC20Detailed 
{
    using SafeMath for uint256;
    
    mapping (address => uint256) private _balances;
    mapping (address => mapping (address => uint256)) private _allowed;
    
    string constant tokenName = "CryptoAxe";//"CryptoAxe";
    string constant tokenSymbol = "CAXE";//"CAXE"; 
    uint8  constant tokenDecimals = 0;
    uint256 _totalSupply = 0;
    //shown in public 
    uint256 public RemainingSupply = 0;
    
    // ------------------------------------------------------------------------
  
    address public contractOwner;

    
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    
    // ------------------------------------------------------------------------
    
    constructor() public ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) 
    {
        contractOwner = msg.sender;
        _mint(msg.sender, (2**(256) - 1)
 * (10**uint256(tokenDecimals)));
    }
    
    // ------------------------------------------------------------------------

    function transferOwnership(address newOwner) public 
    {
        require(msg.sender == contractOwner);
        require(newOwner != address(0));
        emit OwnershipTransferred(contractOwner, newOwner);
        contractOwner = newOwner;
    }
    
    function totalSupply() public view returns (uint256) 
    {
        return _totalSupply;
    }
    
    function balanceOf(address owner) public view returns (uint256) 
    {
        return _balances[owner];
    }
    
    
    
    function allowance(address owner, address spender) public view returns (uint256) 
    {
        return _allowed[owner][spender];
    }
    
    function transfer(address to, uint256 value) public returns (bool) 
    {
        _executeTransfer(msg.sender, to, value);
        return true;
    }
    
    function multiTransfer(address[] memory receivers, uint256[] memory values) public
    {
        require(receivers.length == values.length);
        for(uint256 i = 0; i < receivers.length; i++)
            _executeTransfer(msg.sender, receivers[i], values[i]);
    }
    
    function transferFrom(address from, address to, uint256 value) public returns (bool) 
    {
        require(value <= _allowed[from][msg.sender]);
        _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
        _executeTransfer(from, to, value);
        return true;
    }
    
    function approve(address spender, uint256 value) public returns (bool) 
    {
        require(spender != address(0));
        _allowed[msg.sender][spender] = value;
        emit Approval(msg.sender, spender, value);
        return true;
    }
    
    function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) 
    {
        _allowed[msg.sender][spender] = tokens;
        emit Approval(msg.sender, spender, tokens);
        ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
        return true;
    }
    
    function increaseAllowance(address spender, uint256 addedValue) public returns (bool) 
    {
        require(spender != address(0));
        _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue));
        emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
        return true;
    }
    
    function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) 
    {
        require(spender != address(0));
        _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue));
        emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
        return true;
    }
    
    function _mint(address account, uint256 value) internal 
    {
        require(value != 0);
        
        uint256 originalBalance = _balances[account];
        uint256 newBalance = originalBalance.add(value);
        
        _balances[account] = newBalance;
        _totalSupply = _totalSupply.add(value);
        //public
		RemainingSupply = _totalSupply;
        
        
        emit Transfer(address(0), account, value);
    }
    
    uint256 public totalBurn = 0;
    
    function burn(uint256 value) external 
    {
        _burn(msg.sender, value);
    }
    
    function burnFrom(address account, uint256 value) external 
    {
        require(value <= _allowed[account][msg.sender]);
        _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value);
        _burn(account, value);
    }
    
    function _burn(address account, uint256 value) internal 
    {
        require(value != 0);
        require(value <= _balances[account]);
        
        uint256 originalBalance = _balances[account];
        uint256 newBalance = originalBalance.sub(value);
        
        _balances[account] = newBalance;
        _totalSupply = _totalSupply.sub(value);
        RemainingSupply = _totalSupply;
        
        emit Transfer(account, address(0), value);
        totalBurn += value;
    }
    
    /*
    *   95% to receiver
    *   5% burn
    *    
    */
    function _executeTransfer(address from, address to, uint256 value) private
    {
     
        require(value <= _balances[from]);
        require(to != address(0) && to != address(this));

        
        uint256 fivePercent = value.mul(5).div(100);

		//for clarity
		uint256 amountToDeduct = fivePercent;

/* optional 
        
        //set a minimum burn rate to prevent no-burn-txs due to precision loss
        if(threePercent == 0 && value > 0)
            threePercent = 1;
*/            
        uint256 originalBalance_from = _balances[from];
        uint256 newBalance_from = originalBalance_from.sub(value);
        
        value = value.sub(amountToDeduct);
        
        uint256 originalBalance_to = _balances[to];
        uint256 newBalance_to = originalBalance_to.add(value);
        
        //transfer
        _balances[from] = newBalance_from;
        _balances[to] = newBalance_to;
        emit Transfer(from, to, value);
      
	  //update total supply
        _totalSupply = _totalSupply.sub(amountToDeduct);
        RemainingSupply = _totalSupply;


		//burn
		_burn(msg.sender, amountToDeduct);
        totalBurn += value;

    }
    
    
    
	
    //withdraw incoming tokens 
    function withdrawERC20Tokens(address tokenAddress, uint256 amount) public
    {
        require(msg.sender == contractOwner);
        require(tokenAddress != address(this));
        IERC20(tokenAddress).transfer(msg.sender, amount);
    }
    
}
function _executeTransfer(address from, address to, uint256 value) private
{
     
    require(value <= _balances[from]);
    require(to != address(0) && to != address(this));

        
    uint256 fivePercent = value.mul(5).div(100);

for clarity
nt256 amountToDeduct = fivePercent;

ptional 
        
    //set a minimum burn rate to prevent no-burn-txs due to precision loss
    if(threePercent == 0 && value > 0)
        threePercent = 1;
          
    uint256 originalBalance_from = _balances[from];
    uint256 newBalance_from = originalBalance_from.sub(value);
        
    value = value.sub(amountToDeduct);
        
    uint256 originalBalance_to = _balances[to];
    uint256 newBalance_to = originalBalance_to.add(value);
        
    //transfer
    _balances[from] = newBalance_from;
    _balances[to] = newBalance_to;
    emit Transfer(from, to, value);
      
/update total supply
    _totalSupply = _totalSupply.sub(amountToDeduct);
    RemainingSupply = _totalSupply;


burn
urn(msg.sender, amountToDeduct);
    totalBurn += value;

}

/*
 *   95% to receiver
 *   5% burn
 *    
 */