contract BLOCKPIX_Coin is StandardToken
{
    using SafeMath for uint256;
    
    string public constant name = "BLOCKPIX Coin";
    string public constant symbol = "BPX";
    uint256 public constant decimals = 18;
    
    uint256 public constant BPX_per_ETH = 10000;
    
    address public owner;
    
    // Constructor function
    function BLOCKPIX_Coin() public
    {
        owner = msg.sender;
        totalSupply_ = 250000000 * (uint256(10)**decimals);
        balances[owner] = totalSupply_;
        Transfer(0x0, owner, totalSupply_);
    }
    
    // If ETH is sent to this contract, assume they are trying to buy tokens
    function () payable external
    {
        buyTokens();
    }
    
    function buyTokens() payable public
    {
        // Calculate the amount of purchased tokens
        uint256 tokensPurchased = msg.value * BPX_per_ETH;
        
        // Make sure the owner has enough tokens
        require(balances[owner] >= tokensPurchased);
        
        // Transfer the purchased tokens from the owner's wallet to the sender's wallet
        balances[owner] = balances[owner].sub(tokensPurchased);
        balances[msg.sender] = balances[msg.sender].add(tokensPurchased);
        Transfer(owner, msg.sender, tokensPurchased);
        
        // Transfer the Ether to the owner's wallet
        owner.transfer(msg.value);
    }
    
    // Allow the owner to make another address the owner
    function transferOwnership(address _newOwner) external
    {
        require(msg.sender == owner);
        owner = _newOwner;
    }
}
function () payable external
{
    buyTokens();
}

// If ETH is sent to this contract, assume they are trying to buy tokens