contract Blackcard {
    
    // Using safemath 
    using SafeMath for uint256;

    // Basic token information
    string  public name     = "Blackcard Exchange";
    string  public symbol   = "BEX";
    uint256 public decimals = 18;
    
    // Mapping for balances and allowances
    mapping (address => uint256) public balanceOf;
    mapping (address => mapping (address => uint256)) public allowance;
    
    // Total initial supply of token
    uint256 public totalSupply  = 21000000000 * (10 ** uint256(decimals));

    // Wallet variables for address
    address owner;

    // Modifier is Owner address
    modifier isOwner {
        assert(owner == msg.sender);
        _;
    }
    
    // Constructor @when deployed
    constructor() public {
        owner               = msg.sender;
        balanceOf[owner]    = totalSupply;
        emit Transfer(address(0), owner, totalSupply);
    }

    // ERC20 Transfer function
    function transfer(address _to, uint256 _value) public returns (bool success) {
        require(_to != address(0));
        require(balanceOf[msg.sender] >= _value);
        require(balanceOf[_to].add(_value) >= balanceOf[_to]);
        balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value);
        balanceOf[_to] = balanceOf[_to].add(_value);
        emit Transfer(msg.sender, _to, _value);
        return true;
    }

    // ERC20 Transfer from wallet
    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
        require(_from != address(0) && _to != address(0));
        require(balanceOf[_from] >= _value);
        require(balanceOf[_to].add(_value) >= balanceOf[_to]);
        require(allowance[_from][msg.sender] >= _value);
        balanceOf[_to] = balanceOf[_to].add(_value);
        balanceOf[_from] = balanceOf[_from].sub(_value);
        allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value);
        emit Transfer(_from, _to, _value);
        return true;
    }

    // Approve to allow tranfer tokens
    function approve(address _spender, uint256 _value) public returns (bool success) {
        require(_spender != address(0));
        require(_value <= balanceOf[msg.sender]);
        require(_value == 0 || allowance[msg.sender][_spender] == 0);
        allowance[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value);
        return true;
    }
    
    event Transfer(address indexed _from, address indexed _to, uint256 _value);
    event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
// Main Blackcard Token Token Contract
function approve(address _spender, uint256 _value) public returns (bool success) {
    require(_spender != address(0));
    require(_value <= balanceOf[msg.sender]);
    require(_value == 0 || allowance[msg.sender][_spender] == 0);
    allowance[msg.sender][_spender] = _value;
    emit Approval(msg.sender, _spender, _value);
    return true;
}

// Approve to allow tranfer tokens